|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Commands |
| 6 | + |
| 7 | +```bash |
| 8 | +npm run develop # Start Gatsby dev server |
| 9 | +npm run build # Clean + production build |
| 10 | +npm run lint # Run Biome linter |
| 11 | +npm run lint:fix # Fix linting issues |
| 12 | +npm run format # Format code with Biome |
| 13 | +npm run typecheck # TypeScript type check (no emit) |
| 14 | +npm run test # Run Jest unit tests once |
| 15 | +npm run test:watch # Run Jest in watch mode |
| 16 | +npm run e2e:open # Open Cypress UI |
| 17 | +npm run e2e:all # Run all Cypress E2E tests |
| 18 | +``` |
| 19 | + |
| 20 | +Node: `22.17.0`, npm: `10.9.2`. Install with `npm i --legacy-peer-deps`. |
| 21 | + |
| 22 | +Requires `.env.development` with Firebase credentials (`GATSBY_API_URL`, `GATSBY_API_KEY`, `GATSBY_AUTH_DOMAIN`, `GATSBY_PROJECT_ID`, `GATSBY_STORAGE_BUCKET`, `GATSBY_MESSAGING_SENDER_ID`, `GATSBY_APP_ID`, `GATSBY_MEASUREMENT_ID`). |
| 23 | + |
| 24 | +## Architecture |
| 25 | + |
| 26 | +**Stack:** Gatsby 5 (SSG) + React 18 + TypeScript (strict) + Firebase backend (Cloud Functions, Auth, Storage) + Zustand state + Tailwind CSS + Biome linter. |
| 27 | + |
| 28 | +**Branching:** `develop` is the default branch; `main` is production-only. |
| 29 | + |
| 30 | +### Directory Map |
| 31 | + |
| 32 | +| Path | Purpose | |
| 33 | +|------|---------| |
| 34 | +| `src/pages/` | Gatsby file-based routing | |
| 35 | +| `src/features/` | Domain-driven feature directories (auth, creator, mindmap-creator, etc.) | |
| 36 | +| `src/modules/` | Feature-specific UI modules with local state | |
| 37 | +| `src/containers/` | Smart components that wire state to UI | |
| 38 | +| `src/components/` | Stateless, reusable UI pieces | |
| 39 | +| `src/design-system/` | Base UI components and design tokens | |
| 40 | +| `src/store/` | Zustand stores, one folder per feature | |
| 41 | +| `src/acts/` | Async multi-step operations that span multiple stores | |
| 42 | +| `src/api-4markdown/` | Firebase API client | |
| 43 | +| `src/api-4markdown-contracts/` | Typed API contracts and DTOs | |
| 44 | +| `src/core/` | Auth utilities, analytics, shared models | |
| 45 | +| `src/development-kit/` | Form utilities, Zustand wrapper (`state.ts`), helper functions | |
| 46 | +| `src/models/` | Shared data model types | |
| 47 | +| `src/providers/` | React context providers | |
| 48 | +| `src/layouts/` | Page layout components | |
| 49 | + |
| 50 | +### State Management Pattern (from DS.md) |
| 51 | + |
| 52 | +Every store feature lives under `src/store/[feature-name]/` with four files: |
| 53 | + |
| 54 | +``` |
| 55 | +index.ts # Creates and exports the Zustand hook: useFeatureNameState |
| 56 | +models.ts # Defines the state shape: type FeatureNameState = ... |
| 57 | +actions.ts # Sync-only state mutation functions (postfix: Action) |
| 58 | +selectors.ts # Typed data extraction functions (postfix: Selector) |
| 59 | +``` |
| 60 | + |
| 61 | +State is created via the custom wrapper in `development-kit/state.ts` which exposes `.swap()`, `.reset()`, and `.subscribe()`. |
| 62 | + |
| 63 | +**Acts** (`src/acts/name.act.ts`) orchestrate multi-step async flows that span multiple stores or require API calls + side effects. Use the `Act` postfix. |
| 64 | + |
| 65 | +### TypeScript Path Aliases |
| 66 | + |
| 67 | +Configured in `tsconfig.json` — use these instead of relative paths: |
| 68 | + |
| 69 | +`design-system/*`, `development-kit/*`, `store/*`, `features/*`, `modules/*`, `components/*`, `models/*`, `providers/*`, `core/*`, `layouts/*`, `acts/*`, `containers/*`, `api-4markdown`, `api-4markdown-contracts` |
| 70 | + |
| 71 | +### Conventions (from DS.md) |
| 72 | + |
| 73 | +- All exports go at the **bottom** of the file. |
| 74 | +- State type names use the `State` postfix (e.g., `UploadImageState`). |
| 75 | +- Action functions use the `Action` postfix; selectors use the `Selector` postfix. |
| 76 | +- Actions are always synchronous and free of side effects. |
| 77 | +- Acts always declare an explicit return type and use `AsyncResult<T>` from `development-kit/utility-types`. |
| 78 | +- Local single-use component props can be inlined without a named type: `({ content }: { content: string })`. |
| 79 | + |
| 80 | +### API Layer |
| 81 | + |
| 82 | +API calls go through `getAPI().call('methodName')(params)` from `api-4markdown`. Errors are parsed via `parseError()`. The `api-4markdown-contracts` package defines all method contracts and DTOs. |
| 83 | + |
| 84 | +### Graph/Mindmap |
| 85 | + |
| 86 | +`@xyflow/react` handles diagram rendering; `@dagrejs/dagre` provides the layout engine. Key features: `mindmap-creator`, `mindmap-preview`, `mindmap-display`. |
0 commit comments