create-tigra 1.0.7 → 2.0.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 +21 -21
- package/README.md +80 -87
- package/bin/create-tigra.js +242 -309
- 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 +80 -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 -12
- package/template/server/README.md +0 -183
- 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/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/template/CLAUDE.md
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
# Project Rules for Claude
|
|
2
|
-
|
|
3
|
-
> This file is automatically loaded by Claude Code at the start of each conversation.
|
|
4
|
-
> For detailed rules, see `.claude/rules/` directory.
|
|
5
|
-
|
|
6
|
-
## Safe Editing Rules (CRITICAL)
|
|
7
|
-
|
|
8
|
-
- Assume this is a **production project**. No destructive or experimental changes.
|
|
9
|
-
- Keep changes **small and focused**.
|
|
10
|
-
- Do NOT change existing function signatures, exports, or imports unless explicitly asked.
|
|
11
|
-
- Preserve existing behavior for: Auth, Core business flows, Payment flows.
|
|
12
|
-
- If introducing a breaking change, **call it out clearly**.
|
|
13
|
-
- Add `// TODO:` comments for ambiguous or incomplete sections.
|
|
14
|
-
- Do NOT add noisy debug logs.
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## Stack Overview
|
|
19
|
-
|
|
20
|
-
### Server (`server/`)
|
|
21
|
-
- **Runtime**: Node.js 20+ LTS
|
|
22
|
-
- **Framework**: Fastify
|
|
23
|
-
- **Language**: TypeScript (strict mode)
|
|
24
|
-
- **Database**: MySQL + Prisma ORM
|
|
25
|
-
- **Cache/Queue**: Redis + BullMQ
|
|
26
|
-
- **Validation**: Zod
|
|
27
|
-
- **Testing**: Vitest
|
|
28
|
-
|
|
29
|
-
### Client (`client/`)
|
|
30
|
-
- **Framework**: React 18+ with Vite
|
|
31
|
-
- **UI Library**: Ant Design
|
|
32
|
-
- **State**: Redux Toolkit + React Query
|
|
33
|
-
- **Language**: TypeScript (strict mode)
|
|
34
|
-
- **Styling**: CSS Modules / Tailwind
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## Server Architecture
|
|
39
|
-
|
|
40
|
-
### File Structure
|
|
41
|
-
```
|
|
42
|
-
server/src/
|
|
43
|
-
├── app.ts # Fastify instance & plugin registration
|
|
44
|
-
├── server.ts # Server bootstrap (listen call only)
|
|
45
|
-
├── config/ # env, constants
|
|
46
|
-
├── libs/ # Shared: db, redis, logger, auth
|
|
47
|
-
├── plugins/ # Fastify plugins
|
|
48
|
-
├── hooks/ # Fastify hooks
|
|
49
|
-
├── routes/ # Standalone routes (health, etc.)
|
|
50
|
-
└── modules/<domain>/ # Domain modules
|
|
51
|
-
├── <domain>.routes.ts
|
|
52
|
-
├── <domain>.controller.ts
|
|
53
|
-
├── <domain>.service.ts
|
|
54
|
-
├── <domain>.repo.ts
|
|
55
|
-
├── <domain>.schemas.ts
|
|
56
|
-
└── <domain>.types.ts
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Layered Architecture
|
|
60
|
-
```
|
|
61
|
-
Routes → Controllers → Services → Repositories → DB
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
- **Controllers**: HTTP handlers only, no business logic
|
|
65
|
-
- **Services**: Business logic, throw typed `AppError` instances
|
|
66
|
-
- **Repositories**: Database queries only
|
|
67
|
-
|
|
68
|
-
### Response Contract (MANDATORY)
|
|
69
|
-
|
|
70
|
-
**Success Response:**
|
|
71
|
-
```json
|
|
72
|
-
{
|
|
73
|
-
"success": true,
|
|
74
|
-
"message": "Human readable message",
|
|
75
|
-
"data": {}
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
**Error Response:**
|
|
80
|
-
```json
|
|
81
|
-
{
|
|
82
|
-
"success": false,
|
|
83
|
-
"error": {
|
|
84
|
-
"code": "ERROR_CODE",
|
|
85
|
-
"message": "Human readable message"
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
- Use `successResponse()` helper in controllers
|
|
91
|
-
- Throw typed errors (`BadRequestError`, `NotFoundError`, etc.)
|
|
92
|
-
- NEVER expose stack traces or internal errors to clients
|
|
93
|
-
|
|
94
|
-
### Error Types
|
|
95
|
-
- `BadRequestError`, `ValidationError`, `UnauthorizedError`
|
|
96
|
-
- `ForbiddenError`, `NotFoundError`, `ConflictError`, `InternalError`
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
## Client Architecture
|
|
101
|
-
|
|
102
|
-
### File Structure
|
|
103
|
-
```
|
|
104
|
-
client/src/
|
|
105
|
-
├── app/ # App config (App.tsx, router, providers)
|
|
106
|
-
├── components/
|
|
107
|
-
│ ├── layout/ # Header, Footer, Sidebar, MainLayout
|
|
108
|
-
│ └── common/ # Shared components
|
|
109
|
-
├── features/<domain>/ # Feature modules
|
|
110
|
-
│ ├── components/
|
|
111
|
-
│ ├── hooks/
|
|
112
|
-
│ ├── pages/
|
|
113
|
-
│ ├── services/
|
|
114
|
-
│ ├── store/
|
|
115
|
-
│ ├── types/
|
|
116
|
-
│ └── utils/
|
|
117
|
-
├── hooks/ # Global hooks
|
|
118
|
-
├── lib/
|
|
119
|
-
│ ├── api/ # Axios config, API types
|
|
120
|
-
│ ├── constants/ # routes, api-endpoints, app.constants
|
|
121
|
-
│ └── utils/
|
|
122
|
-
├── store/ # Redux store
|
|
123
|
-
├── types/ # Global types
|
|
124
|
-
└── styles/
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### Naming Conventions
|
|
128
|
-
- **Components**: `PascalCase.tsx` (e.g., `ResourceCard.tsx`)
|
|
129
|
-
- **Pages**: `PascalCase + Page.tsx` (e.g., `ResourcesPage.tsx`)
|
|
130
|
-
- **Hooks**: `use<Name>.ts` (e.g., `useAuth.ts`)
|
|
131
|
-
- **Services**: `<domain>.service.ts`
|
|
132
|
-
- **Types**: `<domain>.types.ts`
|
|
133
|
-
|
|
134
|
-
### TypeScript Rules
|
|
135
|
-
- **NO `any` type** - use `unknown` if needed
|
|
136
|
-
- Explicit return types for all functions
|
|
137
|
-
- Use `interface` for props/objects, `type` for unions/intersections
|
|
138
|
-
|
|
139
|
-
### API Response Types (must match backend)
|
|
140
|
-
```tsx
|
|
141
|
-
interface ApiResponse<T> {
|
|
142
|
-
success: boolean;
|
|
143
|
-
message: string;
|
|
144
|
-
data: T;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
interface PaginatedApiResponse<T> {
|
|
148
|
-
success: boolean;
|
|
149
|
-
message: string;
|
|
150
|
-
data: {
|
|
151
|
-
items: T[];
|
|
152
|
-
pagination: {
|
|
153
|
-
page: number;
|
|
154
|
-
limit: number;
|
|
155
|
-
totalItems: number;
|
|
156
|
-
totalPages: number;
|
|
157
|
-
hasNextPage: boolean;
|
|
158
|
-
hasPreviousPage: boolean;
|
|
159
|
-
};
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
## Coding Style (Both)
|
|
167
|
-
|
|
168
|
-
- Prefer `async/await` over `.then()`
|
|
169
|
-
- Prefer named exports (except `app.ts` and React pages)
|
|
170
|
-
- Use path aliases: `@/`, `@/libs/`, `@/modules/`, etc.
|
|
171
|
-
- Never `console.log` in production code - use the shared `logger`
|
|
172
|
-
|
|
173
|
-
---
|
|
174
|
-
|
|
175
|
-
## Package Manager Detection
|
|
176
|
-
|
|
177
|
-
- `pnpm-lock.yaml` exists → use `pnpm`
|
|
178
|
-
- `yarn.lock` exists → use `yarn`
|
|
179
|
-
- Otherwise → use `npm`
|
|
180
|
-
|
|
181
|
-
---
|
|
182
|
-
|
|
183
|
-
## When Implementing Features
|
|
184
|
-
|
|
185
|
-
1. Summarize what needs to be done
|
|
186
|
-
2. List files to be created/modified
|
|
187
|
-
3. Provide code for each file
|
|
188
|
-
4. Mention any migrations or env variables needed
|
|
189
|
-
5. If unsure, state assumptions clearly
|
|
190
|
-
|
|
191
|
-
---
|
|
192
|
-
|
|
193
|
-
## Detailed Rules
|
|
194
|
-
|
|
195
|
-
For comprehensive rules, read the appropriate files in `.claude/rules/`:
|
|
196
|
-
|
|
197
|
-
**Server:**
|
|
198
|
-
- `server-02-general-rules.md` - Architecture & code style
|
|
199
|
-
- `server-05-project-conventions.md` - File structure & conventions
|
|
200
|
-
- `server-06-response-handling.md` - Error & success responses
|
|
201
|
-
|
|
202
|
-
**Client:**
|
|
203
|
-
- `client-01-project-structure.md` - File structure & naming
|
|
204
|
-
- `client-03-typescript-rules.md` - TypeScript conventions
|
|
205
|
-
|
|
206
|
-
**Global:**
|
|
207
|
-
- `global-ai-edit-safety.md` - Safe editing practices
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
# {{PROJECT_DISPLAY_NAME}}
|
|
2
|
-
|
|
3
|
-
{{PROJECT_DESCRIPTION}}
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
- JWT Authentication (access + refresh tokens)
|
|
7
|
-
- User management with role-based access
|
|
8
|
-
- Complete CRUD for resources
|
|
9
|
-
- Pagination with filters
|
|
10
|
-
- Rate limiting with Redis
|
|
11
|
-
- Background job processing (BullMQ)
|
|
12
|
-
- Comprehensive error handling
|
|
13
|
-
- Request logging and monitoring
|
|
14
|
-
- Health checks
|
|
15
|
-
|
|
16
|
-
## Tech Stack
|
|
17
|
-
- **Runtime**: Node.js 20+
|
|
18
|
-
- **Framework**: Fastify 4
|
|
19
|
-
- **Database**: MySQL 8.0 with Prisma ORM
|
|
20
|
-
- **Cache/Queue**: Redis + BullMQ
|
|
21
|
-
- **Validation**: Zod
|
|
22
|
-
- **Authentication**: JWT (jsonwebtoken)
|
|
23
|
-
- **Testing**: Vitest + Supertest
|
|
24
|
-
|
|
25
|
-
## Prerequisites
|
|
26
|
-
- Node.js 20 or higher
|
|
27
|
-
- Docker and Docker Compose
|
|
28
|
-
- npm or pnpm
|
|
29
|
-
|
|
30
|
-
## Quick Start
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
# 1. Install dependencies
|
|
34
|
-
npm install
|
|
35
|
-
|
|
36
|
-
# 2. Start Docker services (MySQL + Redis)
|
|
37
|
-
docker-compose up -d
|
|
38
|
-
|
|
39
|
-
# 3. Initialize database (creates .env, waits for DB, runs migrations)
|
|
40
|
-
npm run db:init
|
|
41
|
-
|
|
42
|
-
# 4. Seed the database
|
|
43
|
-
npm run prisma:seed
|
|
44
|
-
|
|
45
|
-
# 5. Start development server
|
|
46
|
-
npm run dev
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Server will start at http://localhost:3000
|
|
50
|
-
|
|
51
|
-
### Production Installation
|
|
52
|
-
|
|
53
|
-
For production deployments, install only production dependencies:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
# Install production dependencies only (faster, smaller)
|
|
57
|
-
npm install --omit=dev
|
|
58
|
-
|
|
59
|
-
# Generate Prisma Client
|
|
60
|
-
npx prisma generate
|
|
61
|
-
|
|
62
|
-
# Run migrations
|
|
63
|
-
npx prisma migrate deploy
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## API Endpoints
|
|
67
|
-
|
|
68
|
-
Once running, you can access:
|
|
69
|
-
- Health Check: http://localhost:3000/health
|
|
70
|
-
- Auth endpoints: http://localhost:3000/api/v1/auth/*
|
|
71
|
-
- Resources endpoints: http://localhost:3000/api/v1/resources/*
|
|
72
|
-
- Admin endpoints: http://localhost:3000/api/v1/admin/*
|
|
73
|
-
|
|
74
|
-
## Available Scripts
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
npm run dev # Start dev server with hot reload
|
|
78
|
-
npm run build # Build for production
|
|
79
|
-
npm run start # Start production server
|
|
80
|
-
npm test # Run tests
|
|
81
|
-
npm run test:watch # Run tests in watch mode
|
|
82
|
-
npm run test:coverage # Generate coverage report
|
|
83
|
-
npm run prisma:generate # Generate Prisma Client
|
|
84
|
-
npm run prisma:migrate # Run migrations (dev)
|
|
85
|
-
npm run prisma:seed # Seed database
|
|
86
|
-
npm run prisma:studio # Open Prisma Studio
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## Project Structure
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
src/
|
|
93
|
-
├── app.ts # Fastify app with plugins
|
|
94
|
-
├── server.ts # Server startup
|
|
95
|
-
├── config/
|
|
96
|
-
│ └── env.ts # Environment validation
|
|
97
|
-
├── libs/
|
|
98
|
-
│ ├── db.ts # Prisma client
|
|
99
|
-
│ ├── redis.ts # Redis connection
|
|
100
|
-
│ ├── logger.ts # Pino logger
|
|
101
|
-
│ └── queue.ts # BullMQ queues
|
|
102
|
-
├── modules/
|
|
103
|
-
│ ├── auth/ # Authentication module
|
|
104
|
-
│ │ ├── auth.routes.ts
|
|
105
|
-
│ │ ├── auth.controller.ts
|
|
106
|
-
│ │ ├── auth.service.ts
|
|
107
|
-
│ │ ├── auth.repo.ts
|
|
108
|
-
│ │ ├── auth.schemas.ts
|
|
109
|
-
│ │ └── auth.types.ts
|
|
110
|
-
│ └── resources/ # Resources module
|
|
111
|
-
├── utils/
|
|
112
|
-
│ ├── errors.ts # Custom error classes
|
|
113
|
-
│ ├── response.ts # Response helpers
|
|
114
|
-
│ └── pagination.ts # Pagination helper
|
|
115
|
-
└── workers/
|
|
116
|
-
└── email.worker.ts # Background email worker
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
## Environment Variables
|
|
120
|
-
|
|
121
|
-
Required:
|
|
122
|
-
- `DATABASE_URL` - MySQL connection string
|
|
123
|
-
- `JWT_SECRET` - JWT signing secret (min 32 chars)
|
|
124
|
-
- `REDIS_HOST` - Redis host
|
|
125
|
-
- `REDIS_PORT` - Redis port
|
|
126
|
-
|
|
127
|
-
See `.env.example` for all available variables.
|
|
128
|
-
|
|
129
|
-
## Testing
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
npm test # Run all tests
|
|
133
|
-
npm run test:coverage # Generate coverage report
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
Coverage targets: 70%+ overall
|
|
137
|
-
|
|
138
|
-
## Management Tools
|
|
139
|
-
|
|
140
|
-
The project includes built-in web interfaces for managing your data:
|
|
141
|
-
|
|
142
|
-
### Database (phpMyAdmin)
|
|
143
|
-
- **URL:** [http://localhost:8080](http://localhost:8080)
|
|
144
|
-
- **User:** `{{DATABASE_USER}}` or `root`
|
|
145
|
-
- **Password:** `{{DATABASE_PASSWORD}}` or `password` (check `docker-compose.yml`)
|
|
146
|
-
|
|
147
|
-
### Redis (Redis Commander)
|
|
148
|
-
- **URL:** [http://localhost:8081](http://localhost:8081)
|
|
149
|
-
- **Host:** `local:redis:6379` (default)
|
|
150
|
-
|
|
151
|
-
## Production Deployment
|
|
152
|
-
|
|
153
|
-
### Production Checklist
|
|
154
|
-
|
|
155
|
-
- [ ] Set `NODE_ENV=production`
|
|
156
|
-
- [ ] Build application: `npm run build`
|
|
157
|
-
- [ ] Configure environment variables
|
|
158
|
-
- [ ] Configure Nginx reverse proxy
|
|
159
|
-
- [ ] Set up SSL certificates (Let's Encrypt)
|
|
160
|
-
- [ ] Configure firewall (UFW/iptables)
|
|
161
|
-
- [ ] Set up monitoring (Sentry, logging)
|
|
162
|
-
- [ ] Configure log rotation
|
|
163
|
-
- [ ] Set up automated backups (database + uploads)
|
|
164
|
-
- [ ] Configure rate limiting for production
|
|
165
|
-
- [ ] Enable CORS for production domains only
|
|
166
|
-
|
|
167
|
-
## Security
|
|
168
|
-
|
|
169
|
-
This project follows security best practices and undergoes regular security audits.
|
|
170
|
-
|
|
171
|
-
**Security Status**: Production dependencies 100% secure
|
|
172
|
-
|
|
173
|
-
For detailed information about:
|
|
174
|
-
- Known security considerations
|
|
175
|
-
- Security best practices
|
|
176
|
-
- Vulnerability reporting
|
|
177
|
-
- Audit history
|
|
178
|
-
|
|
179
|
-
See **[SECURITY.md](./SECURITY.md)**
|
|
180
|
-
|
|
181
|
-
## License
|
|
182
|
-
|
|
183
|
-
MIT
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
# Security Considerations
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
This document outlines known security considerations for this project. We take security seriously and regularly audit our dependencies for vulnerabilities.
|
|
6
|
-
|
|
7
|
-
**Last Security Audit**: January 10, 2026
|
|
8
|
-
**Next Scheduled Audit**: February 10, 2026
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## Current Security Status
|
|
13
|
-
|
|
14
|
-
**Production Dependencies**: 100% Secure (0 vulnerabilities)
|
|
15
|
-
**Development Dependencies**: 100% Secure (0 vulnerabilities)
|
|
16
|
-
**Overall Security Score**: 100/100
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## Known Issues
|
|
21
|
-
|
|
22
|
-
**None** - All dependencies are currently secure with no known vulnerabilities.
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## Security Best Practices
|
|
27
|
-
|
|
28
|
-
### Dependency Management
|
|
29
|
-
|
|
30
|
-
1. **Monthly Security Audits**
|
|
31
|
-
```bash
|
|
32
|
-
npm audit
|
|
33
|
-
npm outdated
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
2. **Automated Monitoring**
|
|
37
|
-
- Enable GitHub Dependabot
|
|
38
|
-
- Subscribe to security advisories
|
|
39
|
-
- Monitor npm security feeds
|
|
40
|
-
|
|
41
|
-
3. **Update Strategy**
|
|
42
|
-
- Patch versions: Update immediately
|
|
43
|
-
- Minor versions: Update monthly
|
|
44
|
-
- Major versions: Review and test before updating
|
|
45
|
-
|
|
46
|
-
### Environment Variables
|
|
47
|
-
|
|
48
|
-
1. **Never Commit Secrets**
|
|
49
|
-
- Use `.env` files (gitignored)
|
|
50
|
-
- Use environment-specific configurations
|
|
51
|
-
- Rotate secrets regularly
|
|
52
|
-
|
|
53
|
-
2. **Required Environment Variables**
|
|
54
|
-
```bash
|
|
55
|
-
# See .env.example for full list
|
|
56
|
-
DATABASE_URL=mysql://...
|
|
57
|
-
JWT_SECRET=<minimum-32-characters>
|
|
58
|
-
REDIS_HOST=localhost
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
3. **Validation**
|
|
62
|
-
- All environment variables are validated at startup
|
|
63
|
-
- See `src/config/env.ts` for schema
|
|
64
|
-
|
|
65
|
-
### Authentication & Authorization
|
|
66
|
-
|
|
67
|
-
1. **JWT Security**
|
|
68
|
-
- Tokens include issuer validation
|
|
69
|
-
- Access tokens expire in 15 minutes
|
|
70
|
-
- Refresh tokens expire in 7 days
|
|
71
|
-
- Secure secret (minimum 32 characters)
|
|
72
|
-
|
|
73
|
-
2. **Password Security**
|
|
74
|
-
- bcrypt with 10 rounds
|
|
75
|
-
- Minimum password requirements enforced
|
|
76
|
-
- No password storage in logs
|
|
77
|
-
|
|
78
|
-
3. **Role-Based Access Control (RBAC)**
|
|
79
|
-
- Implemented via middleware
|
|
80
|
-
- Three roles: USER, ORGANIZATION, ADMIN
|
|
81
|
-
- Route-level permission checks
|
|
82
|
-
|
|
83
|
-
### API Security
|
|
84
|
-
|
|
85
|
-
1. **Rate Limiting**
|
|
86
|
-
- Global: 100 requests per 15 minutes
|
|
87
|
-
- Login: 5 requests per 15 minutes
|
|
88
|
-
- Configurable per route
|
|
89
|
-
|
|
90
|
-
2. **Input Validation**
|
|
91
|
-
- All inputs validated with Zod schemas
|
|
92
|
-
- Type-safe validation
|
|
93
|
-
- Automatic error responses
|
|
94
|
-
|
|
95
|
-
3. **Security Headers**
|
|
96
|
-
- Helmet.js for security headers
|
|
97
|
-
- CORS properly configured
|
|
98
|
-
- CSP enabled in production
|
|
99
|
-
|
|
100
|
-
### Database Security
|
|
101
|
-
|
|
102
|
-
1. **SQL Injection Prevention**
|
|
103
|
-
- Prisma ORM (parameterized queries)
|
|
104
|
-
- No raw SQL with user input
|
|
105
|
-
- Type-safe database access
|
|
106
|
-
|
|
107
|
-
2. **Connection Security**
|
|
108
|
-
- Encrypted connections (SSL/TLS)
|
|
109
|
-
- Connection pooling
|
|
110
|
-
- Credential rotation
|
|
111
|
-
|
|
112
|
-
### Monitoring & Logging
|
|
113
|
-
|
|
114
|
-
1. **Structured Logging**
|
|
115
|
-
- Pino for high-performance logging
|
|
116
|
-
- Sensitive data redaction
|
|
117
|
-
- Request ID tracking
|
|
118
|
-
|
|
119
|
-
2. **Error Handling**
|
|
120
|
-
- No stack traces in production responses
|
|
121
|
-
- Internal errors logged securely
|
|
122
|
-
- User-friendly error messages
|
|
123
|
-
|
|
124
|
-
---
|
|
125
|
-
|
|
126
|
-
## Reporting Security Issues
|
|
127
|
-
|
|
128
|
-
If you discover a security vulnerability, please follow responsible disclosure:
|
|
129
|
-
|
|
130
|
-
1. **Do NOT** open a public GitHub issue
|
|
131
|
-
2. Email security concerns to: [itorn9777@gmail.com]
|
|
132
|
-
3. Include:
|
|
133
|
-
- Description of the vulnerability
|
|
134
|
-
- Steps to reproduce
|
|
135
|
-
- Potential impact
|
|
136
|
-
- Suggested fix (if any)
|
|
137
|
-
|
|
138
|
-
We will respond within 48 hours and work with you to address the issue.
|
|
139
|
-
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
## Security Audit History
|
|
143
|
-
|
|
144
|
-
### January 10, 2026
|
|
145
|
-
- **Action**: Comprehensive dependency update
|
|
146
|
-
- **Vulnerabilities Fixed**: 8 out of 8 (100%)
|
|
147
|
-
- **Status**: All dependencies 100% secure
|
|
148
|
-
- **Remaining**: None
|
|
149
|
-
- **Next Review**: February 10, 2026
|
|
150
|
-
|
|
151
|
-
### Previous Audits
|
|
152
|
-
- Initial security setup and configuration
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
## Compliance & Standards
|
|
157
|
-
|
|
158
|
-
This project follows security best practices including:
|
|
159
|
-
|
|
160
|
-
- OWASP Top 10 guidelines
|
|
161
|
-
- Secure coding standards
|
|
162
|
-
- Regular dependency audits
|
|
163
|
-
- Input validation and sanitization
|
|
164
|
-
- Secure authentication and authorization
|
|
165
|
-
- Encrypted data transmission
|
|
166
|
-
- Comprehensive logging and monitoring
|
|
167
|
-
|
|
168
|
-
---
|
|
169
|
-
|
|
170
|
-
## Additional Resources
|
|
171
|
-
|
|
172
|
-
**Security Tools:**
|
|
173
|
-
- npm audit: Built-in vulnerability scanner
|
|
174
|
-
- Snyk: https://snyk.io/
|
|
175
|
-
- GitHub Dependabot: Automated dependency updates
|
|
176
|
-
|
|
177
|
-
**Security Guides:**
|
|
178
|
-
- OWASP: https://owasp.org/
|
|
179
|
-
- Node.js Security Best Practices: https://nodejs.org/en/docs/guides/security/
|
|
180
|
-
- Fastify Security: https://www.fastify.io/docs/latest/Guides/Security/
|
|
181
|
-
|
|
182
|
-
**Monitoring:**
|
|
183
|
-
- npm Security Advisories: https://github.com/advisories
|
|
184
|
-
- Node.js Security Releases: https://nodejs.org/en/blog/vulnerability/
|
|
185
|
-
|
|
186
|
-
---
|
|
187
|
-
|
|
188
|
-
**Last Updated**: January 10, 2026
|
|
189
|
-
**Maintained By**: Development Team
|
|
190
|
-
**Review Schedule**: Monthly
|