create-tigra 1.1.0 → 2.0.1
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 +21 -21
- package/README.md +80 -87
- package/bin/create-tigra.js +259 -308
- package/package.json +49 -41
- package/template/_claude/QUICK_REFERENCE.md +193 -0
- package/template/_claude/README.md +53 -0
- package/template/_claude/commands/create-client.md +881 -0
- package/template/_claude/commands/create-server.md +383 -0
- package/template/_claude/rules/client/01-project-structure.md +133 -0
- package/template/_claude/rules/client/02-components-and-types.md +146 -0
- package/template/_claude/rules/client/03-data-and-state.md +156 -0
- package/template/_claude/rules/client/04-design-system.md +185 -0
- package/template/_claude/rules/client/05-security.md +55 -0
- package/template/_claude/rules/client/06-ux-checklist.md +81 -0
- package/template/_claude/rules/client/core.md +42 -0
- package/template/_claude/rules/global/core.md +77 -0
- package/template/_claude/rules/server/core.md +50 -0
- package/template/_claude/rules/server/database.md +124 -0
- package/template/_claude/rules/server/project-conventions.md +150 -0
- package/template/_claude/rules/server/response-handling.md +144 -0
- package/template/client/.env.example +5 -0
- package/template/client/README.md +36 -0
- package/template/client/components.json +23 -0
- package/template/client/eslint.config.mjs +18 -0
- package/template/client/next.config.ts +34 -0
- package/template/client/package.json +44 -0
- package/template/client/postcss.config.mjs +7 -0
- package/template/client/src/app/(auth)/layout.tsx +18 -0
- package/template/client/src/app/(auth)/login/page.tsx +13 -0
- package/template/client/src/app/(auth)/register/page.tsx +13 -0
- package/template/client/src/app/(main)/dashboard/page.tsx +22 -0
- package/template/client/src/app/(main)/layout.tsx +11 -0
- package/template/client/src/app/error.tsx +27 -0
- package/template/client/src/app/favicon.ico +0 -0
- package/template/client/src/app/globals.css +145 -0
- package/template/client/src/app/layout.tsx +36 -0
- package/template/client/src/app/loading.tsx +11 -0
- package/template/client/src/app/not-found.tsx +23 -0
- package/template/client/src/app/page.tsx +45 -0
- package/template/client/src/app/providers.tsx +43 -0
- package/template/client/src/components/common/ConfirmDialog.tsx +56 -0
- package/template/client/src/components/common/EmptyState.tsx +31 -0
- package/template/client/src/components/common/LoadingSpinner.tsx +30 -0
- package/template/client/src/components/common/Pagination.tsx +55 -0
- package/template/client/src/components/layout/Footer.tsx +17 -0
- package/template/client/src/components/layout/Header.tsx +173 -0
- package/template/client/src/components/layout/MainLayout.tsx +18 -0
- package/template/client/src/components/ui/alert-dialog.tsx +196 -0
- package/template/client/src/components/ui/badge.tsx +48 -0
- package/template/client/src/components/ui/button.tsx +64 -0
- package/template/client/src/components/ui/card.tsx +92 -0
- package/template/client/src/components/ui/input.tsx +21 -0
- package/template/client/src/components/ui/label.tsx +24 -0
- package/template/client/src/components/ui/select.tsx +190 -0
- package/template/client/src/components/ui/skeleton.tsx +13 -0
- package/template/client/src/components/ui/table.tsx +116 -0
- package/template/client/src/features/auth/components/AuthInitializer.tsx +55 -0
- package/template/client/src/features/auth/components/LoginForm.tsx +107 -0
- package/template/client/src/features/auth/components/RegisterForm.tsx +178 -0
- package/template/client/src/features/auth/hooks/useAuth.ts +84 -0
- package/template/client/src/features/auth/services/auth.service.ts +52 -0
- package/template/client/src/features/auth/store/authSlice.ts +38 -0
- package/template/client/src/features/auth/types/auth.types.ts +32 -0
- package/template/client/src/hooks/useDebounce.ts +14 -0
- package/template/client/src/hooks/useLocalStorage.ts +55 -0
- package/template/client/src/hooks/useMediaQuery.ts +27 -0
- package/template/client/src/lib/api/api.types.ts +34 -0
- package/template/client/src/lib/api/axios.config.ts +98 -0
- package/template/client/src/lib/constants/api-endpoints.ts +18 -0
- package/template/client/src/lib/constants/app.constants.ts +12 -0
- package/template/client/src/lib/constants/routes.ts +9 -0
- package/template/client/src/lib/utils/error.ts +32 -0
- package/template/client/src/lib/utils/format.ts +37 -0
- package/template/client/src/lib/utils/security.ts +34 -0
- package/template/client/src/lib/utils.ts +6 -0
- package/template/client/src/middleware.ts +57 -0
- package/template/client/src/store/hooks.ts +7 -0
- package/template/client/src/store/index.ts +12 -0
- package/template/client/src/types/index.ts +3 -0
- package/template/client/tsconfig.json +34 -0
- package/template/gitignore +34 -0
- package/template/server/.dockerignore +66 -0
- package/template/server/.env.example +96 -69
- package/template/server/.env.production.example +90 -0
- package/template/server/Dockerfile +94 -0
- package/template/server/docker-compose.yml +82 -111
- package/template/server/docs/logging.md +62 -0
- package/template/server/eslint.config.mjs +17 -0
- package/template/server/package.json +68 -81
- package/template/server/phpmyadmin-config.php +26 -0
- package/template/server/postman_collection.json +666 -0
- package/template/server/prisma/schema.prisma +77 -93
- package/template/server/prisma/seed.ts +46 -142
- package/template/server/scripts/flush-redis.ts +41 -0
- package/template/server/src/app.ts +243 -71
- package/template/server/src/config/env.ts +67 -94
- package/template/server/src/libs/auth.ts +88 -0
- package/template/server/src/libs/cleanup.ts +35 -0
- package/template/server/src/libs/cookies.ts +46 -0
- package/template/server/src/libs/logger.ts +33 -60
- package/template/server/src/libs/monitoring.ts +205 -0
- package/template/server/src/libs/password.ts +38 -0
- package/template/server/src/libs/prisma.ts +68 -0
- package/template/server/src/libs/redis.ts +60 -79
- package/template/server/src/libs/requestLogger.ts +66 -0
- package/template/server/src/libs/storage/file-storage.service.ts +211 -0
- package/template/server/src/libs/storage/file-validator.ts +97 -0
- package/template/server/src/libs/storage/filename-sanitizer.ts +71 -0
- package/template/server/src/libs/storage/image-optimizer.service.ts +144 -0
- package/template/server/src/modules/auth/__tests__/auth.service.test.ts +365 -0
- package/template/server/src/modules/auth/auth.controller.ts +90 -141
- package/template/server/src/modules/auth/auth.repo.ts +120 -218
- package/template/server/src/modules/auth/auth.routes.ts +96 -83
- package/template/server/src/modules/auth/auth.schemas.ts +35 -137
- package/template/server/src/modules/auth/auth.service.ts +286 -329
- package/template/server/src/modules/auth/session.repo.ts +110 -0
- package/template/server/src/modules/users/users.controller.ts +120 -0
- package/template/server/src/modules/users/users.repo.ts +77 -0
- package/template/server/src/modules/users/users.routes.ts +89 -0
- package/template/server/src/modules/users/users.schemas.ts +21 -0
- package/template/server/src/modules/users/users.service.ts +169 -0
- package/template/server/src/server.ts +58 -139
- package/template/server/src/shared/errors/AppError.ts +21 -0
- package/template/server/src/shared/errors/errors.ts +43 -0
- package/template/server/src/shared/responses/paginatedResponse.ts +38 -0
- package/template/server/src/shared/responses/successResponse.ts +17 -0
- package/template/server/src/shared/schemas/pagination.schema.ts +12 -0
- package/template/server/src/shared/types/index.ts +26 -0
- package/template/server/src/test/setup.ts +74 -38
- package/template/server/tsconfig.json +27 -89
- package/template/server/uploads/avatars/.gitkeep +1 -0
- package/template/server/vitest.config.ts +43 -98
- package/template/.agent/rules/client/01-project-structure.md +0 -326
- package/template/.agent/rules/client/02-component-patterns.md +0 -249
- package/template/.agent/rules/client/03-typescript-rules.md +0 -226
- package/template/.agent/rules/client/04-state-management.md +0 -474
- package/template/.agent/rules/client/05-api-integration.md +0 -129
- package/template/.agent/rules/client/06-forms-validation.md +0 -129
- package/template/.agent/rules/client/07-common-patterns.md +0 -150
- package/template/.agent/rules/client/08-color-system.md +0 -93
- package/template/.agent/rules/client/09-security-rules.md +0 -97
- package/template/.agent/rules/client/10-testing-strategy.md +0 -370
- package/template/.agent/rules/global/ai-edit-safety.md +0 -38
- package/template/.agent/rules/server/01-db-and-migrations.md +0 -242
- package/template/.agent/rules/server/02-general-rules.md +0 -111
- package/template/.agent/rules/server/03-migrations.md +0 -20
- package/template/.agent/rules/server/04-pagination.md +0 -130
- package/template/.agent/rules/server/05-project-conventions.md +0 -71
- package/template/.agent/rules/server/06-response-handling.md +0 -173
- package/template/.agent/rules/server/07-testing-strategy.md +0 -506
- package/template/.agent/rules/server/08-observability.md +0 -180
- package/template/.agent/rules/server/10-background-jobs-v2.md +0 -185
- package/template/.agent/rules/server/11-rate-limiting-v2.md +0 -210
- package/template/.agent/rules/server/12-performance-optimization.md +0 -567
- package/template/.claude/rules/client-01-project-structure.md +0 -327
- package/template/.claude/rules/client-02-component-patterns.md +0 -250
- package/template/.claude/rules/client-03-typescript-rules.md +0 -227
- package/template/.claude/rules/client-04-state-management.md +0 -475
- package/template/.claude/rules/client-05-api-integration.md +0 -130
- package/template/.claude/rules/client-06-forms-validation.md +0 -130
- package/template/.claude/rules/client-07-common-patterns.md +0 -151
- package/template/.claude/rules/client-08-color-system.md +0 -94
- package/template/.claude/rules/client-09-security-rules.md +0 -98
- package/template/.claude/rules/client-10-testing-strategy.md +0 -371
- package/template/.claude/rules/global-ai-edit-safety.md +0 -39
- package/template/.claude/rules/server-01-db-and-migrations.md +0 -243
- package/template/.claude/rules/server-02-general-rules.md +0 -112
- package/template/.claude/rules/server-03-migrations.md +0 -21
- package/template/.claude/rules/server-04-pagination.md +0 -131
- package/template/.claude/rules/server-05-project-conventions.md +0 -72
- package/template/.claude/rules/server-06-response-handling.md +0 -174
- package/template/.claude/rules/server-07-testing-strategy.md +0 -507
- package/template/.claude/rules/server-08-observability.md +0 -181
- package/template/.claude/rules/server-10-background-jobs-v2.md +0 -186
- package/template/.claude/rules/server-11-rate-limiting-v2.md +0 -211
- package/template/.claude/rules/server-12-performance-optimization.md +0 -568
- package/template/.cursor/rules/client-01-project-structure.mdc +0 -327
- package/template/.cursor/rules/client-02-component-patterns.mdc +0 -250
- package/template/.cursor/rules/client-03-typescript-rules.mdc +0 -227
- package/template/.cursor/rules/client-04-state-management.mdc +0 -475
- package/template/.cursor/rules/client-05-api-integration.mdc +0 -130
- package/template/.cursor/rules/client-06-forms-validation.mdc +0 -130
- package/template/.cursor/rules/client-07-common-patterns.mdc +0 -151
- package/template/.cursor/rules/client-08-color-system.mdc +0 -94
- package/template/.cursor/rules/client-09-security-rules.mdc +0 -98
- package/template/.cursor/rules/client-10-testing-strategy.mdc +0 -371
- package/template/.cursor/rules/global-ai-edit-safety.mdc +0 -39
- package/template/.cursor/rules/server-01-db-and-migrations.mdc +0 -243
- package/template/.cursor/rules/server-02-general-rules.mdc +0 -112
- package/template/.cursor/rules/server-03-migrations.mdc +0 -21
- package/template/.cursor/rules/server-04-pagination.mdc +0 -131
- package/template/.cursor/rules/server-05-project-conventions.mdc +0 -72
- package/template/.cursor/rules/server-06-response-handling.mdc +0 -174
- package/template/.cursor/rules/server-07-testing-strategy.mdc +0 -507
- package/template/.cursor/rules/server-08-observability.mdc +0 -181
- package/template/.cursor/rules/server-09-api-documentation-v2.mdc +0 -169
- package/template/.cursor/rules/server-10-background-jobs-v2.mdc +0 -186
- package/template/.cursor/rules/server-11-rate-limiting-v2.mdc +0 -211
- package/template/.cursor/rules/server-12-performance-optimization.mdc +0 -568
- package/template/CLAUDE.md +0 -207
- package/template/server/.tsc-aliasrc.json +0 -13
- package/template/server/IMPORT_FIX_CHECKLIST.md +0 -98
- package/template/server/IMPORT_FIX_COMPLETE.md +0 -89
- package/template/server/README.md +0 -183
- package/template/server/REMAINING_IMPORT_FIXES.md +0 -150
- package/template/server/SECURITY.md +0 -190
- package/template/server/Tigra-API.postman_collection.json +0 -733
- package/template/server/biome.json +0 -42
- package/template/server/scripts/fix-all-imports.ps1 +0 -52
- package/template/server/scripts/fix-imports-reference.ps1 +0 -16
- package/template/server/scripts/fix-imports.mjs +0 -55
- package/template/server/scripts/setup-env.js +0 -50
- package/template/server/scripts/wait-for-db.js +0 -60
- package/template/server/src/hooks/request-timing.hook.ts +0 -26
- package/template/server/src/libs/auth/authenticate.middleware.ts +0 -22
- package/template/server/src/libs/auth/rbac.middleware.test.ts +0 -134
- package/template/server/src/libs/auth/rbac.middleware.ts +0 -147
- package/template/server/src/libs/db.ts +0 -76
- package/template/server/src/libs/error-handler.ts +0 -89
- package/template/server/src/libs/queue.ts +0 -79
- package/template/server/src/modules/admin/admin.controller.ts +0 -122
- package/template/server/src/modules/admin/admin.routes.ts +0 -62
- package/template/server/src/modules/admin/admin.schemas.ts +0 -35
- package/template/server/src/modules/admin/admin.service.ts +0 -167
- package/template/server/src/modules/auth/auth.integration.test.ts +0 -150
- package/template/server/src/modules/auth/auth.service.test.ts +0 -119
- package/template/server/src/modules/auth/auth.types.ts +0 -97
- package/template/server/src/modules/resources/resources.controller.ts +0 -218
- package/template/server/src/modules/resources/resources.repo.ts +0 -253
- package/template/server/src/modules/resources/resources.routes.ts +0 -116
- package/template/server/src/modules/resources/resources.schemas.ts +0 -146
- package/template/server/src/modules/resources/resources.service.ts +0 -218
- package/template/server/src/modules/resources/resources.types.ts +0 -73
- package/template/server/src/plugins/rate-limit.plugin.ts +0 -21
- package/template/server/src/plugins/security.plugin.ts +0 -21
- package/template/server/src/routes/health.routes.ts +0 -31
- package/template/server/src/types/fastify.d.ts +0 -36
- package/template/server/src/utils/errors.ts +0 -108
- package/template/server/src/utils/pagination.ts +0 -120
- package/template/server/src/utils/response.ts +0 -110
- package/template/server/src/workers/file.worker.ts +0 -106
- package/template/server/tsconfig.build.json +0 -30
- package/template/server/tsconfig.test.json +0 -22
package/package.json
CHANGED
|
@@ -1,41 +1,49 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "create-tigra",
|
|
3
|
-
"version": "
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "Create a production-ready
|
|
6
|
-
"
|
|
7
|
-
"create"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
}
|
|
41
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "create-tigra",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Create a production-ready full-stack app with Next.js 16 + Fastify 5 + Prisma + Redis",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-tigra": "bin/create-tigra.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"template"
|
|
12
|
+
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=18.0.0"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"create",
|
|
18
|
+
"generator",
|
|
19
|
+
"scaffold",
|
|
20
|
+
"fullstack",
|
|
21
|
+
"nextjs",
|
|
22
|
+
"fastify",
|
|
23
|
+
"typescript",
|
|
24
|
+
"prisma",
|
|
25
|
+
"redis",
|
|
26
|
+
"boilerplate",
|
|
27
|
+
"starter",
|
|
28
|
+
"react",
|
|
29
|
+
"tailwind",
|
|
30
|
+
"shadcn"
|
|
31
|
+
],
|
|
32
|
+
"author": "seed977",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/blessandsoul/create-tigra.git"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/blessandsoul/create-tigra/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/blessandsoul/create-tigra#readme",
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"chalk": "^5.4.1",
|
|
44
|
+
"commander": "^13.1.0",
|
|
45
|
+
"fs-extra": "^11.3.0",
|
|
46
|
+
"ora": "^8.2.0",
|
|
47
|
+
"prompts": "^2.4.2"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# Quick Reference for AI Assistants
|
|
2
|
+
|
|
3
|
+
**Read this first, then dive into specific rule files as needed.**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
If project is empty start server/client commands (`/create-server`, `/create-client`)
|
|
8
|
+
|
|
9
|
+
## How Rules Are Organized
|
|
10
|
+
|
|
11
|
+
Rules are scoped by directory:
|
|
12
|
+
|
|
13
|
+
| Scope | Path | Applies To |
|
|
14
|
+
|-------|------|------------|
|
|
15
|
+
| **Global** | `.claude/rules/global/` | Entire workspace (server + client) |
|
|
16
|
+
| **Server** | `.claude/rules/server/` | Backend (Fastify API server) only |
|
|
17
|
+
| **Client** | `.claude/rules/client/` | Frontend (Next.js App Router) only |
|
|
18
|
+
|
|
19
|
+
Always check which scope you're working in before writing code.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Global Rules (Always Apply)
|
|
24
|
+
|
|
25
|
+
### Safe Editing
|
|
26
|
+
- Keep changes **small and focused**
|
|
27
|
+
- Preserve existing function signatures and exports unless explicitly asked
|
|
28
|
+
- Extend modules, don't rewrite
|
|
29
|
+
- Add `// TODO:` comments for ambiguities or follow-ups
|
|
30
|
+
- Never leave half-implemented features without explanation
|
|
31
|
+
- No noisy debug logs; mark temporary ones with `// TODO: remove debug log`
|
|
32
|
+
- Never delete or radically restructure large parts of the codebase
|
|
33
|
+
- Preserve existing behavior for critical flows (auth, payments, core business logic)
|
|
34
|
+
|
|
35
|
+
See: `global/core.md`
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Server Rules Summary
|
|
40
|
+
|
|
41
|
+
### Architecture
|
|
42
|
+
```
|
|
43
|
+
Request -> Routes -> Controller -> Service -> Repository -> Database
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- **Controllers**: Validate input (Zod), call services, return responses, throw typed errors. NO business logic, NO direct DB access.
|
|
47
|
+
- **Services**: All business logic. Throw typed `AppError` instances. NO HTTP concepts (request/reply). Return data or throw.
|
|
48
|
+
- **Repositories**: Database queries only.
|
|
49
|
+
|
|
50
|
+
### Module Structure
|
|
51
|
+
```
|
|
52
|
+
src/modules/<domain>/
|
|
53
|
+
<domain>.routes.ts
|
|
54
|
+
<domain>.controller.ts
|
|
55
|
+
<domain>.service.ts
|
|
56
|
+
<domain>.repo.ts
|
|
57
|
+
<domain>.schemas.ts
|
|
58
|
+
<domain>.types.ts (optional)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### API Response Format (Mandatory)
|
|
62
|
+
```json
|
|
63
|
+
// Success
|
|
64
|
+
{ "success": true, "message": "...", "data": { ... } }
|
|
65
|
+
|
|
66
|
+
// Error
|
|
67
|
+
{ "success": false, "error": { "code": "ERROR_CODE", "message": "..." } }
|
|
68
|
+
```
|
|
69
|
+
- Use `successResponse()` / `paginatedResponse()` helpers
|
|
70
|
+
- Throw typed errors only (`AppError` subclasses)
|
|
71
|
+
- Global error handler formats all errors
|
|
72
|
+
|
|
73
|
+
### Auth Architecture
|
|
74
|
+
- **httpOnly cookies** for token storage (access_token + refresh_token)
|
|
75
|
+
- Account lockout with progressive thresholds
|
|
76
|
+
- Session tracking with device info and IP
|
|
77
|
+
- Transparent password rehash (bcrypt legacy -> argon2id)
|
|
78
|
+
|
|
79
|
+
### Database
|
|
80
|
+
- Schema changes via Prisma migrations only
|
|
81
|
+
- Development: `prisma:reset` freely; Production: `prisma:migrate deploy` only
|
|
82
|
+
- Prisma models: `PascalCase`; Fields: `camelCase`
|
|
83
|
+
- All main tables need: `id`, `createdAt`, `updatedAt`
|
|
84
|
+
|
|
85
|
+
### Code Style
|
|
86
|
+
- TypeScript strict mode, type all params and returns
|
|
87
|
+
- `async/await` over `.then()`
|
|
88
|
+
- Named exports (exception: `app.ts` default-exports `buildApp`)
|
|
89
|
+
- Use `logger` from `src/libs/`, never `console.log`
|
|
90
|
+
- Detect package manager from lockfile
|
|
91
|
+
|
|
92
|
+
See: `server/core.md`, `server/project-conventions.md`, `server/response-handling.md`, `server/database.md`
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Client Rules Summary
|
|
97
|
+
|
|
98
|
+
### Architecture
|
|
99
|
+
- Next.js App Router with Server Components by default
|
|
100
|
+
- Client Components only when interactivity is needed (`'use client'`)
|
|
101
|
+
- Feature modules under `src/features/<domain>/`
|
|
102
|
+
|
|
103
|
+
### Auth Flow
|
|
104
|
+
- **httpOnly cookies** — no tokens stored in Redux or localStorage
|
|
105
|
+
- `AuthInitializer` component hydrates user state on page load via `getMe()` API call
|
|
106
|
+
- Redux auth state: `{ user, isAuthenticated, isInitializing, isLoggingOut }`
|
|
107
|
+
- Axios `withCredentials: true` sends cookies automatically
|
|
108
|
+
|
|
109
|
+
### Module Structure
|
|
110
|
+
```
|
|
111
|
+
src/features/<domain>/
|
|
112
|
+
components/
|
|
113
|
+
hooks/
|
|
114
|
+
services/
|
|
115
|
+
store/ (Redux, if needed)
|
|
116
|
+
types/
|
|
117
|
+
actions/ (Server Actions, optional)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### State Management
|
|
121
|
+
| State Type | Tool |
|
|
122
|
+
|------------|------|
|
|
123
|
+
| Server data (SSR) | Server Components |
|
|
124
|
+
| Server data (client) | React Query |
|
|
125
|
+
| Global client state | Redux (auth only) |
|
|
126
|
+
| Local state | useState / useReducer |
|
|
127
|
+
| URL state | useSearchParams |
|
|
128
|
+
|
|
129
|
+
### Component Rules
|
|
130
|
+
- Max 250 lines per component
|
|
131
|
+
- Max 5 props (use object if more)
|
|
132
|
+
- Max 3 levels of JSX nesting
|
|
133
|
+
- Use `cn()` for conditional classes
|
|
134
|
+
- Use Next.js `Image` and `Link` components
|
|
135
|
+
- Follow import order: React/Next -> third-party -> UI -> local -> hooks -> services -> types -> utils
|
|
136
|
+
|
|
137
|
+
### Styling
|
|
138
|
+
- Tailwind CSS v4 only, no inline styles
|
|
139
|
+
- OKLCH color space via CSS custom properties
|
|
140
|
+
- Use semantic color tokens (e.g., `bg-primary`, `text-foreground`)
|
|
141
|
+
- Never hardcode hex/rgb values
|
|
142
|
+
- Pair backgrounds with foregrounds for contrast
|
|
143
|
+
|
|
144
|
+
### Forms
|
|
145
|
+
- React Hook Form + Zod for complex forms
|
|
146
|
+
- Server Actions for simple forms
|
|
147
|
+
- Always validate client-side AND server-side
|
|
148
|
+
|
|
149
|
+
### Security
|
|
150
|
+
- Never inject raw HTML without sanitization (use DOMPurify)
|
|
151
|
+
- Never prefix secrets with `NEXT_PUBLIC_`
|
|
152
|
+
- Validate all inputs, sanitize all outputs
|
|
153
|
+
- Secure external links with `rel="noopener noreferrer"`
|
|
154
|
+
|
|
155
|
+
See: `client/core.md`, `client/01-project-structure.md` through `client/06-ux-checklist.md`
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## When Implementing Features
|
|
160
|
+
|
|
161
|
+
1. **Identify scope** - Are you working in server, client, or both?
|
|
162
|
+
2. **Read relevant rules** - Check the scoped rule files for that directory
|
|
163
|
+
3. **Summarize** what needs to be done
|
|
164
|
+
4. **List** files to create/modify
|
|
165
|
+
5. **Provide** complete code for each file
|
|
166
|
+
6. **Mention** migrations, env variables, or dependencies needed
|
|
167
|
+
7. **State assumptions** if unsure
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Full Documentation Index
|
|
172
|
+
|
|
173
|
+
### Global
|
|
174
|
+
- `global/core.md` - Safe editing, TypeScript, git, env, testing rules
|
|
175
|
+
|
|
176
|
+
### Server
|
|
177
|
+
- `server/core.md` - Index and non-negotiables
|
|
178
|
+
- `server/project-conventions.md` - Stack, folder structure, coding style, Postman
|
|
179
|
+
- `server/response-handling.md` - Response contract, error classes
|
|
180
|
+
- `server/database.md` - Database standards, migrations, indexing
|
|
181
|
+
|
|
182
|
+
### Client
|
|
183
|
+
- `client/core.md` - Architecture and non-negotiables
|
|
184
|
+
- `client/01-project-structure.md` - Folder structure, naming, imports, constants
|
|
185
|
+
- `client/02-components-and-types.md` - Component rules, TypeScript, API types
|
|
186
|
+
- `client/03-data-and-state.md` - State management, React Query, Redux, Axios, forms
|
|
187
|
+
- `client/04-design-system.md` - Colors, typography, spacing, motion, dark mode
|
|
188
|
+
- `client/05-security.md` - Token storage, env vars, CSP, validation
|
|
189
|
+
- `client/06-ux-checklist.md` - Cognitive load, accessibility, performance
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
**Last Updated**: 2026-02-20
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Claude Assistant Rules
|
|
2
|
+
|
|
3
|
+
This directory contains project-specific rules and guidelines for Claude.
|
|
4
|
+
|
|
5
|
+
## Directory Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
.claude/
|
|
9
|
+
├── README.md # This file
|
|
10
|
+
└── rules/
|
|
11
|
+
├── global/ # Cross-cutting rules (always active)
|
|
12
|
+
│ └── core.md # Safe editing, TypeScript, git, env, testing
|
|
13
|
+
├── client/ # Next.js App Router rules
|
|
14
|
+
│ ├── core.md # Index — which file to read for what
|
|
15
|
+
│ ├── 01-project-structure.md
|
|
16
|
+
│ ├── 02-components-and-types.md
|
|
17
|
+
│ ├── 03-data-and-state.md
|
|
18
|
+
│ ├── 04-design-system.md
|
|
19
|
+
│ ├── 05-security.md
|
|
20
|
+
│ └── 06-ux-checklist.md
|
|
21
|
+
└── server/ # Fastify backend rules
|
|
22
|
+
├── core.md # Index — which file to read for what
|
|
23
|
+
├── project-conventions.md
|
|
24
|
+
├── response-handling.md
|
|
25
|
+
└── database.md
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## For Claude
|
|
29
|
+
|
|
30
|
+
- This directory is the source of truth for project rules.
|
|
31
|
+
- **Don't read every file upfront.** Start with the relevant `core.md` index and follow it to the file you need.
|
|
32
|
+
- `global/core.md` always applies. `client/` and `server/` rules apply based on which directory you're working in.
|
|
33
|
+
|
|
34
|
+
## Key Principles (TL;DR)
|
|
35
|
+
|
|
36
|
+
### Global
|
|
37
|
+
- TypeScript strict, no `any`, Zod validation, explicit return types
|
|
38
|
+
- Small focused changes, extend don't rewrite, protect critical flows
|
|
39
|
+
- Conventional commits, `.env` never committed, tests for non-trivial changes
|
|
40
|
+
|
|
41
|
+
### Server
|
|
42
|
+
- **Stack**: Node.js, Fastify, TypeScript, MySQL, Prisma, Redis
|
|
43
|
+
- **Architecture**: Routes → Controllers → Services → Repositories → DB
|
|
44
|
+
- **API**: All routes prefixed with `/api/v1`
|
|
45
|
+
- **Responses**: `successResponse()` / `paginatedResponse()` — no custom shapes
|
|
46
|
+
- **Errors**: Only `AppError` subclasses, global error handler formats everything
|
|
47
|
+
|
|
48
|
+
### Client
|
|
49
|
+
- **Stack**: Next.js App Router, React Query, Redux (auth only), shadcn/ui, Tailwind
|
|
50
|
+
- **Architecture**: Server Components by default, `'use client'` only when needed
|
|
51
|
+
- **State**: Server data → Server Components or React Query. Redux → auth only. URL → filters/pagination
|
|
52
|
+
- **Design**: Semantic color tokens only, no hardcoded colors, neuro-minimalist aesthetic
|
|
53
|
+
- **Components**: Max 250 lines, max 5 props, max 3 JSX nesting levels
|