# Project Guidelines ## Protecting This File **IMPORTANT**: This file (claude.md) is gitignored and can be lost during branch operations! Git doesn't protect untracked/ignored files during `git checkout` or branch switches. Before major git operations: ```bash cp claude.md claude.md.backup ``` ## Coding Best Practices (CRITICAL) **Read `coding-best-practices.md` before writing any code.** It contains personal coding conventions that apply to every project — naming rules, file/function size limits, folder nesting patterns, persistence rules, and language-specific structure guides. Those rules override defaults and must be followed. ### File Header Check Rule **Every time you open a file to work on it, check the file header first.** Look for outstanding `@todo` items, unresolved `@issues`, or outdated `@status` notes. If any are completed or resolved, clean them up before doing other work. If a TODO is relevant to the current task, address it. This ensures nothing falls through the cracks. ## Project Structure (CRITICAL) This project follows a standardized structure for future modularity. The long-term goal is to enable drag-and-drop of components between projects. **This structure must be followed.** ``` ProjectRoot/ # git root ├── claude.md # (gitignored) AI assistant guidelines ├── coding-best-practices.md # Coding conventions (read before Phase 1) ├── build_spec.md # (gitignored) Full project specification ├── build_plan.md # (gitignored) Phased task checklist ├── .gitignore ├── docs/ # Public-facing documentation (parsed to HTML for website) │ ├── README.md # Docs index with table of contents │ ├── getting-started.md │ ├── architecture.md │ ├── development.md │ ├── deployment.md │ └── feature-*.md # Feature docs (added per phase) ├── InternalDocs/ # Internal development documentation (not public) │ └── ... # Design decisions, technical debt, internal API docs └── app/ # ALL project code lives here ├── src/ │ ├── assets/ # Static assets │ ├── boot/ # Quasar boot files (nhost init, etc.) │ ├── components/ # Vue components │ ├── composables/ # Vue composables │ ├── layouts/ # Page layouts │ ├── pages/ # Route pages │ ├── router/ # Vue Router config │ ├── stores/ # Pinia stores │ ├── services/ # API services │ └── types/ # TypeScript types ├── nhost/ # Nhost configuration │ ├── functions/ # Serverless functions │ ├── migrations/ # Database migrations │ └── metadata/ # Hasura metadata ├── public/ # Public static files ├── docker-compose.yml ├── .env # Dev environment (gitignored) └── .env.prod # Prod environment (gitignored) ``` ## Terminology - **"build spec"** or **"spec"** refers to `build_spec.md` - the full project description - **"build plan"** or **"plan"** refers to `build_plan.md` - the phased task checklist ## Onboarding Questions (Ask at Project Start) At the start of every new project conversation, gather these details before writing any code: 1. **Brand colors & fonts** - Primary, secondary, accent colors. Typography preferences. Any existing brand guidelines or color palette? 2. **App personality & tone** - Formal or casual? Dark or light default theme? Dense or spacious layout? Any design inspiration or reference apps? 3. **Target platform** - Desktop-first, mobile-first, or responsive? Specific OS targets (macOS, Windows, Linux)? Minimum screen sizes? 4. **Auth requirements** - Login method (email/password, OAuth, magic link)? User roles and permissions? Public or private app? Don't assume defaults for any of these. Ask, get answers, then document them in the Project-Specific Configuration section at the bottom of this file. ## Tech Stack - **Frontend**: Quasar Framework (Vue 3) - SPA mode - **Desktop** (optional): Tauri (Rust) - Cross-platform builds (macOS, Windows, Linux) - **Backend**: Nhost (self-hosted via Docker) - PostgreSQL - Database - Hasura - GraphQL API - Auth - Authentication service - Storage - File storage - Functions - Serverless functions (Node.js) - **Containerization**: Docker / Docker Compose ### Tauri Desktop Apps When building desktop apps with Tauri: - Add `src-tauri/` folder inside `app/` - Use the build-and-run approach (no hot reload) for consistent dev/prod builds - Separate bundle IDs for dev and prod (can run both simultaneously) ## Testing Changes (CRITICAL) **After every code editing session, you MUST rebuild the app so the user can test your changes.** ```bash cd app ./build.sh -dev -open ``` ### Why This Matters - This uses a **build-and-run** approach, not hot reload - Your code changes are NOT visible until you rebuild - Always rebuild before asking the user to test - If the user reports issues, check the logs first: `./build.sh logs` ## Build Script **Always use `build.sh` for building the app.** This ensures consistent builds and logging for collaborative debugging. ```bash cd app ./build.sh -dev -open # Build dev and open app ./build.sh -prod # Build prod to build/prod/ ./build.sh -install # Build prod and open Finder for drag-to-Applications ./build.sh logs # View latest console output (last 100 lines) ./build.sh clean # Clean build artifacts (preserves logs) ./build.sh clean-logs # Remove all logs ``` ### Commands | Command | Description | |---------|-------------| | `-dev` | Development build. Bundle ID: `com.[app].dev` | | `-prod` | Production build. Builds to `build/prod/`. | | `-install` | Build prod and open Finder for drag-to-Applications. | | `-open` | Open the app after building (use with `-dev` or `-prod`) | | `logs` | Show last 100 lines of console output | | `clean` | Remove build artifacts (preserves logs) | | `clean-logs` | Remove all log files | ### Why Build-and-Run (No Hot Reload) This project uses a **build-and-run** approach instead of hot reload: | Aspect | Hot Reload | Build-and-Run | |--------|------------|---------------| | Speed | Instant updates | Full rebuild required | | Dev/Prod parity | Different environments | Identical to production | | Debugging | Dev-only issues possible | What you test = what ships | | Logging | Console only | Full logs to files | The tradeoff is slower iteration, but you always test exactly what will ship. ### What the Build Does 1. **Build with Tauri** - `npx tauri build` does all of the following: - Build frontend (`npm run build` → `dist/spa/`) - Build Rust binary with embedded frontend - Create .app bundle in `src-tauri/target/release/bundle/macos/` 2. **Copy to build folder** - Copies bundle to `build/dev/` or `build/prod/` 3. **Update Info.plist** - Sets correct bundle ID for dev/prod 4. **Install (prod only)** - Copies to `~/Applications` **Important**: Using `npx tauri build` ensures the frontend is properly embedded in the binary. Manual `cargo build --release` does NOT embed the frontend. ### Build Output Builds are organized in separate folders: ``` app/build/ ├── dev/ │ └── AppName.app # Dev build (bundle ID: .dev) ├── prod/ │ └── AppName.app # Prod build ├── logs/ │ ├── build_dev_*.log # Build output logs │ └── build_latest.log # Symlink to latest └── console/ ├── console_*.log # App runtime console output └── console_latest.log # Symlink to latest ``` Dev and prod have different bundle IDs, so both can run simultaneously. ### Logging All build output and app console output is logged: - **Build logs**: `build/logs/build_latest.log` - compilation output, errors - **Console logs**: `build/console/console_latest.log` - runtime `console.log()`, errors When debugging, run `./build.sh logs` to see the latest console output. ### Console Logging Setup (Tauri) For frontend `console.log()` to appear in the logs, you need: 1. **Boot file** - Copy `templates/scripts/console-logger.ts` to `app/src/boot/` 2. **Register boot** - Add `'console-logger'` to `boot` array in `quasar.config.js` 3. **Rust command** - Add `log_to_stdout` command to `src-tauri/src/commands.rs` 4. **Cargo dep** - Add `chrono = "0.4"` to `Cargo.toml` The console-logger.ts template includes the Rust code you need to add. **How it works:** ``` console.log() → console-logger.ts → invoke('log_to_stdout') → Rust println!() → stdout → build.sh logs ``` ### When to Clean Run `./build.sh clean` when: - Switching between major dependency versions - Build errors reference stale/cached files - Rust compilation issues after Tauri config changes - Before creating a fresh production build ## Node.js Environment **Node.js version**: Always match Debian stable (currently Node.js 18.x for Debian 12 Bookworm) Check current Debian stable Node version: https://packages.debian.org/stable/nodejs **Package manager**: Use npm. Commit lock files for reproducible builds. Rules: - Always commit `package-lock.json` - required for deterministic installs - Never ignore lock files (`package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`) - Use `npm install` to install dependencies - Use `npm run