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
|
@@ -1,98 +1,43 @@
|
|
|
1
|
-
import { defineConfig } from 'vitest/config';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
hookTimeout: 10000,
|
|
45
|
-
|
|
46
|
-
// Teardown timeout (milliseconds)
|
|
47
|
-
teardownTimeout: 10000,
|
|
48
|
-
|
|
49
|
-
// Setup files to run before tests
|
|
50
|
-
setupFiles: ['./src/test/setup.ts'],
|
|
51
|
-
|
|
52
|
-
// Reporter configuration
|
|
53
|
-
reporters: ['verbose'],
|
|
54
|
-
|
|
55
|
-
// Isolate tests in separate threads
|
|
56
|
-
isolate: true,
|
|
57
|
-
|
|
58
|
-
// Pool configuration (Vitest v2)
|
|
59
|
-
pool: 'threads',
|
|
60
|
-
poolOptions: {
|
|
61
|
-
threads: {
|
|
62
|
-
maxThreads: 4,
|
|
63
|
-
minThreads: 1,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
// Retry failed tests
|
|
68
|
-
retry: 0,
|
|
69
|
-
|
|
70
|
-
// Bail on first test failure
|
|
71
|
-
bail: 0,
|
|
72
|
-
|
|
73
|
-
// Watch mode options
|
|
74
|
-
watch: false,
|
|
75
|
-
|
|
76
|
-
// Mock configuration
|
|
77
|
-
mockReset: true,
|
|
78
|
-
restoreMocks: true,
|
|
79
|
-
clearMocks: true,
|
|
80
|
-
|
|
81
|
-
// Silent console output during tests
|
|
82
|
-
silent: false,
|
|
83
|
-
|
|
84
|
-
// Include source files in coverage
|
|
85
|
-
includeSource: ['src/**/*.ts'],
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
// Path resolution (match tsconfig.json paths)
|
|
89
|
-
resolve: {
|
|
90
|
-
alias: {
|
|
91
|
-
'@': path.resolve(__dirname, './src'),
|
|
92
|
-
'@/config': path.resolve(__dirname, './src/config'),
|
|
93
|
-
'@/libs': path.resolve(__dirname, './src/libs'),
|
|
94
|
-
'@/modules': path.resolve(__dirname, './src/modules'),
|
|
95
|
-
'@/types': path.resolve(__dirname, './src/types'),
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
});
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
test: {
|
|
6
|
+
globals: true,
|
|
7
|
+
environment: 'node',
|
|
8
|
+
coverage: {
|
|
9
|
+
provider: 'v8',
|
|
10
|
+
reporter: ['text', 'json', 'html', 'lcov'],
|
|
11
|
+
exclude: [
|
|
12
|
+
'node_modules/**',
|
|
13
|
+
'dist/**',
|
|
14
|
+
'**/*.config.ts',
|
|
15
|
+
'**/*.config.js',
|
|
16
|
+
'**/test/**',
|
|
17
|
+
'**/__tests__/**',
|
|
18
|
+
'prisma/**',
|
|
19
|
+
'scripts/**',
|
|
20
|
+
],
|
|
21
|
+
thresholds: {
|
|
22
|
+
lines: 80,
|
|
23
|
+
functions: 80,
|
|
24
|
+
branches: 80,
|
|
25
|
+
statements: 80,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
setupFiles: ['./src/test/setup.ts'],
|
|
29
|
+
include: ['**/__tests__/**/*.test.ts', '**/*.test.ts'],
|
|
30
|
+
exclude: ['node_modules', 'dist'],
|
|
31
|
+
testTimeout: 10000,
|
|
32
|
+
hookTimeout: 10000,
|
|
33
|
+
},
|
|
34
|
+
resolve: {
|
|
35
|
+
alias: {
|
|
36
|
+
'@': resolve(__dirname, './src'),
|
|
37
|
+
'@modules': resolve(__dirname, './src/modules'),
|
|
38
|
+
'@libs': resolve(__dirname, './src/libs'),
|
|
39
|
+
'@config': resolve(__dirname, './src/config'),
|
|
40
|
+
'@shared': resolve(__dirname, './src/shared'),
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
trigger: always_on
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
> **SCOPE**: These rules apply specifically to the **client** directory.
|
|
6
|
-
|
|
7
|
-
# Project Structure & File Naming
|
|
8
|
-
|
|
9
|
-
## Folder Structure
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
src/
|
|
13
|
-
├── app/ # App configuration
|
|
14
|
-
│ ├── App.tsx
|
|
15
|
-
│ ├── router.tsx
|
|
16
|
-
│ └── providers.tsx
|
|
17
|
-
├── components/
|
|
18
|
-
│ ├── layout/ # Header, Footer, MainLayout
|
|
19
|
-
│ │ ├── Header.tsx
|
|
20
|
-
│ │ ├── Footer.tsx
|
|
21
|
-
│ │ ├── Sidebar.tsx
|
|
22
|
-
│ │ └── MainLayout.tsx
|
|
23
|
-
│ └── common/ # Shared components
|
|
24
|
-
│ ├── LoadingSpinner.tsx
|
|
25
|
-
│ ├── ErrorBoundary.tsx
|
|
26
|
-
│ ├── ProtectedRoute.tsx
|
|
27
|
-
│ ├── Pagination.tsx
|
|
28
|
-
│ └── EmptyState.tsx
|
|
29
|
-
├── features/ # Feature modules (domain-driven)
|
|
30
|
-
│ ├── auth/
|
|
31
|
-
│ │ ├── components/ # LoginForm, RegisterForm
|
|
32
|
-
│ │ ├── hooks/ # useAuth, useLogin, useRegister
|
|
33
|
-
│ │ ├── pages/ # LoginPage, RegisterPage
|
|
34
|
-
│ │ ├── services/ # auth.service.ts
|
|
35
|
-
│ │ ├── store/ # authSlice.ts (Redux)
|
|
36
|
-
│ │ ├── types/ # auth.types.ts
|
|
37
|
-
│ │ └── utils/ # auth.utils.ts
|
|
38
|
-
│ ├── resources/ # Example feature
|
|
39
|
-
│ │ ├── components/
|
|
40
|
-
│ │ ├── hooks/
|
|
41
|
-
│ │ ├── pages/
|
|
42
|
-
│ │ ├── services/
|
|
43
|
-
│ │ ├── types/
|
|
44
|
-
│ │ └── utils/
|
|
45
|
-
│ └── users/
|
|
46
|
-
├── hooks/ # Global custom hooks
|
|
47
|
-
│ ├── useDebounce.ts
|
|
48
|
-
│ ├── useLocalStorage.ts
|
|
49
|
-
│ └── useMediaQuery.ts
|
|
50
|
-
├── lib/
|
|
51
|
-
│ ├── api/
|
|
52
|
-
│ │ ├── axios.config.ts
|
|
53
|
-
│ │ └── api.types.ts
|
|
54
|
-
│ ├── constants/
|
|
55
|
-
│ │ ├── routes.ts
|
|
56
|
-
│ │ ├── api-endpoints.ts
|
|
57
|
-
│ │ └── app.constants.ts
|
|
58
|
-
│ └── utils/
|
|
59
|
-
│ ├── format.ts
|
|
60
|
-
│ ├── validation.ts
|
|
61
|
-
│ └── error.ts
|
|
62
|
-
├── store/ # Redux store
|
|
63
|
-
│ ├── index.ts
|
|
64
|
-
│ └── hooks.ts
|
|
65
|
-
├── types/ # Global types
|
|
66
|
-
│ ├── index.ts
|
|
67
|
-
│ └── api.types.ts
|
|
68
|
-
└── styles/
|
|
69
|
-
├── globals.css # Global CSS
|
|
70
|
-
└── theme.css # Ant Design custom theme (if needed)
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## File Naming Rules
|
|
74
|
-
|
|
75
|
-
### Components
|
|
76
|
-
- **PascalCase**: `ResourceCard.tsx`, `LoginForm.tsx`
|
|
77
|
-
- **Pattern**: `<ComponentName>.tsx`
|
|
78
|
-
- **CSS**: If using CSS Modules, name as `<ComponentName>.module.css`
|
|
79
|
-
|
|
80
|
-
### Pages
|
|
81
|
-
- **PascalCase + Page suffix**: `ResourcesPage.tsx`, `LoginPage.tsx`
|
|
82
|
-
- **Pattern**: `<FeatureName>Page.tsx`
|
|
83
|
-
|
|
84
|
-
### Hooks
|
|
85
|
-
- **camelCase + use prefix**: `useAuth.ts`, `useResources.ts`
|
|
86
|
-
- **Pattern**: `use<HookName>.ts`
|
|
87
|
-
|
|
88
|
-
### Services
|
|
89
|
-
- **camelCase + .service suffix**: `auth.service.ts`, `resource.service.ts`
|
|
90
|
-
- **Pattern**: `<domain>.service.ts`
|
|
91
|
-
|
|
92
|
-
### Types
|
|
93
|
-
- **camelCase + .types suffix**: `auth.types.ts`, `resource.types.ts`
|
|
94
|
-
- **Pattern**: `<domain>.types.ts`
|
|
95
|
-
|
|
96
|
-
### Store (Redux)
|
|
97
|
-
- **camelCase + Slice suffix**: `authSlice.ts`, `resourceSlice.ts`
|
|
98
|
-
- **Pattern**: `<domain>Slice.ts`
|
|
99
|
-
|
|
100
|
-
### Utils
|
|
101
|
-
- **camelCase + .utils suffix**: `auth.utils.ts`, `date.utils.ts`
|
|
102
|
-
- **Pattern**: `<purpose>.utils.ts`
|
|
103
|
-
|
|
104
|
-
### Constants
|
|
105
|
-
- **camelCase**: `routes.ts`, `api-endpoints.ts`, `app.constants.ts`
|
|
106
|
-
|
|
107
|
-
## Module Structure Pattern
|
|
108
|
-
|
|
109
|
-
Every feature module follows this pattern:
|
|
110
|
-
|
|
111
|
-
```
|
|
112
|
-
features/<domain>/
|
|
113
|
-
├── components/ # Feature-specific components
|
|
114
|
-
├── hooks/ # Feature-specific hooks
|
|
115
|
-
├── pages/ # Feature pages (routes)
|
|
116
|
-
├── services/ # API service
|
|
117
|
-
├── store/ # Redux slice (if needed)
|
|
118
|
-
├── types/ # TypeScript types
|
|
119
|
-
└── utils/ # Feature utilities
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## Import Path Aliases
|
|
123
|
-
|
|
124
|
-
```json
|
|
125
|
-
// tsconfig.json & vite.config.ts
|
|
126
|
-
{
|
|
127
|
-
"paths": {
|
|
128
|
-
"@/*": ["./src/*"],
|
|
129
|
-
"@/components/*": ["./src/components/*"],
|
|
130
|
-
"@/features/*": ["./src/features/*"],
|
|
131
|
-
"@/lib/*": ["./src/lib/*"],
|
|
132
|
-
"@/hooks/*": ["./src/hooks/*"],
|
|
133
|
-
"@/store/*": ["./src/store/*"],
|
|
134
|
-
"@/types/*": ["./src/types/*"],
|
|
135
|
-
"@/styles/*": ["./src/styles/*"]
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## Import Order
|
|
141
|
-
|
|
142
|
-
```tsx
|
|
143
|
-
// 1. React and framework
|
|
144
|
-
import { useState, useEffect } from 'react';
|
|
145
|
-
import { useNavigate } from 'react-router-dom';
|
|
146
|
-
|
|
147
|
-
// 2. Third-party libraries (Ant Design first)
|
|
148
|
-
import { Button, Card, Input } from 'antd';
|
|
149
|
-
import { useQuery } from '@tanstack/react-query';
|
|
150
|
-
|
|
151
|
-
// 3. Styles
|
|
152
|
-
import './ResourceCard.css'; // or .module.css
|
|
153
|
-
|
|
154
|
-
// 4. Local components
|
|
155
|
-
import { ResourceCard } from '../components/ResourceCard';
|
|
156
|
-
|
|
157
|
-
// 5. Hooks
|
|
158
|
-
import { useAuth } from '@/features/auth/hooks/useAuth';
|
|
159
|
-
import { useResources } from '../hooks/useResources';
|
|
160
|
-
|
|
161
|
-
// 6. Services
|
|
162
|
-
import { resourceService } from '../services/resource.service';
|
|
163
|
-
|
|
164
|
-
// 7. Types (always use 'type' keyword)
|
|
165
|
-
import type { Resource } from '../types/resource.types';
|
|
166
|
-
|
|
167
|
-
// 8. Utils
|
|
168
|
-
import { formatDate } from '@/lib/utils/format';
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
## Constants Structure
|
|
172
|
-
|
|
173
|
-
### API Endpoints
|
|
174
|
-
|
|
175
|
-
```tsx
|
|
176
|
-
// lib/constants/api-endpoints.ts
|
|
177
|
-
export const API_ENDPOINTS = {
|
|
178
|
-
AUTH: {
|
|
179
|
-
REGISTER: '/auth/register',
|
|
180
|
-
LOGIN: '/auth/login',
|
|
181
|
-
LOGOUT: '/auth/logout',
|
|
182
|
-
REFRESH: '/auth/refresh',
|
|
183
|
-
ME: '/auth/me',
|
|
184
|
-
VERIFY_EMAIL: '/auth/verify-email',
|
|
185
|
-
RESEND_VERIFICATION: '/auth/resend-verification',
|
|
186
|
-
REQUEST_PASSWORD_RESET: '/auth/request-password-reset',
|
|
187
|
-
RESET_PASSWORD: '/auth/reset-password',
|
|
188
|
-
},
|
|
189
|
-
USERS: {
|
|
190
|
-
ME: '/users/me',
|
|
191
|
-
UPDATE_ME: '/users/me',
|
|
192
|
-
DELETE_ME: '/users/me',
|
|
193
|
-
},
|
|
194
|
-
RESOURCES: {
|
|
195
|
-
LIST: '/resources',
|
|
196
|
-
MY_RESOURCES: '/resources/my',
|
|
197
|
-
CREATE: '/resources',
|
|
198
|
-
GET: (id: string) => `/resources/${id}`,
|
|
199
|
-
UPDATE: (id: string) => `/resources/${id}`,
|
|
200
|
-
DELETE: (id: string) => `/resources/${id}`,
|
|
201
|
-
},
|
|
202
|
-
} as const;
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
### Routes
|
|
206
|
-
|
|
207
|
-
```tsx
|
|
208
|
-
// lib/constants/routes.ts
|
|
209
|
-
export const ROUTES = {
|
|
210
|
-
HOME: '/',
|
|
211
|
-
LOGIN: '/login',
|
|
212
|
-
REGISTER: '/register',
|
|
213
|
-
VERIFY_EMAIL: '/verify-email',
|
|
214
|
-
RESET_PASSWORD: '/reset-password',
|
|
215
|
-
DASHBOARD: '/dashboard',
|
|
216
|
-
PROFILE: '/profile',
|
|
217
|
-
RESOURCES: {
|
|
218
|
-
LIST: '/resources',
|
|
219
|
-
DETAILS: (id: string) => `/resources/${id}`,
|
|
220
|
-
MY_RESOURCES: '/my-resources',
|
|
221
|
-
CREATE: '/resources/create',
|
|
222
|
-
EDIT: (id: string) => `/resources/${id}/edit`,
|
|
223
|
-
},
|
|
224
|
-
} as const;
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
### App Constants
|
|
228
|
-
|
|
229
|
-
```tsx
|
|
230
|
-
// lib/constants/app.constants.ts
|
|
231
|
-
export const APP_NAME = 'My Application';
|
|
232
|
-
|
|
233
|
-
export const PAGINATION = {
|
|
234
|
-
DEFAULT_PAGE: 1,
|
|
235
|
-
DEFAULT_LIMIT: 10,
|
|
236
|
-
MAX_LIMIT: 100,
|
|
237
|
-
} as const;
|
|
238
|
-
|
|
239
|
-
export const USER_ROLES = {
|
|
240
|
-
USER: 'USER',
|
|
241
|
-
ORG: 'ORGANIZATION',
|
|
242
|
-
ADMIN: 'ADMIN',
|
|
243
|
-
} as const;
|
|
244
|
-
|
|
245
|
-
export const CURRENCIES = {
|
|
246
|
-
GEL: 'GEL',
|
|
247
|
-
USD: 'USD',
|
|
248
|
-
EUR: 'EUR',
|
|
249
|
-
} as const;
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
## Naming Conventions
|
|
253
|
-
|
|
254
|
-
### Variables
|
|
255
|
-
- **camelCase**: `userName`, `resourceList`, `isLoading`
|
|
256
|
-
|
|
257
|
-
### Functions
|
|
258
|
-
- **camelCase**: `getUserData()`, `handleSubmit()`, `formatPrice()`
|
|
259
|
-
|
|
260
|
-
### Constants
|
|
261
|
-
- **UPPER_SNAKE_CASE**: `API_BASE_URL`, `MAX_FILE_SIZE`
|
|
262
|
-
|
|
263
|
-
### Types/Interfaces
|
|
264
|
-
- **PascalCase**: `User`, `Resource`, `ResourceFilters`
|
|
265
|
-
- **Interface prefix**: `IUser`, `IResource` (optional, be consistent)
|
|
266
|
-
|
|
267
|
-
### Enums/Type Unions
|
|
268
|
-
- **PascalCase**: `UserRole`, `ResourceStatus`
|
|
269
|
-
|
|
270
|
-
## Export Patterns
|
|
271
|
-
|
|
272
|
-
### Named Exports (Preferred)
|
|
273
|
-
```tsx
|
|
274
|
-
// ✅ GOOD
|
|
275
|
-
export const ResourceCard = () => {};
|
|
276
|
-
export const ResourceList = () => {};
|
|
277
|
-
|
|
278
|
-
// Import
|
|
279
|
-
import { ResourceCard, ResourceList } from './components';
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### Default Export (Only for app.ts)
|
|
283
|
-
```tsx
|
|
284
|
-
// ❌ AVOID for components
|
|
285
|
-
export default ResourceCard;
|
|
286
|
-
|
|
287
|
-
// ✅ OK for App
|
|
288
|
-
export default App;
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
### Barrel Exports
|
|
292
|
-
```tsx
|
|
293
|
-
// features/resources/index.ts
|
|
294
|
-
export { ResourceCard } from './components/ResourceCard';
|
|
295
|
-
export { ResourceList } from './components/ResourceList';
|
|
296
|
-
export { useResources } from './hooks/useResources';
|
|
297
|
-
export { resourceService } from './services/resource.service';
|
|
298
|
-
export type * from './types/resource.types';
|
|
299
|
-
|
|
300
|
-
// Usage
|
|
301
|
-
import { ResourceCard, useResources, resourceService } from '@/features/resources';
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
## Environment Variables
|
|
305
|
-
|
|
306
|
-
```env
|
|
307
|
-
# .env.development
|
|
308
|
-
VITE_API_BASE_URL=http://localhost:3000/api/v1
|
|
309
|
-
VITE_APP_NAME=My Application
|
|
310
|
-
|
|
311
|
-
# .env.production
|
|
312
|
-
VITE_API_BASE_URL=https://api.myapplication.com/api/v1
|
|
313
|
-
VITE_APP_NAME=My Application
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
**Rules:**
|
|
317
|
-
- Prefix with `VITE_` to expose to client
|
|
318
|
-
- Never commit `.env` files
|
|
319
|
-
- Always provide `.env.example`
|
|
320
|
-
|
|
321
|
-
```tsx
|
|
322
|
-
// Accessing env variables
|
|
323
|
-
const apiUrl = import.meta.env.VITE_API_BASE_URL;
|
|
324
|
-
const isDev = import.meta.env.DEV;
|
|
325
|
-
const isProd = import.meta.env.PROD;
|
|
326
|
-
```
|