specialist-agent 2.12.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +33 -207
- package/dist/catalog.json +15529 -0
- package/dist/hw-worker.mjs +254 -0
- package/dist/icones/icone.ico +0 -0
- package/dist/icones/icone.png +0 -0
- package/dist/interface/assets/figtree-latin-400-normal-g7Dtegnw.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-500-normal-BWnGEVsr.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-600-normal-Cv_xCTDl.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-700-normal-th6qEP7c.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-ext-400-normal-CXAzuTZb.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-ext-500-normal-Du0rIuHj.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-ext-600-normal-DJlfifZj.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-ext-700-normal-CS4sQkGV.woff2 +0 -0
- package/dist/interface/assets/index-BIyqZkro.css +1 -0
- package/dist/interface/assets/index-zAegy908.js +13 -0
- package/dist/interface/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-ext-500-normal-Cut-4mMH.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-ext-600-normal-BfB_LPfz.woff2 +0 -0
- package/dist/interface/assets/unbounded-latin-500-normal-4slEIF53.woff2 +0 -0
- package/dist/interface/assets/unbounded-latin-700-normal-CaoNriVp.woff2 +0 -0
- package/dist/interface/assets/unbounded-latin-ext-500-normal-BTIpesyw.woff2 +0 -0
- package/dist/interface/assets/unbounded-latin-ext-700-normal-BLzWLLjG.woff2 +0 -0
- package/dist/interface/icones/apple-touch-icon.png +0 -0
- package/dist/interface/icones/favicon-32.png +0 -0
- package/dist/interface/icones/icone-192.png +0 -0
- package/dist/interface/icones/icone-512.png +0 -0
- package/dist/interface/icones/icone-mascara-512.png +0 -0
- package/dist/interface/index.html +19 -0
- package/dist/interface/manifest.webmanifest +19 -0
- package/dist/interface/sw.js +63 -0
- package/dist/specialist-agent.mjs +6919 -0
- package/dist/usage-worker.mjs +174 -0
- package/package.json +32 -57
- package/.claude-plugin/marketplace.json +0 -52
- package/.claude-plugin/plugin.json +0 -37
- package/.codex/INSTALL.md +0 -145
- package/.cursor-plugin/marketplace.json +0 -52
- package/.cursor-plugin/plugin.json +0 -37
- package/.opencode/INSTALL.md +0 -127
- package/.opencode/opencode.json +0 -186
- package/agents/analyst-lite.md +0 -48
- package/agents/analyst.md +0 -396
- package/agents/api-lite.md +0 -43
- package/agents/api.md +0 -427
- package/agents/architect-lite.md +0 -104
- package/agents/architect.md +0 -571
- package/agents/autopilot-lite.md +0 -46
- package/agents/autopilot.md +0 -196
- package/agents/cloud-lite.md +0 -75
- package/agents/cloud.md +0 -213
- package/agents/data-lite.md +0 -67
- package/agents/data.md +0 -306
- package/agents/debugger-lite.md +0 -46
- package/agents/debugger.md +0 -410
- package/agents/deps-lite.md +0 -41
- package/agents/deps.md +0 -363
- package/agents/designer-lite.md +0 -67
- package/agents/designer.md +0 -195
- package/agents/devops-lite.md +0 -67
- package/agents/devops.md +0 -205
- package/agents/docs-lite.md +0 -42
- package/agents/docs.md +0 -454
- package/agents/executor-lite.md +0 -61
- package/agents/executor.md +0 -695
- package/agents/explorer-lite.md +0 -55
- package/agents/explorer.md +0 -152
- package/agents/finance-lite.md +0 -66
- package/agents/finance.md +0 -255
- package/agents/i18n-lite.md +0 -44
- package/agents/i18n.md +0 -594
- package/agents/legal-lite.md +0 -113
- package/agents/legal.md +0 -302
- package/agents/marketing-lite.md +0 -25
- package/agents/marketing.md +0 -188
- package/agents/memory.md +0 -166
- package/agents/orchestrator-lite.md +0 -40
- package/agents/orchestrator.md +0 -512
- package/agents/pair-lite.md +0 -38
- package/agents/pair.md +0 -310
- package/agents/perf-lite.md +0 -42
- package/agents/perf.md +0 -320
- package/agents/planner-lite.md +0 -59
- package/agents/planner.md +0 -272
- package/agents/product-lite.md +0 -25
- package/agents/product.md +0 -195
- package/agents/refactor-lite.md +0 -42
- package/agents/refactor.md +0 -467
- package/agents/ripple-lite.md +0 -106
- package/agents/ripple.md +0 -166
- package/agents/scout-lite.md +0 -37
- package/agents/scout.md +0 -224
- package/agents/security-lite.md +0 -66
- package/agents/security.md +0 -252
- package/agents/sentry-triage-lite.md +0 -54
- package/agents/sentry-triage.md +0 -217
- package/agents/starter-lite.md +0 -80
- package/agents/starter.md +0 -300
- package/agents/support-lite.md +0 -24
- package/agents/support.md +0 -191
- package/agents/tdd-lite.md +0 -43
- package/agents/tdd.md +0 -329
- package/agents/tester-lite.md +0 -71
- package/agents/tester.md +0 -237
- package/cli/architectures.mjs +0 -713
- package/cli/detect-architecture.mjs +0 -752
- package/cli/generate-architecture.mjs +0 -1096
- package/cli/index.mjs +0 -1217
- package/cli/recommend-architecture.mjs +0 -870
- package/hooks/after-review.mjs +0 -130
- package/hooks/after-task.mjs +0 -117
- package/hooks/before-plan.mjs +0 -155
- package/hooks/before-review.mjs +0 -139
- package/hooks/hooks.json +0 -66
- package/hooks/lifecycle.json +0 -91
- package/hooks/native/auto-dispatch.mjs +0 -207
- package/hooks/native/auto-format.mjs +0 -176
- package/hooks/native/mcp-discovery.mjs +0 -168
- package/hooks/native/security-config.json +0 -38
- package/hooks/native/security-guard.mjs +0 -323
- package/hooks/native/session-context.mjs +0 -179
- package/hooks/native/session-end.mjs +0 -42
- package/hooks/native/utils.mjs +0 -62
- package/hooks/on-error.mjs +0 -129
- package/hooks/session-end.mjs +0 -185
- package/hooks/session-start.mjs +0 -154
- package/packs/angular/ARCHITECTURE.md +0 -814
- package/packs/angular/CLAUDE.md +0 -105
- package/packs/angular/agents/builder.md +0 -113
- package/packs/angular/agents/doctor.md +0 -187
- package/packs/angular/agents/migrator.md +0 -101
- package/packs/angular/agents/reviewer.md +0 -252
- package/packs/angular/agents-lite/builder.md +0 -65
- package/packs/angular/agents-lite/doctor.md +0 -64
- package/packs/angular/agents-lite/migrator.md +0 -75
- package/packs/angular/agents-lite/reviewer.md +0 -69
- package/packs/angular/skills/dev-create-component/SKILL.md +0 -56
- package/packs/angular/skills/dev-create-injectable/SKILL.md +0 -60
- package/packs/angular/skills/dev-create-module/SKILL.md +0 -49
- package/packs/angular/skills/dev-create-service/SKILL.md +0 -34
- package/packs/angular/skills/dev-create-test/SKILL.md +0 -78
- package/packs/angular/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/angular/skills/docs-onboard/SKILL.md +0 -42
- package/packs/angular/skills/migration-migrate-component/SKILL.md +0 -42
- package/packs/angular/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/angular/skills/review-check-architecture/SKILL.md +0 -67
- package/packs/angular/skills/review-fix-violations/SKILL.md +0 -43
- package/packs/angular/skills/review-review/SKILL.md +0 -43
- package/packs/astro/ARCHITECTURE.md +0 -718
- package/packs/astro/CLAUDE.md +0 -106
- package/packs/astro/agents/builder.md +0 -123
- package/packs/astro/agents/doctor.md +0 -200
- package/packs/astro/agents/migrator.md +0 -105
- package/packs/astro/agents/reviewer.md +0 -253
- package/packs/astro/agents-lite/builder.md +0 -71
- package/packs/astro/agents-lite/doctor.md +0 -66
- package/packs/astro/agents-lite/migrator.md +0 -71
- package/packs/astro/agents-lite/reviewer.md +0 -70
- package/packs/astro/skills/dev-create-component/SKILL.md +0 -50
- package/packs/astro/skills/dev-create-island/SKILL.md +0 -63
- package/packs/astro/skills/dev-create-module/SKILL.md +0 -49
- package/packs/astro/skills/dev-create-service/SKILL.md +0 -34
- package/packs/astro/skills/dev-create-test/SKILL.md +0 -76
- package/packs/astro/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/astro/skills/docs-onboard/SKILL.md +0 -51
- package/packs/astro/skills/migration-migrate-component/SKILL.md +0 -48
- package/packs/astro/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/astro/skills/review-check-architecture/SKILL.md +0 -72
- package/packs/astro/skills/review-fix-violations/SKILL.md +0 -43
- package/packs/astro/skills/review-review/SKILL.md +0 -45
- package/packs/nextjs/ARCHITECTURE.md +0 -1033
- package/packs/nextjs/CLAUDE.md +0 -106
- package/packs/nextjs/agents/builder.md +0 -132
- package/packs/nextjs/agents/doctor.md +0 -226
- package/packs/nextjs/agents/migrator.md +0 -101
- package/packs/nextjs/agents/reviewer.md +0 -243
- package/packs/nextjs/agents-lite/builder.md +0 -74
- package/packs/nextjs/agents-lite/doctor.md +0 -74
- package/packs/nextjs/agents-lite/migrator.md +0 -75
- package/packs/nextjs/agents-lite/reviewer.md +0 -73
- package/packs/nextjs/skills/dev-create-component/SKILL.md +0 -82
- package/packs/nextjs/skills/dev-create-hook/SKILL.md +0 -90
- package/packs/nextjs/skills/dev-create-module/SKILL.md +0 -63
- package/packs/nextjs/skills/dev-create-service/SKILL.md +0 -35
- package/packs/nextjs/skills/dev-create-test/SKILL.md +0 -106
- package/packs/nextjs/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/nextjs/skills/docs-onboard/SKILL.md +0 -55
- package/packs/nextjs/skills/migration-migrate-component/SKILL.md +0 -58
- package/packs/nextjs/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/nextjs/skills/review-check-architecture/SKILL.md +0 -101
- package/packs/nextjs/skills/review-fix-violations/SKILL.md +0 -48
- package/packs/nextjs/skills/review-review/SKILL.md +0 -47
- package/packs/nuxt/ARCHITECTURE.md +0 -831
- package/packs/nuxt/CLAUDE.md +0 -111
- package/packs/nuxt/agents/builder.md +0 -120
- package/packs/nuxt/agents/doctor.md +0 -198
- package/packs/nuxt/agents/migrator.md +0 -101
- package/packs/nuxt/agents/reviewer.md +0 -255
- package/packs/nuxt/agents-lite/builder.md +0 -67
- package/packs/nuxt/agents-lite/doctor.md +0 -67
- package/packs/nuxt/agents-lite/migrator.md +0 -80
- package/packs/nuxt/agents-lite/reviewer.md +0 -71
- package/packs/nuxt/skills/dev-create-component/SKILL.md +0 -60
- package/packs/nuxt/skills/dev-create-composable/SKILL.md +0 -33
- package/packs/nuxt/skills/dev-create-module/SKILL.md +0 -49
- package/packs/nuxt/skills/dev-create-service/SKILL.md +0 -34
- package/packs/nuxt/skills/dev-create-test/SKILL.md +0 -61
- package/packs/nuxt/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/nuxt/skills/docs-onboard/SKILL.md +0 -49
- package/packs/nuxt/skills/migration-migrate-component/SKILL.md +0 -48
- package/packs/nuxt/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/nuxt/skills/review-check-architecture/SKILL.md +0 -71
- package/packs/nuxt/skills/review-fix-violations/SKILL.md +0 -43
- package/packs/nuxt/skills/review-review/SKILL.md +0 -45
- package/packs/react/ARCHITECTURE.md +0 -991
- package/packs/react/CLAUDE.md +0 -102
- package/packs/react/agents/builder.md +0 -113
- package/packs/react/agents/doctor.md +0 -203
- package/packs/react/agents/migrator.md +0 -101
- package/packs/react/agents/reviewer.md +0 -252
- package/packs/react/agents-lite/builder.md +0 -65
- package/packs/react/agents-lite/doctor.md +0 -64
- package/packs/react/agents-lite/migrator.md +0 -74
- package/packs/react/agents-lite/reviewer.md +0 -69
- package/packs/react/skills/dev-create-component/SKILL.md +0 -53
- package/packs/react/skills/dev-create-hook/SKILL.md +0 -78
- package/packs/react/skills/dev-create-module/SKILL.md +0 -51
- package/packs/react/skills/dev-create-service/SKILL.md +0 -34
- package/packs/react/skills/dev-create-test/SKILL.md +0 -92
- package/packs/react/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/react/skills/docs-onboard/SKILL.md +0 -42
- package/packs/react/skills/migration-migrate-component/SKILL.md +0 -44
- package/packs/react/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/react/skills/review-check-architecture/SKILL.md +0 -73
- package/packs/react/skills/review-fix-violations/SKILL.md +0 -45
- package/packs/react/skills/review-review/SKILL.md +0 -44
- package/packs/svelte/ARCHITECTURE.md +0 -975
- package/packs/svelte/CLAUDE.md +0 -102
- package/packs/svelte/agents/builder.md +0 -114
- package/packs/svelte/agents/doctor.md +0 -174
- package/packs/svelte/agents/migrator.md +0 -101
- package/packs/svelte/agents/reviewer.md +0 -238
- package/packs/svelte/agents-lite/builder.md +0 -66
- package/packs/svelte/agents-lite/doctor.md +0 -67
- package/packs/svelte/agents-lite/migrator.md +0 -82
- package/packs/svelte/agents-lite/reviewer.md +0 -70
- package/packs/svelte/skills/dev-create-component/SKILL.md +0 -77
- package/packs/svelte/skills/dev-create-module/SKILL.md +0 -59
- package/packs/svelte/skills/dev-create-service/SKILL.md +0 -35
- package/packs/svelte/skills/dev-create-store/SKILL.md +0 -94
- package/packs/svelte/skills/dev-create-test/SKILL.md +0 -98
- package/packs/svelte/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/svelte/skills/docs-onboard/SKILL.md +0 -47
- package/packs/svelte/skills/migration-migrate-component/SKILL.md +0 -51
- package/packs/svelte/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/svelte/skills/review-check-architecture/SKILL.md +0 -79
- package/packs/svelte/skills/review-fix-violations/SKILL.md +0 -47
- package/packs/svelte/skills/review-review/SKILL.md +0 -45
- package/packs/vue/ARCHITECTURE.md +0 -798
- package/packs/vue/CLAUDE.md +0 -102
- package/packs/vue/agents/builder.md +0 -112
- package/packs/vue/agents/doctor.md +0 -185
- package/packs/vue/agents/migrator.md +0 -101
- package/packs/vue/agents/reviewer.md +0 -249
- package/packs/vue/agents-lite/builder.md +0 -65
- package/packs/vue/agents-lite/doctor.md +0 -63
- package/packs/vue/agents-lite/migrator.md +0 -73
- package/packs/vue/agents-lite/reviewer.md +0 -68
- package/packs/vue/skills/dev-create-component/SKILL.md +0 -58
- package/packs/vue/skills/dev-create-composable/SKILL.md +0 -31
- package/packs/vue/skills/dev-create-module/SKILL.md +0 -50
- package/packs/vue/skills/dev-create-service/SKILL.md +0 -34
- package/packs/vue/skills/dev-create-test/SKILL.md +0 -62
- package/packs/vue/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/vue/skills/docs-onboard/SKILL.md +0 -42
- package/packs/vue/skills/migration-migrate-component/SKILL.md +0 -41
- package/packs/vue/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/vue/skills/review-check-architecture/SKILL.md +0 -73
- package/packs/vue/skills/review-fix-violations/SKILL.md +0 -42
- package/packs/vue/skills/review-review/SKILL.md +0 -43
- package/skills/audit/SKILL.md +0 -231
- package/skills/autofix/SKILL.md +0 -166
- package/skills/autopilot/SKILL.md +0 -286
- package/skills/brainstorm/SKILL.md +0 -298
- package/skills/checkpoint/SKILL.md +0 -217
- package/skills/codereview/SKILL.md +0 -268
- package/skills/commit/SKILL.md +0 -150
- package/skills/copywriting/SKILL.md +0 -218
- package/skills/cro/SKILL.md +0 -234
- package/skills/debug/SKILL.md +0 -210
- package/skills/design-review/SKILL.md +0 -217
- package/skills/discovery/SKILL.md +0 -218
- package/skills/estimate/SKILL.md +0 -154
- package/skills/finish/SKILL.md +0 -220
- package/skills/grill/SKILL.md +0 -270
- package/skills/health/SKILL.md +0 -251
- package/skills/improve-architecture/SKILL.md +0 -205
- package/skills/learn/SKILL.md +0 -260
- package/skills/lint/SKILL.md +0 -126
- package/skills/migrate-architecture/SKILL.md +0 -242
- package/skills/migrate-framework/SKILL.md +0 -172
- package/skills/onboard/SKILL.md +0 -168
- package/skills/plan/SKILL.md +0 -141
- package/skills/prd/SKILL.md +0 -241
- package/skills/recall/SKILL.md +0 -112
- package/skills/remember/SKILL.md +0 -108
- package/skills/seo-audit/SKILL.md +0 -240
- package/skills/tdd/SKILL.md +0 -201
- package/skills/tutorial/SKILL.md +0 -346
- package/skills/verify/SKILL.md +0 -168
- package/skills/worktree/SKILL.md +0 -168
- package/skills/write-skill/SKILL.md +0 -225
- package/templates/autopilot/PROMPT.md +0 -39
- package/templates/autopilot/README.md +0 -122
- package/templates/autopilot/devcontainer.json +0 -21
- package/templates/industry/ecommerce.md +0 -127
- package/templates/industry/fintech.md +0 -161
- package/templates/industry/saas.md +0 -134
- package/templates/session-memory.json +0 -48
- package/templates/skill-template/SKILL.md +0 -90
|
@@ -1,1033 +0,0 @@
|
|
|
1
|
-
# ARCHITECTURE.md -- Architecture & Patterns Guide (Next.js)
|
|
2
|
-
|
|
3
|
-
> This document is the **source of truth** for all subagents.
|
|
4
|
-
> Every architectural decision must be documented here.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## 1. Overview
|
|
9
|
-
|
|
10
|
-
Architecture for Next.js 14+ projects using the App Router, TypeScript strict mode, and a modular feature-based structure:
|
|
11
|
-
|
|
12
|
-
| Concept | Implementation |
|
|
13
|
-
|---------|---------------|
|
|
14
|
-
| Framework | Next.js 14+ (App Router) |
|
|
15
|
-
| Language | TypeScript (strict) |
|
|
16
|
-
| Server rendering | React Server Components (default) |
|
|
17
|
-
| Client interactivity | Client Components (`'use client'`) |
|
|
18
|
-
| Mutations | Server Actions (`'use server'`) |
|
|
19
|
-
| Client state | Zustand |
|
|
20
|
-
| Server state (client-side) | TanStack React Query |
|
|
21
|
-
| Data fetching (server) | async Server Components / Server Actions |
|
|
22
|
-
| Routing | App Router file-system conventions |
|
|
23
|
-
| Testing | Vitest + React Testing Library |
|
|
24
|
-
| Validation | Zod |
|
|
25
|
-
|
|
26
|
-
### Architecture Flow
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
Service (HTTP only) --> Adapter (parse) --> Hook / Server Action (orchestrate) --> Component / Page / Layout (RSC + Client)
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## 2. Directory Structure (Modular Architecture)
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
src/
|
|
38
|
-
├── app/ # Next.js App Router
|
|
39
|
-
│ ├── layout.tsx # Root layout (RSC)
|
|
40
|
-
│ ├── page.tsx # Home page
|
|
41
|
-
│ ├── loading.tsx # Root loading UI
|
|
42
|
-
│ ├── error.tsx # Root error boundary ('use client')
|
|
43
|
-
│ ├── not-found.tsx # 404 page
|
|
44
|
-
│ ├── providers.tsx # Client providers (QueryClient, Zustand, Theme)
|
|
45
|
-
│ ├── globals.css
|
|
46
|
-
│ │
|
|
47
|
-
│ ├── [feature]/ # Feature route group
|
|
48
|
-
│ │ ├── page.tsx # Feature page (RSC)
|
|
49
|
-
│ │ ├── layout.tsx # Feature layout (RSC)
|
|
50
|
-
│ │ ├── loading.tsx # Feature loading skeleton
|
|
51
|
-
│ │ ├── error.tsx # Feature error boundary ('use client')
|
|
52
|
-
│ │ └── not-found.tsx # Feature 404
|
|
53
|
-
│ │
|
|
54
|
-
│ └── api/ # Route Handlers (external API endpoints)
|
|
55
|
-
│ └── [resource]/
|
|
56
|
-
│ └── route.ts # GET, POST, PUT, DELETE handlers
|
|
57
|
-
│
|
|
58
|
-
├── modules/ # Feature modules (bounded contexts)
|
|
59
|
-
│ ├── auth/
|
|
60
|
-
│ │ ├── components/
|
|
61
|
-
│ │ ├── hooks/
|
|
62
|
-
│ │ ├── services/
|
|
63
|
-
│ │ ├── adapters/
|
|
64
|
-
│ │ ├── stores/
|
|
65
|
-
│ │ ├── actions/
|
|
66
|
-
│ │ ├── types/
|
|
67
|
-
│ │ ├── __tests__/
|
|
68
|
-
│ │ └── index.ts # Barrel export (public API)
|
|
69
|
-
│ │
|
|
70
|
-
│ ├── marketplace/
|
|
71
|
-
│ │ ├── components/
|
|
72
|
-
│ │ │ ├── MarketplaceList.tsx
|
|
73
|
-
│ │ │ ├── MarketplaceCard.tsx
|
|
74
|
-
│ │ │ ├── MarketplaceFilters.tsx
|
|
75
|
-
│ │ │ └── marketplace-card/ # Sub-components if needed
|
|
76
|
-
│ │ │ ├── MarketplaceCardHeader.tsx
|
|
77
|
-
│ │ │ └── MarketplaceCardActions.tsx
|
|
78
|
-
│ │ ├── hooks/
|
|
79
|
-
│ │ │ ├── useMarketplaceList.ts
|
|
80
|
-
│ │ │ └── useMarketplaceFilters.ts
|
|
81
|
-
│ │ ├── services/
|
|
82
|
-
│ │ │ └── marketplace-service.ts
|
|
83
|
-
│ │ ├── adapters/
|
|
84
|
-
│ │ │ └── marketplace-adapter.ts
|
|
85
|
-
│ │ ├── stores/
|
|
86
|
-
│ │ │ └── marketplace-store.ts # Client state only (filters, UI)
|
|
87
|
-
│ │ ├── actions/
|
|
88
|
-
│ │ │ └── marketplace-actions.ts # Server Actions ('use server')
|
|
89
|
-
│ │ ├── types/
|
|
90
|
-
│ │ │ ├── marketplace.types.ts
|
|
91
|
-
│ │ │ └── marketplace.contracts.ts # Zod schemas
|
|
92
|
-
│ │ ├── __tests__/
|
|
93
|
-
│ │ └── index.ts
|
|
94
|
-
│ │
|
|
95
|
-
│ └── [other-module]/
|
|
96
|
-
│
|
|
97
|
-
├── shared/ # Shared across modules
|
|
98
|
-
│ ├── components/ # Generic components (Button, Modal, Table)
|
|
99
|
-
│ ├── hooks/ # Shared hooks
|
|
100
|
-
│ ├── services/ # Base API client, interceptors
|
|
101
|
-
│ ├── adapters/ # Shared adapters
|
|
102
|
-
│ ├── types/ # Global types
|
|
103
|
-
│ ├── utils/ # Pure functions, no side effects
|
|
104
|
-
│ ├── helpers/ # Functions with side effects or DOM
|
|
105
|
-
│ ├── constants/ # Static values
|
|
106
|
-
│ └── providers/ # React context providers
|
|
107
|
-
│
|
|
108
|
-
└── assets/ # Static files (images, fonts, global CSS)
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Import Rules Between Layers
|
|
112
|
-
|
|
113
|
-
```
|
|
114
|
-
modules/auth <-> shared/ OK Module imports from shared
|
|
115
|
-
modules/auth --> modules/market NO Module MUST NOT import from another module
|
|
116
|
-
shared/ --> modules/auth NO Shared MUST NOT import from modules
|
|
117
|
-
app/ --> modules/* OK App imports modules (pages, layouts)
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
If two modules need to share something, move it to `shared/`.
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
## 3. Naming Conventions
|
|
125
|
-
|
|
126
|
-
### Files & Directories
|
|
127
|
-
|
|
128
|
-
| Type | Pattern | Example |
|
|
129
|
-
|------|---------|---------|
|
|
130
|
-
| Directories | `kebab-case` | `user-settings/` |
|
|
131
|
-
| Components (TSX) | `PascalCase.tsx` | `UserSettingsForm.tsx` |
|
|
132
|
-
| Pages | `page.tsx` (App Router) | `app/marketplace/page.tsx` |
|
|
133
|
-
| Layouts | `layout.tsx` (App Router) | `app/marketplace/layout.tsx` |
|
|
134
|
-
| Hooks | `use` + `PascalCase.ts` | `useMarketplaceList.ts` |
|
|
135
|
-
| Services | `kebab-case-service.ts` | `marketplace-service.ts` |
|
|
136
|
-
| Adapters | `kebab-case-adapter.ts` | `marketplace-adapter.ts` |
|
|
137
|
-
| Stores (Zustand) | `kebab-case-store.ts` | `marketplace-store.ts` |
|
|
138
|
-
| Actions | `kebab-case-actions.ts` | `marketplace-actions.ts` |
|
|
139
|
-
| Types | `kebab-case.types.ts` | `marketplace.types.ts` |
|
|
140
|
-
| Contracts/Schemas | `kebab-case.contracts.ts` | `marketplace.contracts.ts` |
|
|
141
|
-
| Utils | `kebab-case.ts` | `format-date.ts` |
|
|
142
|
-
| Helpers | `kebab-case.ts` | `clipboard-helper.ts` |
|
|
143
|
-
| Tests | `OriginalName.spec.ts(x)` | `MarketplaceList.spec.tsx` |
|
|
144
|
-
| Constants | `kebab-case.constants.ts` | `api-endpoints.constants.ts` |
|
|
145
|
-
| Route Handlers | `route.ts` | `app/api/marketplace/route.ts` |
|
|
146
|
-
|
|
147
|
-
### Code
|
|
148
|
-
|
|
149
|
-
| Type | Pattern | Example |
|
|
150
|
-
|------|---------|---------|
|
|
151
|
-
| Variables / functions | `camelCase` | `getUserById`, `isLoading` |
|
|
152
|
-
| Types / Interfaces | `PascalCase` | `UserProfile`, `MarketplaceItem` |
|
|
153
|
-
| Enums | `PascalCase` | `UserRole.Admin` |
|
|
154
|
-
| Constants | `UPPER_SNAKE_CASE` | `API_BASE_URL`, `MAX_RETRIES` |
|
|
155
|
-
| Hooks | `use` + `PascalCase` | `useAuth`, `useMarketplaceList` |
|
|
156
|
-
| Store hooks | `use` + `PascalCase` + `Store` | `useMarketplaceStore` |
|
|
157
|
-
| Query Keys | `camelCase` array | `['marketplace', 'list', { page }]` |
|
|
158
|
-
| Event handlers | `handle` + action | `handleSubmit`, `handleDelete` |
|
|
159
|
-
| Server Actions | `camelCase` + verb | `createMarketplaceItem`, `deleteItem` |
|
|
160
|
-
| Boolean | `is`/`has`/`can`/`should` | `isLoading`, `hasPermission` |
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## 4. Responsibility Layers
|
|
165
|
-
|
|
166
|
-
### 4.1 Services -- Pure HTTP Calls
|
|
167
|
-
|
|
168
|
-
Services make **only** the HTTP request. No try/catch, no transformation, no business logic.
|
|
169
|
-
|
|
170
|
-
```typescript
|
|
171
|
-
// services/marketplace-service.ts
|
|
172
|
-
import { api } from '@/shared/services/api-client'
|
|
173
|
-
import type { MarketplaceListResponse, MarketplaceItemResponse } from '../types/marketplace.types'
|
|
174
|
-
|
|
175
|
-
export const marketplaceService = {
|
|
176
|
-
list(params: { page: number; pageSize: number; search?: string }) {
|
|
177
|
-
return api.get<MarketplaceListResponse>('/marketplace', { params })
|
|
178
|
-
},
|
|
179
|
-
|
|
180
|
-
getById(id: string) {
|
|
181
|
-
return api.get<MarketplaceItemResponse>(`/marketplace/${id}`)
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
create(payload: CreateMarketplacePayload) {
|
|
185
|
-
return api.post<MarketplaceItemResponse>('/marketplace', payload)
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
delete(id: string) {
|
|
189
|
-
return api.delete(`/marketplace/${id}`)
|
|
190
|
-
},
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
**Service Rules:**
|
|
195
|
-
- NO try/catch (caller handles errors)
|
|
196
|
-
- NO data transformation (adapter does that)
|
|
197
|
-
- NO business logic
|
|
198
|
-
- NO access to stores or hooks
|
|
199
|
-
- YES typed request/response
|
|
200
|
-
- YES one file per domain/resource
|
|
201
|
-
- YES export as object with methods
|
|
202
|
-
- Usable in both Server Components and Client Components
|
|
203
|
-
|
|
204
|
-
### 4.2 Adapters -- Contract Parsers
|
|
205
|
-
|
|
206
|
-
Adapters transform API data to the application TypeScript contract (and vice-versa). They are **pure functions** with no side effects.
|
|
207
|
-
|
|
208
|
-
```typescript
|
|
209
|
-
// adapters/marketplace-adapter.ts
|
|
210
|
-
import type {
|
|
211
|
-
MarketplaceListResponse,
|
|
212
|
-
MarketplaceItemResponse,
|
|
213
|
-
} from '../types/marketplace.types'
|
|
214
|
-
import type {
|
|
215
|
-
MarketplaceItem,
|
|
216
|
-
MarketplaceList,
|
|
217
|
-
} from '../types/marketplace.contracts'
|
|
218
|
-
|
|
219
|
-
export const marketplaceAdapter = {
|
|
220
|
-
/**
|
|
221
|
-
* API response -> App contract (inbound)
|
|
222
|
-
*/
|
|
223
|
-
toMarketplaceItem(response: MarketplaceItemResponse): MarketplaceItem {
|
|
224
|
-
return {
|
|
225
|
-
id: response.uuid,
|
|
226
|
-
name: response.name,
|
|
227
|
-
vendor: response.vendor_name,
|
|
228
|
-
category: response.category_slug,
|
|
229
|
-
price: response.price_cents / 100,
|
|
230
|
-
isActive: response.status === 'active',
|
|
231
|
-
createdAt: new Date(response.created_at),
|
|
232
|
-
updatedAt: new Date(response.updated_at),
|
|
233
|
-
}
|
|
234
|
-
},
|
|
235
|
-
|
|
236
|
-
toMarketplaceList(response: MarketplaceListResponse): MarketplaceList {
|
|
237
|
-
return {
|
|
238
|
-
items: response.results.map(marketplaceAdapter.toMarketplaceItem),
|
|
239
|
-
totalItems: response.count,
|
|
240
|
-
totalPages: Math.ceil(response.count / response.page_size),
|
|
241
|
-
currentPage: response.page,
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* App contract -> API payload (outbound)
|
|
247
|
-
*/
|
|
248
|
-
toCreatePayload(item: CreateMarketplaceInput): CreateMarketplacePayload {
|
|
249
|
-
return {
|
|
250
|
-
name: item.name,
|
|
251
|
-
vendor_name: item.vendor,
|
|
252
|
-
category_slug: item.category,
|
|
253
|
-
price_cents: Math.round(item.price * 100),
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
}
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
**Adapter Rules:**
|
|
260
|
-
- YES pure functions (input -> output, no side effects)
|
|
261
|
-
- YES bidirectional: API->App (inbound) and App->API (outbound)
|
|
262
|
-
- YES rename fields (snake_case API -> camelCase App)
|
|
263
|
-
- YES convert types (string->Date, cents->decimal, status->boolean)
|
|
264
|
-
- NO HTTP calls
|
|
265
|
-
- NO access to stores/hooks
|
|
266
|
-
- NO try/catch (failure = wrong type = bug to fix)
|
|
267
|
-
|
|
268
|
-
### 4.3 Types & Contracts
|
|
269
|
-
|
|
270
|
-
```typescript
|
|
271
|
-
// types/marketplace.types.ts
|
|
272
|
-
// Types that mirror the API response exactly (snake_case)
|
|
273
|
-
|
|
274
|
-
export interface MarketplaceItemResponse {
|
|
275
|
-
uuid: string
|
|
276
|
-
name: string
|
|
277
|
-
vendor_name: string
|
|
278
|
-
category_slug: string
|
|
279
|
-
price_cents: number
|
|
280
|
-
status: 'active' | 'inactive' | 'pending'
|
|
281
|
-
created_at: string
|
|
282
|
-
updated_at: string
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
export interface MarketplaceListResponse {
|
|
286
|
-
count: number
|
|
287
|
-
page: number
|
|
288
|
-
page_size: number
|
|
289
|
-
results: MarketplaceItemResponse[]
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
// types/marketplace.contracts.ts
|
|
293
|
-
// Application contracts (camelCase, correct types)
|
|
294
|
-
|
|
295
|
-
export interface MarketplaceItem {
|
|
296
|
-
id: string
|
|
297
|
-
name: string
|
|
298
|
-
vendor: string
|
|
299
|
-
category: string
|
|
300
|
-
price: number // in currency units, not cents
|
|
301
|
-
isActive: boolean // derived from status
|
|
302
|
-
createdAt: Date
|
|
303
|
-
updatedAt: Date
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
export interface MarketplaceList {
|
|
307
|
-
items: MarketplaceItem[]
|
|
308
|
-
totalItems: number
|
|
309
|
-
totalPages: number
|
|
310
|
-
currentPage: number
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
export interface CreateMarketplaceInput {
|
|
314
|
-
name: string
|
|
315
|
-
vendor: string
|
|
316
|
-
category: string
|
|
317
|
-
price: number
|
|
318
|
-
}
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
### 4.4 Hooks -- Business Logic + Orchestration (Client Only)
|
|
322
|
-
|
|
323
|
-
Hooks connect everything: call service, pass through adapter, manage loading/error, and expose reactive state. **Hooks can only be used in Client Components.**
|
|
324
|
-
|
|
325
|
-
```typescript
|
|
326
|
-
// hooks/useMarketplaceList.ts
|
|
327
|
-
'use client'
|
|
328
|
-
|
|
329
|
-
import { useQuery, keepPreviousData } from '@tanstack/react-query'
|
|
330
|
-
import { marketplaceService } from '../services/marketplace-service'
|
|
331
|
-
import { marketplaceAdapter } from '../adapters/marketplace-adapter'
|
|
332
|
-
import type { MarketplaceList } from '../types/marketplace.contracts'
|
|
333
|
-
|
|
334
|
-
interface UseMarketplaceListOptions {
|
|
335
|
-
page: number
|
|
336
|
-
pageSize?: number
|
|
337
|
-
search?: string
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
export function useMarketplaceList(options: UseMarketplaceListOptions) {
|
|
341
|
-
const { page, pageSize = 20, search = '' } = options
|
|
342
|
-
|
|
343
|
-
const query = useQuery({
|
|
344
|
-
queryKey: ['marketplace', 'list', { page, pageSize, search }],
|
|
345
|
-
queryFn: async (): Promise<MarketplaceList> => {
|
|
346
|
-
const response = await marketplaceService.list({ page, pageSize, search })
|
|
347
|
-
return marketplaceAdapter.toMarketplaceList(response.data)
|
|
348
|
-
},
|
|
349
|
-
staleTime: 5 * 60 * 1000,
|
|
350
|
-
placeholderData: keepPreviousData,
|
|
351
|
-
})
|
|
352
|
-
|
|
353
|
-
return {
|
|
354
|
-
// Data
|
|
355
|
-
items: query.data?.items ?? [],
|
|
356
|
-
totalPages: query.data?.totalPages ?? 0,
|
|
357
|
-
// State
|
|
358
|
-
isLoading: query.isLoading,
|
|
359
|
-
isFetching: query.isFetching,
|
|
360
|
-
isEmpty: !query.isLoading && (query.data?.items.length ?? 0) === 0,
|
|
361
|
-
error: query.error,
|
|
362
|
-
// Actions
|
|
363
|
-
refetch: query.refetch,
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
**Hook Rules:**
|
|
369
|
-
- YES orchestrate: service -> adapter -> React Query
|
|
370
|
-
- YES manage loading, error, empty states
|
|
371
|
-
- YES prefix `use`
|
|
372
|
-
- YES typed return values
|
|
373
|
-
- YES `'use client'` if using React hooks (useState, useEffect, useQuery)
|
|
374
|
-
- NO rendering (that is the component's job)
|
|
375
|
-
- NO direct API access (service does that)
|
|
376
|
-
|
|
377
|
-
### 4.5 Zustand Stores -- Client State Only
|
|
378
|
-
|
|
379
|
-
Zustand is for state that **does not come from the server**: UI state, filters, preferences, auth tokens.
|
|
380
|
-
|
|
381
|
-
```typescript
|
|
382
|
-
// stores/marketplace-store.ts
|
|
383
|
-
import { create } from 'zustand'
|
|
384
|
-
|
|
385
|
-
interface MarketplaceState {
|
|
386
|
-
// State
|
|
387
|
-
selectedCategory: string | null
|
|
388
|
-
viewMode: 'grid' | 'list'
|
|
389
|
-
searchQuery: string
|
|
390
|
-
// Derived
|
|
391
|
-
hasActiveFilters: boolean
|
|
392
|
-
// Actions
|
|
393
|
-
setCategory: (category: string | null) => void
|
|
394
|
-
setViewMode: (mode: 'grid' | 'list') => void
|
|
395
|
-
setSearchQuery: (query: string) => void
|
|
396
|
-
clearFilters: () => void
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
export const useMarketplaceStore = create<MarketplaceState>((set, get) => ({
|
|
400
|
-
// State
|
|
401
|
-
selectedCategory: null,
|
|
402
|
-
viewMode: 'grid',
|
|
403
|
-
searchQuery: '',
|
|
404
|
-
|
|
405
|
-
// Derived (computed via get())
|
|
406
|
-
get hasActiveFilters() {
|
|
407
|
-
const state = get()
|
|
408
|
-
return !!state.selectedCategory || !!state.searchQuery
|
|
409
|
-
},
|
|
410
|
-
|
|
411
|
-
// Actions
|
|
412
|
-
setCategory: (category) => set({ selectedCategory: category }),
|
|
413
|
-
setViewMode: (mode) => set({ viewMode: mode }),
|
|
414
|
-
setSearchQuery: (query) => set({ searchQuery: query }),
|
|
415
|
-
clearFilters: () => set({ selectedCategory: null, searchQuery: '' }),
|
|
416
|
-
}))
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
**Store Rules:**
|
|
420
|
-
- YES client state only (UI, filters, preferences, session)
|
|
421
|
-
- YES `create<T>()` from Zustand
|
|
422
|
-
- YES selectors for granular subscriptions in components
|
|
423
|
-
- YES actions co-located with state
|
|
424
|
-
- NO server state (API data goes in TanStack React Query)
|
|
425
|
-
- NO HTTP calls inside stores
|
|
426
|
-
- NO complex business logic (hook does that)
|
|
427
|
-
|
|
428
|
-
### 4.6 Server Actions -- Server-Side Mutations
|
|
429
|
-
|
|
430
|
-
Server Actions handle mutations that run on the server. They replace API routes for form submissions and data mutations.
|
|
431
|
-
|
|
432
|
-
```typescript
|
|
433
|
-
// actions/marketplace-actions.ts
|
|
434
|
-
'use server'
|
|
435
|
-
|
|
436
|
-
import { revalidatePath } from 'next/cache'
|
|
437
|
-
import { marketplaceService } from '../services/marketplace-service'
|
|
438
|
-
import { marketplaceAdapter } from '../adapters/marketplace-adapter'
|
|
439
|
-
import type { CreateMarketplaceInput } from '../types/marketplace.contracts'
|
|
440
|
-
|
|
441
|
-
export async function createMarketplaceItem(input: CreateMarketplaceInput) {
|
|
442
|
-
const payload = marketplaceAdapter.toCreatePayload(input)
|
|
443
|
-
const response = await marketplaceService.create(payload)
|
|
444
|
-
const item = marketplaceAdapter.toMarketplaceItem(response.data)
|
|
445
|
-
|
|
446
|
-
revalidatePath('/marketplace')
|
|
447
|
-
return item
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
export async function deleteMarketplaceItem(id: string) {
|
|
451
|
-
await marketplaceService.delete(id)
|
|
452
|
-
revalidatePath('/marketplace')
|
|
453
|
-
}
|
|
454
|
-
```
|
|
455
|
-
|
|
456
|
-
**Server Action Rules:**
|
|
457
|
-
- YES `'use server'` directive at the top of the file
|
|
458
|
-
- YES use service + adapter (same as hooks)
|
|
459
|
-
- YES `revalidatePath()` or `revalidateTag()` after mutations
|
|
460
|
-
- YES can be called from Client Components via forms or event handlers
|
|
461
|
-
- YES can be called from Server Components via forms
|
|
462
|
-
- NO direct database access (use service layer)
|
|
463
|
-
- NO returning non-serializable data (no Date objects, no functions)
|
|
464
|
-
|
|
465
|
-
### 4.7 Route Handlers -- External API Endpoints
|
|
466
|
-
|
|
467
|
-
Route Handlers are for external API endpoints (webhooks, third-party integrations, public APIs).
|
|
468
|
-
|
|
469
|
-
```typescript
|
|
470
|
-
// app/api/marketplace/route.ts
|
|
471
|
-
import { NextRequest, NextResponse } from 'next/server'
|
|
472
|
-
import { marketplaceService } from '@/modules/marketplace/services/marketplace-service'
|
|
473
|
-
import { marketplaceAdapter } from '@/modules/marketplace/adapters/marketplace-adapter'
|
|
474
|
-
|
|
475
|
-
export async function GET(request: NextRequest) {
|
|
476
|
-
const searchParams = request.nextUrl.searchParams
|
|
477
|
-
const page = Number(searchParams.get('page') ?? 1)
|
|
478
|
-
const pageSize = Number(searchParams.get('pageSize') ?? 20)
|
|
479
|
-
|
|
480
|
-
const response = await marketplaceService.list({ page, pageSize })
|
|
481
|
-
const data = marketplaceAdapter.toMarketplaceList(response.data)
|
|
482
|
-
|
|
483
|
-
return NextResponse.json(data)
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
export async function POST(request: NextRequest) {
|
|
487
|
-
const body = await request.json()
|
|
488
|
-
const response = await marketplaceService.create(body)
|
|
489
|
-
const item = marketplaceAdapter.toMarketplaceItem(response.data)
|
|
490
|
-
|
|
491
|
-
return NextResponse.json(item, { status: 201 })
|
|
492
|
-
}
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
**Route Handler Rules:**
|
|
496
|
-
- YES use for external APIs, webhooks, third-party callbacks
|
|
497
|
-
- YES use service + adapter layers
|
|
498
|
-
- YES proper HTTP status codes
|
|
499
|
-
- NO use for internal app mutations (use Server Actions instead)
|
|
500
|
-
- NO business logic (service/adapter handle that)
|
|
501
|
-
|
|
502
|
-
---
|
|
503
|
-
|
|
504
|
-
## 5. Server Components vs Client Components
|
|
505
|
-
|
|
506
|
-
### 5.1 Decision Tree
|
|
507
|
-
|
|
508
|
-
```
|
|
509
|
-
Does the component need...
|
|
510
|
-
├── useState, useEffect, useRef, event handlers (onClick, onChange)?
|
|
511
|
-
│ └── YES -> Client Component ('use client')
|
|
512
|
-
│
|
|
513
|
-
├── React Query (useQuery, useMutation)?
|
|
514
|
-
│ └── YES -> Client Component ('use client')
|
|
515
|
-
│
|
|
516
|
-
├── Zustand store (useXxxStore)?
|
|
517
|
-
│ └── YES -> Client Component ('use client')
|
|
518
|
-
│
|
|
519
|
-
├── Browser APIs (window, document, localStorage)?
|
|
520
|
-
│ └── YES -> Client Component ('use client')
|
|
521
|
-
│
|
|
522
|
-
├── Only fetching data and rendering?
|
|
523
|
-
│ └── YES -> Server Component (default, no directive)
|
|
524
|
-
│
|
|
525
|
-
└── Only composing other components with no interactivity?
|
|
526
|
-
└── YES -> Server Component (default, no directive)
|
|
527
|
-
```
|
|
528
|
-
|
|
529
|
-
### 5.2 Server Component Pattern (Default)
|
|
530
|
-
|
|
531
|
-
Server Components are the default in Next.js App Router. They run only on the server and can be async.
|
|
532
|
-
|
|
533
|
-
```tsx
|
|
534
|
-
// app/marketplace/page.tsx (Server Component -- NO directive needed)
|
|
535
|
-
import { marketplaceService } from '@/modules/marketplace/services/marketplace-service'
|
|
536
|
-
import { marketplaceAdapter } from '@/modules/marketplace/adapters/marketplace-adapter'
|
|
537
|
-
import { MarketplaceList } from '@/modules/marketplace/components/MarketplaceList'
|
|
538
|
-
|
|
539
|
-
export default async function MarketplacePage() {
|
|
540
|
-
const response = await marketplaceService.list({ page: 1, pageSize: 20 })
|
|
541
|
-
const data = marketplaceAdapter.toMarketplaceList(response.data)
|
|
542
|
-
|
|
543
|
-
return (
|
|
544
|
-
<main>
|
|
545
|
-
<h1>Marketplace</h1>
|
|
546
|
-
<MarketplaceList initialData={data} />
|
|
547
|
-
</main>
|
|
548
|
-
)
|
|
549
|
-
}
|
|
550
|
-
```
|
|
551
|
-
|
|
552
|
-
**Server Component Rules:**
|
|
553
|
-
- NO `'use client'` directive
|
|
554
|
-
- NO hooks (useState, useEffect, useRef, useContext)
|
|
555
|
-
- NO event handlers (onClick, onChange, onSubmit)
|
|
556
|
-
- NO browser APIs (window, document, localStorage)
|
|
557
|
-
- YES async/await directly in the component
|
|
558
|
-
- YES direct service calls for data fetching
|
|
559
|
-
- YES importing Client Components (they render on client)
|
|
560
|
-
- YES passing serializable props to Client Components
|
|
561
|
-
|
|
562
|
-
### 5.3 Client Component Pattern
|
|
563
|
-
|
|
564
|
-
Client Components opt into client-side rendering with the `'use client'` directive.
|
|
565
|
-
|
|
566
|
-
```tsx
|
|
567
|
-
// components/MarketplaceList.tsx
|
|
568
|
-
'use client'
|
|
569
|
-
|
|
570
|
-
import { useState } from 'react'
|
|
571
|
-
import { useMarketplaceList } from '../hooks/useMarketplaceList'
|
|
572
|
-
import { useMarketplaceStore } from '../stores/marketplace-store'
|
|
573
|
-
import { MarketplaceCard } from './MarketplaceCard'
|
|
574
|
-
import type { MarketplaceItem } from '../types/marketplace.contracts'
|
|
575
|
-
|
|
576
|
-
interface MarketplaceListProps {
|
|
577
|
-
initialData?: MarketplaceItem[]
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
export function MarketplaceList({ initialData }: MarketplaceListProps) {
|
|
581
|
-
const [page, setPage] = useState(1)
|
|
582
|
-
const { searchQuery } = useMarketplaceStore()
|
|
583
|
-
const { items, totalPages, isLoading, isEmpty } = useMarketplaceList({
|
|
584
|
-
page,
|
|
585
|
-
search: searchQuery,
|
|
586
|
-
})
|
|
587
|
-
|
|
588
|
-
const displayItems = items.length > 0 ? items : (initialData ?? [])
|
|
589
|
-
|
|
590
|
-
if (isLoading) return <div>Loading...</div>
|
|
591
|
-
if (isEmpty) return <div>No items found</div>
|
|
592
|
-
|
|
593
|
-
return (
|
|
594
|
-
<div>
|
|
595
|
-
{displayItems.map((item) => (
|
|
596
|
-
<MarketplaceCard key={item.id} item={item} />
|
|
597
|
-
))}
|
|
598
|
-
<Pagination
|
|
599
|
-
currentPage={page}
|
|
600
|
-
totalPages={totalPages}
|
|
601
|
-
onPageChange={setPage}
|
|
602
|
-
/>
|
|
603
|
-
</div>
|
|
604
|
-
)
|
|
605
|
-
}
|
|
606
|
-
```
|
|
607
|
-
|
|
608
|
-
**Client Component Rules:**
|
|
609
|
-
- YES `'use client'` directive at the top of the file
|
|
610
|
-
- YES hooks (useState, useEffect, useRef, custom hooks)
|
|
611
|
-
- YES event handlers (onClick, onChange, onSubmit)
|
|
612
|
-
- YES browser APIs
|
|
613
|
-
- NO async component functions
|
|
614
|
-
- NO direct service calls for initial data (use hooks or receive via props)
|
|
615
|
-
|
|
616
|
-
### 5.4 Composition Pattern -- Server + Client
|
|
617
|
-
|
|
618
|
-
```tsx
|
|
619
|
-
// app/marketplace/page.tsx (Server Component)
|
|
620
|
-
import { marketplaceService } from '@/modules/marketplace/services/marketplace-service'
|
|
621
|
-
import { marketplaceAdapter } from '@/modules/marketplace/adapters/marketplace-adapter'
|
|
622
|
-
import { MarketplaceFilters } from '@/modules/marketplace/components/MarketplaceFilters'
|
|
623
|
-
import { MarketplaceList } from '@/modules/marketplace/components/MarketplaceList'
|
|
624
|
-
|
|
625
|
-
export default async function MarketplacePage() {
|
|
626
|
-
// Server-side data fetching
|
|
627
|
-
const response = await marketplaceService.list({ page: 1, pageSize: 20 })
|
|
628
|
-
const data = marketplaceAdapter.toMarketplaceList(response.data)
|
|
629
|
-
|
|
630
|
-
return (
|
|
631
|
-
<main>
|
|
632
|
-
<h1>Marketplace</h1>
|
|
633
|
-
{/* Client Component for interactivity */}
|
|
634
|
-
<MarketplaceFilters />
|
|
635
|
-
{/* Client Component with server-fetched initial data */}
|
|
636
|
-
<MarketplaceList initialData={data.items} />
|
|
637
|
-
</main>
|
|
638
|
-
)
|
|
639
|
-
}
|
|
640
|
-
```
|
|
641
|
-
|
|
642
|
-
### 5.5 Component Hierarchy
|
|
643
|
-
|
|
644
|
-
```
|
|
645
|
-
Pages (Server Components) -> Data fetching, composition, metadata
|
|
646
|
-
|-- Layouts (Server) -> Shared structure, navigation
|
|
647
|
-
|-- Feature Components -> Business logic (Client or Server)
|
|
648
|
-
|-- Shared -> Presentation (props in, callbacks out)
|
|
649
|
-
```
|
|
650
|
-
|
|
651
|
-
| Type | Responsibility | Server or Client? | Can have hooks? |
|
|
652
|
-
|------|---------------|-------------------|-----------------|
|
|
653
|
-
| **Pages** | Fetch data, compose components, metadata | Server (default) | No |
|
|
654
|
-
| **Layouts** | Shared structure, providers | Server (default) | No |
|
|
655
|
-
| **Feature Components** | Business logic + UI | Client (usually) | Yes |
|
|
656
|
-
| **Shared Components** | Generic, reusable UI | Either | If Client |
|
|
657
|
-
|
|
658
|
-
---
|
|
659
|
-
|
|
660
|
-
## 6. App Router Conventions
|
|
661
|
-
|
|
662
|
-
### 6.1 File Conventions
|
|
663
|
-
|
|
664
|
-
| File | Purpose | Server/Client |
|
|
665
|
-
|------|---------|---------------|
|
|
666
|
-
| `page.tsx` | Route UI | Server (default) |
|
|
667
|
-
| `layout.tsx` | Shared layout (persists across navigations) | Server (default) |
|
|
668
|
-
| `loading.tsx` | Loading skeleton (Suspense boundary) | Server |
|
|
669
|
-
| `error.tsx` | Error boundary | Client (`'use client'` required) |
|
|
670
|
-
| `not-found.tsx` | 404 page | Server |
|
|
671
|
-
| `route.ts` | API route handler | Server |
|
|
672
|
-
| `template.tsx` | Re-rendered layout (no state persistence) | Server |
|
|
673
|
-
| `default.tsx` | Parallel route fallback | Server |
|
|
674
|
-
|
|
675
|
-
### 6.2 Metadata
|
|
676
|
-
|
|
677
|
-
```tsx
|
|
678
|
-
// Static metadata
|
|
679
|
-
export const metadata = {
|
|
680
|
-
title: 'Marketplace',
|
|
681
|
-
description: 'Browse our marketplace',
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
// Dynamic metadata
|
|
685
|
-
export async function generateMetadata({ params }: Props) {
|
|
686
|
-
const item = await getItem(params.id)
|
|
687
|
-
return {
|
|
688
|
-
title: item.name,
|
|
689
|
-
description: item.description,
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
```
|
|
693
|
-
|
|
694
|
-
### 6.3 Loading & Error Patterns
|
|
695
|
-
|
|
696
|
-
```tsx
|
|
697
|
-
// app/marketplace/loading.tsx (Server Component)
|
|
698
|
-
export default function MarketplaceLoading() {
|
|
699
|
-
return (
|
|
700
|
-
<div className="animate-pulse">
|
|
701
|
-
<div className="h-8 bg-gray-200 rounded w-1/4 mb-4" />
|
|
702
|
-
<div className="grid grid-cols-3 gap-4">
|
|
703
|
-
{Array.from({ length: 6 }).map((_, i) => (
|
|
704
|
-
<div key={i} className="h-48 bg-gray-200 rounded" />
|
|
705
|
-
))}
|
|
706
|
-
</div>
|
|
707
|
-
</div>
|
|
708
|
-
)
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
// app/marketplace/error.tsx (Client Component -- REQUIRED)
|
|
712
|
-
'use client'
|
|
713
|
-
|
|
714
|
-
interface ErrorProps {
|
|
715
|
-
error: Error & { digest?: string }
|
|
716
|
-
reset: () => void
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
export default function MarketplaceError({ error, reset }: ErrorProps) {
|
|
720
|
-
return (
|
|
721
|
-
<div>
|
|
722
|
-
<h2>Something went wrong</h2>
|
|
723
|
-
<p>{error.message}</p>
|
|
724
|
-
<button onClick={reset}>Try again</button>
|
|
725
|
-
</div>
|
|
726
|
-
)
|
|
727
|
-
}
|
|
728
|
-
```
|
|
729
|
-
|
|
730
|
-
### 6.4 Dynamic Routes
|
|
731
|
-
|
|
732
|
-
```tsx
|
|
733
|
-
// app/marketplace/[id]/page.tsx
|
|
734
|
-
interface PageProps {
|
|
735
|
-
params: Promise<{ id: string }>
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
export default async function MarketplaceDetailPage({ params }: PageProps) {
|
|
739
|
-
const { id } = await params
|
|
740
|
-
const response = await marketplaceService.getById(id)
|
|
741
|
-
const item = marketplaceAdapter.toMarketplaceItem(response.data)
|
|
742
|
-
|
|
743
|
-
return <MarketplaceDetail item={item} />
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
// Generate static params for SSG
|
|
747
|
-
export async function generateStaticParams() {
|
|
748
|
-
const response = await marketplaceService.list({ page: 1, pageSize: 100 })
|
|
749
|
-
return response.data.results.map((item) => ({
|
|
750
|
-
id: item.uuid,
|
|
751
|
-
}))
|
|
752
|
-
}
|
|
753
|
-
```
|
|
754
|
-
|
|
755
|
-
---
|
|
756
|
-
|
|
757
|
-
## 7. Utils vs Helpers
|
|
758
|
-
|
|
759
|
-
### Utils -- Pure Functions
|
|
760
|
-
- No side effects
|
|
761
|
-
- Input -> Output deterministic
|
|
762
|
-
- Testable without mocks
|
|
763
|
-
- No dependency on DOM, browser APIs, or React
|
|
764
|
-
|
|
765
|
-
```typescript
|
|
766
|
-
// shared/utils/format-date.ts
|
|
767
|
-
export function formatDate(date: Date, locale = 'en-US'): string {
|
|
768
|
-
return new Intl.DateTimeFormat(locale).format(date)
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
// shared/utils/currency.ts
|
|
772
|
-
export function formatCurrency(value: number, currency = 'USD'): string {
|
|
773
|
-
return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(value)
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
// shared/utils/string.ts
|
|
777
|
-
export function slugify(text: string): string {
|
|
778
|
-
return text.toLowerCase().replace(/\s+/g, '-').replace(/[^\w-]/g, '')
|
|
779
|
-
}
|
|
780
|
-
```
|
|
781
|
-
|
|
782
|
-
### Helpers -- Functions with Side Effects or DOM
|
|
783
|
-
- Interact with browser APIs (clipboard, localStorage, DOM)
|
|
784
|
-
- May have side effects
|
|
785
|
-
- May need mocks in tests
|
|
786
|
-
|
|
787
|
-
```typescript
|
|
788
|
-
// shared/helpers/clipboard-helper.ts
|
|
789
|
-
export async function copyToClipboard(text: string): Promise<boolean> {
|
|
790
|
-
try {
|
|
791
|
-
await navigator.clipboard.writeText(text)
|
|
792
|
-
return true
|
|
793
|
-
} catch {
|
|
794
|
-
return false
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
// shared/helpers/storage-helper.ts
|
|
799
|
-
export function getFromStorage<T>(key: string, fallback: T): T {
|
|
800
|
-
if (typeof window === 'undefined') return fallback
|
|
801
|
-
try {
|
|
802
|
-
const value = localStorage.getItem(key)
|
|
803
|
-
return value ? (JSON.parse(value) as T) : fallback
|
|
804
|
-
} catch {
|
|
805
|
-
return fallback
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
// shared/helpers/download-helper.ts
|
|
810
|
-
export function downloadAsFile(content: string, filename: string): void {
|
|
811
|
-
const blob = new Blob([content], { type: 'text/plain' })
|
|
812
|
-
const url = URL.createObjectURL(blob)
|
|
813
|
-
const a = document.createElement('a')
|
|
814
|
-
a.href = url
|
|
815
|
-
a.download = filename
|
|
816
|
-
a.click()
|
|
817
|
-
URL.revokeObjectURL(url)
|
|
818
|
-
}
|
|
819
|
-
```
|
|
820
|
-
|
|
821
|
-
---
|
|
822
|
-
|
|
823
|
-
## 8. Error Handling -- Centralized Pattern
|
|
824
|
-
|
|
825
|
-
### In the Hook Layer (React Query)
|
|
826
|
-
|
|
827
|
-
```typescript
|
|
828
|
-
// Error handling stays in onError of mutations
|
|
829
|
-
const { mutate: deleteItem } = useMutation({
|
|
830
|
-
mutationFn: (id: string) => marketplaceService.delete(id),
|
|
831
|
-
onSuccess: () => {
|
|
832
|
-
queryClient.invalidateQueries({ queryKey: ['marketplace'] })
|
|
833
|
-
toast.success('Item removed successfully')
|
|
834
|
-
},
|
|
835
|
-
onError: (error) => {
|
|
836
|
-
toast.error(parseApiError(error))
|
|
837
|
-
},
|
|
838
|
-
})
|
|
839
|
-
```
|
|
840
|
-
|
|
841
|
-
### In Server Actions
|
|
842
|
-
|
|
843
|
-
```typescript
|
|
844
|
-
// actions/marketplace-actions.ts
|
|
845
|
-
'use server'
|
|
846
|
-
|
|
847
|
-
import { parseApiError } from '@/shared/utils/parse-api-error'
|
|
848
|
-
|
|
849
|
-
export async function createMarketplaceItem(input: CreateMarketplaceInput) {
|
|
850
|
-
try {
|
|
851
|
-
const payload = marketplaceAdapter.toCreatePayload(input)
|
|
852
|
-
const response = await marketplaceService.create(payload)
|
|
853
|
-
const item = marketplaceAdapter.toMarketplaceItem(response.data)
|
|
854
|
-
revalidatePath('/marketplace')
|
|
855
|
-
return { success: true, data: item }
|
|
856
|
-
} catch (error) {
|
|
857
|
-
return { success: false, error: parseApiError(error) }
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
```
|
|
861
|
-
|
|
862
|
-
### Centralized Error Parser
|
|
863
|
-
|
|
864
|
-
```typescript
|
|
865
|
-
// shared/utils/parse-api-error.ts
|
|
866
|
-
import type { AxiosError } from 'axios'
|
|
867
|
-
|
|
868
|
-
interface ApiErrorResponse {
|
|
869
|
-
message?: string
|
|
870
|
-
detail?: string
|
|
871
|
-
errors?: Record<string, string[]>
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
export function parseApiError(error: unknown): string {
|
|
875
|
-
if (error instanceof AxiosError) {
|
|
876
|
-
const data = error.response?.data as ApiErrorResponse | undefined
|
|
877
|
-
if (data?.message) return data.message
|
|
878
|
-
if (data?.detail) return data.detail
|
|
879
|
-
if (error.response?.status === 403) return 'Permission denied'
|
|
880
|
-
if (error.response?.status === 404) return 'Resource not found'
|
|
881
|
-
if (error.response?.status === 500) return 'Internal server error'
|
|
882
|
-
}
|
|
883
|
-
return 'Unexpected error. Please try again.'
|
|
884
|
-
}
|
|
885
|
-
```
|
|
886
|
-
|
|
887
|
-
### Global Error Boundary (App Router)
|
|
888
|
-
|
|
889
|
-
```tsx
|
|
890
|
-
// app/error.tsx
|
|
891
|
-
'use client'
|
|
892
|
-
|
|
893
|
-
export default function GlobalError({
|
|
894
|
-
error,
|
|
895
|
-
reset,
|
|
896
|
-
}: {
|
|
897
|
-
error: Error & { digest?: string }
|
|
898
|
-
reset: () => void
|
|
899
|
-
}) {
|
|
900
|
-
return (
|
|
901
|
-
<div>
|
|
902
|
-
<h2>Something went wrong</h2>
|
|
903
|
-
<button onClick={reset}>Try again</button>
|
|
904
|
-
</div>
|
|
905
|
-
)
|
|
906
|
-
}
|
|
907
|
-
```
|
|
908
|
-
|
|
909
|
-
### API Client with Interceptor
|
|
910
|
-
|
|
911
|
-
```typescript
|
|
912
|
-
// shared/services/api-client.ts
|
|
913
|
-
import axios from 'axios'
|
|
914
|
-
|
|
915
|
-
export const api = axios.create({
|
|
916
|
-
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL,
|
|
917
|
-
})
|
|
918
|
-
|
|
919
|
-
api.interceptors.response.use(
|
|
920
|
-
(response) => response,
|
|
921
|
-
(error) => {
|
|
922
|
-
// Only log and redirect on 401 (session expired)
|
|
923
|
-
if (error.response?.status === 401) {
|
|
924
|
-
if (typeof window !== 'undefined') {
|
|
925
|
-
window.location.href = '/login'
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
// DO NOT handle other errors here -- let the caller handle them
|
|
929
|
-
return Promise.reject(error)
|
|
930
|
-
},
|
|
931
|
-
)
|
|
932
|
-
```
|
|
933
|
-
|
|
934
|
-
---
|
|
935
|
-
|
|
936
|
-
## 9. Barrel Exports (index.ts)
|
|
937
|
-
|
|
938
|
-
Each module exports only its **public API**:
|
|
939
|
-
|
|
940
|
-
```typescript
|
|
941
|
-
// modules/marketplace/index.ts
|
|
942
|
-
|
|
943
|
-
// Components (for use in pages)
|
|
944
|
-
export { MarketplaceList } from './components/MarketplaceList'
|
|
945
|
-
export { MarketplaceCard } from './components/MarketplaceCard'
|
|
946
|
-
|
|
947
|
-
// Hooks (for client-side usage)
|
|
948
|
-
export { useMarketplaceList } from './hooks/useMarketplaceList'
|
|
949
|
-
|
|
950
|
-
// Actions (for server-side mutations)
|
|
951
|
-
export { createMarketplaceItem, deleteMarketplaceItem } from './actions/marketplace-actions'
|
|
952
|
-
|
|
953
|
-
// Types (for consumers that need typing)
|
|
954
|
-
export type { MarketplaceItem, MarketplaceList as MarketplaceListType } from './types/marketplace.contracts'
|
|
955
|
-
|
|
956
|
-
// DO NOT export:
|
|
957
|
-
// - services (internal detail)
|
|
958
|
-
// - adapters (internal detail)
|
|
959
|
-
// - stores (use via hooks)
|
|
960
|
-
// - internal hooks
|
|
961
|
-
```
|
|
962
|
-
|
|
963
|
-
---
|
|
964
|
-
|
|
965
|
-
## 10. SOLID Principles Applied to Next.js
|
|
966
|
-
|
|
967
|
-
| Principle | Application in Next.js |
|
|
968
|
-
|-----------|----------------------|
|
|
969
|
-
| **S**ingle Responsibility | 1 component = 1 responsibility. 1 hook = 1 domain. 1 service = 1 resource. Server Components fetch, Client Components interact. |
|
|
970
|
-
| **O**pen/Closed | Components extensible via props and children, not by internal modification. Use composition over inheritance. |
|
|
971
|
-
| **L**iskov Substitution | Shared components must work in any context without breaking. Server and Client components interchangeable where directives allow. |
|
|
972
|
-
| **I**nterface Segregation | Specific props, not generic objects. `<UserAvatar src={src} alt={alt} />` not `<UserAvatar user={user} />`. |
|
|
973
|
-
| **D**ependency Inversion | Hooks depend on interfaces (types), not implementations. Services injected via hooks/actions, not imported directly in components. |
|
|
974
|
-
|
|
975
|
-
---
|
|
976
|
-
|
|
977
|
-
## 11. Migration Checklist Per File
|
|
978
|
-
|
|
979
|
-
### Page / Layout (App Router)
|
|
980
|
-
- [ ] Server Component by default (no `'use client'`)
|
|
981
|
-
- [ ] Async if fetching data
|
|
982
|
-
- [ ] `metadata` or `generateMetadata()` for SEO
|
|
983
|
-
- [ ] Proper `loading.tsx` sibling
|
|
984
|
-
- [ ] Proper `error.tsx` sibling (`'use client'`)
|
|
985
|
-
- [ ] Uses service + adapter for data fetching
|
|
986
|
-
- [ ] Passes serializable props to Client Components
|
|
987
|
-
|
|
988
|
-
### Client Component (.tsx)
|
|
989
|
-
- [ ] `'use client'` directive at the top
|
|
990
|
-
- [ ] Typed props interface
|
|
991
|
-
- [ ] < 200 lines total
|
|
992
|
-
- [ ] JSX < 100 lines
|
|
993
|
-
- [ ] No business logic in JSX
|
|
994
|
-
- [ ] Loading / error / empty states handled
|
|
995
|
-
- [ ] No `dangerouslySetInnerHTML` or with sanitization
|
|
996
|
-
|
|
997
|
-
### Hook
|
|
998
|
-
- [ ] Prefix `use`
|
|
999
|
-
- [ ] Typed return value
|
|
1000
|
-
- [ ] Uses service + adapter (never direct API)
|
|
1001
|
-
- [ ] TanStack React Query for server state
|
|
1002
|
-
- [ ] Error handling via onError in query/mutation
|
|
1003
|
-
- [ ] `staleTime` always set
|
|
1004
|
-
|
|
1005
|
-
### Server Action
|
|
1006
|
-
- [ ] `'use server'` directive
|
|
1007
|
-
- [ ] Uses service + adapter
|
|
1008
|
-
- [ ] `revalidatePath()` or `revalidateTag()` after mutations
|
|
1009
|
-
- [ ] Returns serializable data (no Date, no functions)
|
|
1010
|
-
- [ ] Error handling with try/catch returning `{ success, error }`
|
|
1011
|
-
|
|
1012
|
-
### Service
|
|
1013
|
-
- [ ] HTTP calls only
|
|
1014
|
-
- [ ] No try/catch
|
|
1015
|
-
- [ ] No data transformation
|
|
1016
|
-
- [ ] Typed request and response
|
|
1017
|
-
|
|
1018
|
-
### Adapter
|
|
1019
|
-
- [ ] Pure functions
|
|
1020
|
-
- [ ] Inbound (API->App) and Outbound (App->API)
|
|
1021
|
-
- [ ] Naming conversion (snake_case -> camelCase)
|
|
1022
|
-
- [ ] Type conversion (string->Date, etc.)
|
|
1023
|
-
|
|
1024
|
-
### Zustand Store
|
|
1025
|
-
- [ ] Client state only
|
|
1026
|
-
- [ ] `create<T>()` syntax
|
|
1027
|
-
- [ ] Selectors for granular subscriptions
|
|
1028
|
-
- [ ] Actions co-located with state
|
|
1029
|
-
|
|
1030
|
-
### Types
|
|
1031
|
-
- [ ] `.types.ts` for API types (raw response)
|
|
1032
|
-
- [ ] `.contracts.ts` for application contracts
|
|
1033
|
-
- [ ] No `any`
|