3.1 KiB
3.1 KiB
Agent Instructions
Monorepo Package Map
| Package | Purpose |
|---|---|
@repo/core |
Clean architecture: entities, use cases, interfaces, DI |
@repo/api |
tRPC router definitions (calls core controllers) |
@repo/api-client |
Shared React Query hooks + ApiProvider |
@repo/cms-core |
Payload CMS config, collections, hooks, globals |
@repo/cms-client |
Dual-mode Payload client (local + HTTP) |
@repo/ui |
shadcn/ui + Atomic Design component library |
@repo/eslint-config |
Shared ESLint flat configs |
@repo/typescript-config |
Shared TypeScript configs |
| App | Purpose |
|---|---|
apps/web-next |
Next.js 15 reference app |
apps/web-tanstack |
TanStack Start reference app |
apps/cms |
Thin Next.js shell for Payload admin |
apps/storybook |
Centralized Storybook instance |
Dependency Flow (one direction only)
apps/web-next, apps/web-tanstack → @repo/api-client → @repo/api → @repo/core
apps/cms → @repo/cms-core → @repo/core/application (hooks only)
@repo/core/infrastructure → @repo/cms-client (standalone)
@repo/ui (standalone)
HARD RULES — NEVER VIOLATE
- NEVER: packages/core → apps/*
- NEVER: apps/cms → packages/core/infrastructure
- NEVER: packages/cms-client → apps/cms or packages/core or packages/cms-core
- NEVER: packages/cms-core → packages/cms-client
- NEVER: core/entities → anything
- NEVER: core/application → core/infrastructure
How to Add a New Feature (end-to-end)
- Define entity in
packages/core/src/entities/models/ - Define repository interface in
packages/core/src/application/repositories/ - Write use case in
packages/core/src/application/use-cases/{domain}/ - Write controller in
packages/core/src/interface-adapters/controllers/{domain}/ - Write infrastructure implementation in
packages/core/src/infrastructure/ - Register in DI container (
packages/core/src/di/) - Add tRPC router in
packages/api/src/router/ - Add React Query hook in
packages/api-client/src/hooks/ - If CMS collection needed: add to
packages/cms-core/src/collections/ - Build UI component in
packages/ui/src/(classify atomic level) - Write Storybook story (co-located
.stories.tsx) - Write tests (unit in packages/core/tests/, E2E in tests/e2e/)
How to Add a New UI Component
- Classify: atom (single element), molecule (2-3 atoms), organism (complex section), template (layout)
- Create folder:
packages/ui/src/{level}/{component-name}/ - Create:
{name}.tsx,{name}.stories.tsx,index.ts - Story title:
"{Level}/{ComponentName}"(e.g.,"Atoms/Button") - Export from level's
index.tsbarrel file - Import rules: atoms ← nothing | molecules ← atoms | organisms ← atoms+molecules | templates ← all
How to Add a Payload CMS Collection
- Create folder:
packages/cms-core/src/collections/{name}/ - Create:
index.ts(CollectionConfig),fields.ts, optionallyhooks/,access/ - Import in
packages/cms-core/src/payload.config.tscollections array - Export from
packages/cms-core/src/index.ts - Hooks that contain business logic must delegate to use cases in
@repo/core/application