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.
Files changed (243) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +80 -87
  3. package/bin/create-tigra.js +259 -308
  4. package/package.json +49 -41
  5. package/template/_claude/QUICK_REFERENCE.md +193 -0
  6. package/template/_claude/README.md +53 -0
  7. package/template/_claude/commands/create-client.md +881 -0
  8. package/template/_claude/commands/create-server.md +383 -0
  9. package/template/_claude/rules/client/01-project-structure.md +133 -0
  10. package/template/_claude/rules/client/02-components-and-types.md +146 -0
  11. package/template/_claude/rules/client/03-data-and-state.md +156 -0
  12. package/template/_claude/rules/client/04-design-system.md +185 -0
  13. package/template/_claude/rules/client/05-security.md +55 -0
  14. package/template/_claude/rules/client/06-ux-checklist.md +81 -0
  15. package/template/_claude/rules/client/core.md +42 -0
  16. package/template/_claude/rules/global/core.md +77 -0
  17. package/template/_claude/rules/server/core.md +50 -0
  18. package/template/_claude/rules/server/database.md +124 -0
  19. package/template/_claude/rules/server/project-conventions.md +150 -0
  20. package/template/_claude/rules/server/response-handling.md +144 -0
  21. package/template/client/.env.example +5 -0
  22. package/template/client/README.md +36 -0
  23. package/template/client/components.json +23 -0
  24. package/template/client/eslint.config.mjs +18 -0
  25. package/template/client/next.config.ts +34 -0
  26. package/template/client/package.json +44 -0
  27. package/template/client/postcss.config.mjs +7 -0
  28. package/template/client/src/app/(auth)/layout.tsx +18 -0
  29. package/template/client/src/app/(auth)/login/page.tsx +13 -0
  30. package/template/client/src/app/(auth)/register/page.tsx +13 -0
  31. package/template/client/src/app/(main)/dashboard/page.tsx +22 -0
  32. package/template/client/src/app/(main)/layout.tsx +11 -0
  33. package/template/client/src/app/error.tsx +27 -0
  34. package/template/client/src/app/favicon.ico +0 -0
  35. package/template/client/src/app/globals.css +145 -0
  36. package/template/client/src/app/layout.tsx +36 -0
  37. package/template/client/src/app/loading.tsx +11 -0
  38. package/template/client/src/app/not-found.tsx +23 -0
  39. package/template/client/src/app/page.tsx +45 -0
  40. package/template/client/src/app/providers.tsx +43 -0
  41. package/template/client/src/components/common/ConfirmDialog.tsx +56 -0
  42. package/template/client/src/components/common/EmptyState.tsx +31 -0
  43. package/template/client/src/components/common/LoadingSpinner.tsx +30 -0
  44. package/template/client/src/components/common/Pagination.tsx +55 -0
  45. package/template/client/src/components/layout/Footer.tsx +17 -0
  46. package/template/client/src/components/layout/Header.tsx +173 -0
  47. package/template/client/src/components/layout/MainLayout.tsx +18 -0
  48. package/template/client/src/components/ui/alert-dialog.tsx +196 -0
  49. package/template/client/src/components/ui/badge.tsx +48 -0
  50. package/template/client/src/components/ui/button.tsx +64 -0
  51. package/template/client/src/components/ui/card.tsx +92 -0
  52. package/template/client/src/components/ui/input.tsx +21 -0
  53. package/template/client/src/components/ui/label.tsx +24 -0
  54. package/template/client/src/components/ui/select.tsx +190 -0
  55. package/template/client/src/components/ui/skeleton.tsx +13 -0
  56. package/template/client/src/components/ui/table.tsx +116 -0
  57. package/template/client/src/features/auth/components/AuthInitializer.tsx +55 -0
  58. package/template/client/src/features/auth/components/LoginForm.tsx +107 -0
  59. package/template/client/src/features/auth/components/RegisterForm.tsx +178 -0
  60. package/template/client/src/features/auth/hooks/useAuth.ts +84 -0
  61. package/template/client/src/features/auth/services/auth.service.ts +52 -0
  62. package/template/client/src/features/auth/store/authSlice.ts +38 -0
  63. package/template/client/src/features/auth/types/auth.types.ts +32 -0
  64. package/template/client/src/hooks/useDebounce.ts +14 -0
  65. package/template/client/src/hooks/useLocalStorage.ts +55 -0
  66. package/template/client/src/hooks/useMediaQuery.ts +27 -0
  67. package/template/client/src/lib/api/api.types.ts +34 -0
  68. package/template/client/src/lib/api/axios.config.ts +98 -0
  69. package/template/client/src/lib/constants/api-endpoints.ts +18 -0
  70. package/template/client/src/lib/constants/app.constants.ts +12 -0
  71. package/template/client/src/lib/constants/routes.ts +9 -0
  72. package/template/client/src/lib/utils/error.ts +32 -0
  73. package/template/client/src/lib/utils/format.ts +37 -0
  74. package/template/client/src/lib/utils/security.ts +34 -0
  75. package/template/client/src/lib/utils.ts +6 -0
  76. package/template/client/src/middleware.ts +57 -0
  77. package/template/client/src/store/hooks.ts +7 -0
  78. package/template/client/src/store/index.ts +12 -0
  79. package/template/client/src/types/index.ts +3 -0
  80. package/template/client/tsconfig.json +34 -0
  81. package/template/gitignore +34 -0
  82. package/template/server/.dockerignore +66 -0
  83. package/template/server/.env.example +96 -69
  84. package/template/server/.env.production.example +90 -0
  85. package/template/server/Dockerfile +94 -0
  86. package/template/server/docker-compose.yml +82 -111
  87. package/template/server/docs/logging.md +62 -0
  88. package/template/server/eslint.config.mjs +17 -0
  89. package/template/server/package.json +68 -81
  90. package/template/server/phpmyadmin-config.php +26 -0
  91. package/template/server/postman_collection.json +666 -0
  92. package/template/server/prisma/schema.prisma +77 -93
  93. package/template/server/prisma/seed.ts +46 -142
  94. package/template/server/scripts/flush-redis.ts +41 -0
  95. package/template/server/src/app.ts +243 -71
  96. package/template/server/src/config/env.ts +67 -94
  97. package/template/server/src/libs/auth.ts +88 -0
  98. package/template/server/src/libs/cleanup.ts +35 -0
  99. package/template/server/src/libs/cookies.ts +46 -0
  100. package/template/server/src/libs/logger.ts +33 -60
  101. package/template/server/src/libs/monitoring.ts +205 -0
  102. package/template/server/src/libs/password.ts +38 -0
  103. package/template/server/src/libs/prisma.ts +68 -0
  104. package/template/server/src/libs/redis.ts +60 -79
  105. package/template/server/src/libs/requestLogger.ts +66 -0
  106. package/template/server/src/libs/storage/file-storage.service.ts +211 -0
  107. package/template/server/src/libs/storage/file-validator.ts +97 -0
  108. package/template/server/src/libs/storage/filename-sanitizer.ts +71 -0
  109. package/template/server/src/libs/storage/image-optimizer.service.ts +144 -0
  110. package/template/server/src/modules/auth/__tests__/auth.service.test.ts +365 -0
  111. package/template/server/src/modules/auth/auth.controller.ts +90 -141
  112. package/template/server/src/modules/auth/auth.repo.ts +120 -218
  113. package/template/server/src/modules/auth/auth.routes.ts +96 -83
  114. package/template/server/src/modules/auth/auth.schemas.ts +35 -137
  115. package/template/server/src/modules/auth/auth.service.ts +286 -329
  116. package/template/server/src/modules/auth/session.repo.ts +110 -0
  117. package/template/server/src/modules/users/users.controller.ts +120 -0
  118. package/template/server/src/modules/users/users.repo.ts +77 -0
  119. package/template/server/src/modules/users/users.routes.ts +89 -0
  120. package/template/server/src/modules/users/users.schemas.ts +21 -0
  121. package/template/server/src/modules/users/users.service.ts +169 -0
  122. package/template/server/src/server.ts +58 -139
  123. package/template/server/src/shared/errors/AppError.ts +21 -0
  124. package/template/server/src/shared/errors/errors.ts +43 -0
  125. package/template/server/src/shared/responses/paginatedResponse.ts +38 -0
  126. package/template/server/src/shared/responses/successResponse.ts +17 -0
  127. package/template/server/src/shared/schemas/pagination.schema.ts +12 -0
  128. package/template/server/src/shared/types/index.ts +26 -0
  129. package/template/server/src/test/setup.ts +74 -38
  130. package/template/server/tsconfig.json +27 -89
  131. package/template/server/uploads/avatars/.gitkeep +1 -0
  132. package/template/server/vitest.config.ts +43 -98
  133. package/template/.agent/rules/client/01-project-structure.md +0 -326
  134. package/template/.agent/rules/client/02-component-patterns.md +0 -249
  135. package/template/.agent/rules/client/03-typescript-rules.md +0 -226
  136. package/template/.agent/rules/client/04-state-management.md +0 -474
  137. package/template/.agent/rules/client/05-api-integration.md +0 -129
  138. package/template/.agent/rules/client/06-forms-validation.md +0 -129
  139. package/template/.agent/rules/client/07-common-patterns.md +0 -150
  140. package/template/.agent/rules/client/08-color-system.md +0 -93
  141. package/template/.agent/rules/client/09-security-rules.md +0 -97
  142. package/template/.agent/rules/client/10-testing-strategy.md +0 -370
  143. package/template/.agent/rules/global/ai-edit-safety.md +0 -38
  144. package/template/.agent/rules/server/01-db-and-migrations.md +0 -242
  145. package/template/.agent/rules/server/02-general-rules.md +0 -111
  146. package/template/.agent/rules/server/03-migrations.md +0 -20
  147. package/template/.agent/rules/server/04-pagination.md +0 -130
  148. package/template/.agent/rules/server/05-project-conventions.md +0 -71
  149. package/template/.agent/rules/server/06-response-handling.md +0 -173
  150. package/template/.agent/rules/server/07-testing-strategy.md +0 -506
  151. package/template/.agent/rules/server/08-observability.md +0 -180
  152. package/template/.agent/rules/server/10-background-jobs-v2.md +0 -185
  153. package/template/.agent/rules/server/11-rate-limiting-v2.md +0 -210
  154. package/template/.agent/rules/server/12-performance-optimization.md +0 -567
  155. package/template/.claude/rules/client-01-project-structure.md +0 -327
  156. package/template/.claude/rules/client-02-component-patterns.md +0 -250
  157. package/template/.claude/rules/client-03-typescript-rules.md +0 -227
  158. package/template/.claude/rules/client-04-state-management.md +0 -475
  159. package/template/.claude/rules/client-05-api-integration.md +0 -130
  160. package/template/.claude/rules/client-06-forms-validation.md +0 -130
  161. package/template/.claude/rules/client-07-common-patterns.md +0 -151
  162. package/template/.claude/rules/client-08-color-system.md +0 -94
  163. package/template/.claude/rules/client-09-security-rules.md +0 -98
  164. package/template/.claude/rules/client-10-testing-strategy.md +0 -371
  165. package/template/.claude/rules/global-ai-edit-safety.md +0 -39
  166. package/template/.claude/rules/server-01-db-and-migrations.md +0 -243
  167. package/template/.claude/rules/server-02-general-rules.md +0 -112
  168. package/template/.claude/rules/server-03-migrations.md +0 -21
  169. package/template/.claude/rules/server-04-pagination.md +0 -131
  170. package/template/.claude/rules/server-05-project-conventions.md +0 -72
  171. package/template/.claude/rules/server-06-response-handling.md +0 -174
  172. package/template/.claude/rules/server-07-testing-strategy.md +0 -507
  173. package/template/.claude/rules/server-08-observability.md +0 -181
  174. package/template/.claude/rules/server-10-background-jobs-v2.md +0 -186
  175. package/template/.claude/rules/server-11-rate-limiting-v2.md +0 -211
  176. package/template/.claude/rules/server-12-performance-optimization.md +0 -568
  177. package/template/.cursor/rules/client-01-project-structure.mdc +0 -327
  178. package/template/.cursor/rules/client-02-component-patterns.mdc +0 -250
  179. package/template/.cursor/rules/client-03-typescript-rules.mdc +0 -227
  180. package/template/.cursor/rules/client-04-state-management.mdc +0 -475
  181. package/template/.cursor/rules/client-05-api-integration.mdc +0 -130
  182. package/template/.cursor/rules/client-06-forms-validation.mdc +0 -130
  183. package/template/.cursor/rules/client-07-common-patterns.mdc +0 -151
  184. package/template/.cursor/rules/client-08-color-system.mdc +0 -94
  185. package/template/.cursor/rules/client-09-security-rules.mdc +0 -98
  186. package/template/.cursor/rules/client-10-testing-strategy.mdc +0 -371
  187. package/template/.cursor/rules/global-ai-edit-safety.mdc +0 -39
  188. package/template/.cursor/rules/server-01-db-and-migrations.mdc +0 -243
  189. package/template/.cursor/rules/server-02-general-rules.mdc +0 -112
  190. package/template/.cursor/rules/server-03-migrations.mdc +0 -21
  191. package/template/.cursor/rules/server-04-pagination.mdc +0 -131
  192. package/template/.cursor/rules/server-05-project-conventions.mdc +0 -72
  193. package/template/.cursor/rules/server-06-response-handling.mdc +0 -174
  194. package/template/.cursor/rules/server-07-testing-strategy.mdc +0 -507
  195. package/template/.cursor/rules/server-08-observability.mdc +0 -181
  196. package/template/.cursor/rules/server-09-api-documentation-v2.mdc +0 -169
  197. package/template/.cursor/rules/server-10-background-jobs-v2.mdc +0 -186
  198. package/template/.cursor/rules/server-11-rate-limiting-v2.mdc +0 -211
  199. package/template/.cursor/rules/server-12-performance-optimization.mdc +0 -568
  200. package/template/CLAUDE.md +0 -207
  201. package/template/server/.tsc-aliasrc.json +0 -13
  202. package/template/server/IMPORT_FIX_CHECKLIST.md +0 -98
  203. package/template/server/IMPORT_FIX_COMPLETE.md +0 -89
  204. package/template/server/README.md +0 -183
  205. package/template/server/REMAINING_IMPORT_FIXES.md +0 -150
  206. package/template/server/SECURITY.md +0 -190
  207. package/template/server/Tigra-API.postman_collection.json +0 -733
  208. package/template/server/biome.json +0 -42
  209. package/template/server/scripts/fix-all-imports.ps1 +0 -52
  210. package/template/server/scripts/fix-imports-reference.ps1 +0 -16
  211. package/template/server/scripts/fix-imports.mjs +0 -55
  212. package/template/server/scripts/setup-env.js +0 -50
  213. package/template/server/scripts/wait-for-db.js +0 -60
  214. package/template/server/src/hooks/request-timing.hook.ts +0 -26
  215. package/template/server/src/libs/auth/authenticate.middleware.ts +0 -22
  216. package/template/server/src/libs/auth/rbac.middleware.test.ts +0 -134
  217. package/template/server/src/libs/auth/rbac.middleware.ts +0 -147
  218. package/template/server/src/libs/db.ts +0 -76
  219. package/template/server/src/libs/error-handler.ts +0 -89
  220. package/template/server/src/libs/queue.ts +0 -79
  221. package/template/server/src/modules/admin/admin.controller.ts +0 -122
  222. package/template/server/src/modules/admin/admin.routes.ts +0 -62
  223. package/template/server/src/modules/admin/admin.schemas.ts +0 -35
  224. package/template/server/src/modules/admin/admin.service.ts +0 -167
  225. package/template/server/src/modules/auth/auth.integration.test.ts +0 -150
  226. package/template/server/src/modules/auth/auth.service.test.ts +0 -119
  227. package/template/server/src/modules/auth/auth.types.ts +0 -97
  228. package/template/server/src/modules/resources/resources.controller.ts +0 -218
  229. package/template/server/src/modules/resources/resources.repo.ts +0 -253
  230. package/template/server/src/modules/resources/resources.routes.ts +0 -116
  231. package/template/server/src/modules/resources/resources.schemas.ts +0 -146
  232. package/template/server/src/modules/resources/resources.service.ts +0 -218
  233. package/template/server/src/modules/resources/resources.types.ts +0 -73
  234. package/template/server/src/plugins/rate-limit.plugin.ts +0 -21
  235. package/template/server/src/plugins/security.plugin.ts +0 -21
  236. package/template/server/src/routes/health.routes.ts +0 -31
  237. package/template/server/src/types/fastify.d.ts +0 -36
  238. package/template/server/src/utils/errors.ts +0 -108
  239. package/template/server/src/utils/pagination.ts +0 -120
  240. package/template/server/src/utils/response.ts +0 -110
  241. package/template/server/src/workers/file.worker.ts +0 -106
  242. package/template/server/tsconfig.build.json +0 -30
  243. package/template/server/tsconfig.test.json +0 -22
@@ -1,327 +0,0 @@
1
- ---
2
- trigger: always_on
3
- globs: "client/**/*"
4
- ---
5
-
6
- > **SCOPE**: These rules apply specifically to the **client** directory.
7
-
8
- # Project Structure & File Naming
9
-
10
- ## Folder Structure
11
-
12
- ```
13
- src/
14
- ├── app/ # App configuration
15
- │ ├── App.tsx
16
- │ ├── router.tsx
17
- │ └── providers.tsx
18
- ├── components/
19
- │ ├── layout/ # Header, Footer, MainLayout
20
- │ │ ├── Header.tsx
21
- │ │ ├── Footer.tsx
22
- │ │ ├── Sidebar.tsx
23
- │ │ └── MainLayout.tsx
24
- │ └── common/ # Shared components
25
- │ ├── LoadingSpinner.tsx
26
- │ ├── ErrorBoundary.tsx
27
- │ ├── ProtectedRoute.tsx
28
- │ ├── Pagination.tsx
29
- │ └── EmptyState.tsx
30
- ├── features/ # Feature modules (domain-driven)
31
- │ ├── auth/
32
- │ │ ├── components/ # LoginForm, RegisterForm
33
- │ │ ├── hooks/ # useAuth, useLogin, useRegister
34
- │ │ ├── pages/ # LoginPage, RegisterPage
35
- │ │ ├── services/ # auth.service.ts
36
- │ │ ├── store/ # authSlice.ts (Redux)
37
- │ │ ├── types/ # auth.types.ts
38
- │ │ └── utils/ # auth.utils.ts
39
- │ ├── resources/ # Example feature
40
- │ │ ├── components/
41
- │ │ ├── hooks/
42
- │ │ ├── pages/
43
- │ │ ├── services/
44
- │ │ ├── types/
45
- │ │ └── utils/
46
- │ └── users/
47
- ├── hooks/ # Global custom hooks
48
- │ ├── useDebounce.ts
49
- │ ├── useLocalStorage.ts
50
- │ └── useMediaQuery.ts
51
- ├── lib/
52
- │ ├── api/
53
- │ │ ├── axios.config.ts
54
- │ │ └── api.types.ts
55
- │ ├── constants/
56
- │ │ ├── routes.ts
57
- │ │ ├── api-endpoints.ts
58
- │ │ └── app.constants.ts
59
- │ └── utils/
60
- │ ├── format.ts
61
- │ ├── validation.ts
62
- │ └── error.ts
63
- ├── store/ # Redux store
64
- │ ├── index.ts
65
- │ └── hooks.ts
66
- ├── types/ # Global types
67
- │ ├── index.ts
68
- │ └── api.types.ts
69
- └── styles/
70
- ├── globals.css # Global CSS
71
- └── theme.css # Ant Design custom theme (if needed)
72
- ```
73
-
74
- ## File Naming Rules
75
-
76
- ### Components
77
- - **PascalCase**: `ResourceCard.tsx`, `LoginForm.tsx`
78
- - **Pattern**: `<ComponentName>.tsx`
79
- - **CSS**: If using CSS Modules, name as `<ComponentName>.module.css`
80
-
81
- ### Pages
82
- - **PascalCase + Page suffix**: `ResourcesPage.tsx`, `LoginPage.tsx`
83
- - **Pattern**: `<FeatureName>Page.tsx`
84
-
85
- ### Hooks
86
- - **camelCase + use prefix**: `useAuth.ts`, `useResources.ts`
87
- - **Pattern**: `use<HookName>.ts`
88
-
89
- ### Services
90
- - **camelCase + .service suffix**: `auth.service.ts`, `resource.service.ts`
91
- - **Pattern**: `<domain>.service.ts`
92
-
93
- ### Types
94
- - **camelCase + .types suffix**: `auth.types.ts`, `resource.types.ts`
95
- - **Pattern**: `<domain>.types.ts`
96
-
97
- ### Store (Redux)
98
- - **camelCase + Slice suffix**: `authSlice.ts`, `resourceSlice.ts`
99
- - **Pattern**: `<domain>Slice.ts`
100
-
101
- ### Utils
102
- - **camelCase + .utils suffix**: `auth.utils.ts`, `date.utils.ts`
103
- - **Pattern**: `<purpose>.utils.ts`
104
-
105
- ### Constants
106
- - **camelCase**: `routes.ts`, `api-endpoints.ts`, `app.constants.ts`
107
-
108
- ## Module Structure Pattern
109
-
110
- Every feature module follows this pattern:
111
-
112
- ```
113
- features/<domain>/
114
- ├── components/ # Feature-specific components
115
- ├── hooks/ # Feature-specific hooks
116
- ├── pages/ # Feature pages (routes)
117
- ├── services/ # API service
118
- ├── store/ # Redux slice (if needed)
119
- ├── types/ # TypeScript types
120
- └── utils/ # Feature utilities
121
- ```
122
-
123
- ## Import Path Aliases
124
-
125
- ```json
126
- // tsconfig.json & vite.config.ts
127
- {
128
- "paths": {
129
- "@/*": ["./src/*"],
130
- "@/components/*": ["./src/components/*"],
131
- "@/features/*": ["./src/features/*"],
132
- "@/lib/*": ["./src/lib/*"],
133
- "@/hooks/*": ["./src/hooks/*"],
134
- "@/store/*": ["./src/store/*"],
135
- "@/types/*": ["./src/types/*"],
136
- "@/styles/*": ["./src/styles/*"]
137
- }
138
- }
139
- ```
140
-
141
- ## Import Order
142
-
143
- ```tsx
144
- // 1. React and framework
145
- import { useState, useEffect } from 'react';
146
- import { useNavigate } from 'react-router-dom';
147
-
148
- // 2. Third-party libraries (Ant Design first)
149
- import { Button, Card, Input } from 'antd';
150
- import { useQuery } from '@tanstack/react-query';
151
-
152
- // 3. Styles
153
- import './ResourceCard.css'; // or .module.css
154
-
155
- // 4. Local components
156
- import { ResourceCard } from '../components/ResourceCard';
157
-
158
- // 5. Hooks
159
- import { useAuth } from '@/features/auth/hooks/useAuth';
160
- import { useResources } from '../hooks/useResources';
161
-
162
- // 6. Services
163
- import { resourceService } from '../services/resource.service';
164
-
165
- // 7. Types (always use 'type' keyword)
166
- import type { Resource } from '../types/resource.types';
167
-
168
- // 8. Utils
169
- import { formatDate } from '@/lib/utils/format';
170
- ```
171
-
172
- ## Constants Structure
173
-
174
- ### API Endpoints
175
-
176
- ```tsx
177
- // lib/constants/api-endpoints.ts
178
- export const API_ENDPOINTS = {
179
- AUTH: {
180
- REGISTER: '/auth/register',
181
- LOGIN: '/auth/login',
182
- LOGOUT: '/auth/logout',
183
- REFRESH: '/auth/refresh',
184
- ME: '/auth/me',
185
- VERIFY_EMAIL: '/auth/verify-email',
186
- RESEND_VERIFICATION: '/auth/resend-verification',
187
- REQUEST_PASSWORD_RESET: '/auth/request-password-reset',
188
- RESET_PASSWORD: '/auth/reset-password',
189
- },
190
- USERS: {
191
- ME: '/users/me',
192
- UPDATE_ME: '/users/me',
193
- DELETE_ME: '/users/me',
194
- },
195
- RESOURCES: {
196
- LIST: '/resources',
197
- MY_RESOURCES: '/resources/my',
198
- CREATE: '/resources',
199
- GET: (id: string) => `/resources/${id}`,
200
- UPDATE: (id: string) => `/resources/${id}`,
201
- DELETE: (id: string) => `/resources/${id}`,
202
- },
203
- } as const;
204
- ```
205
-
206
- ### Routes
207
-
208
- ```tsx
209
- // lib/constants/routes.ts
210
- export const ROUTES = {
211
- HOME: '/',
212
- LOGIN: '/login',
213
- REGISTER: '/register',
214
- VERIFY_EMAIL: '/verify-email',
215
- RESET_PASSWORD: '/reset-password',
216
- DASHBOARD: '/dashboard',
217
- PROFILE: '/profile',
218
- RESOURCES: {
219
- LIST: '/resources',
220
- DETAILS: (id: string) => `/resources/${id}`,
221
- MY_RESOURCES: '/my-resources',
222
- CREATE: '/resources/create',
223
- EDIT: (id: string) => `/resources/${id}/edit`,
224
- },
225
- } as const;
226
- ```
227
-
228
- ### App Constants
229
-
230
- ```tsx
231
- // lib/constants/app.constants.ts
232
- export const APP_NAME = 'My Application';
233
-
234
- export const PAGINATION = {
235
- DEFAULT_PAGE: 1,
236
- DEFAULT_LIMIT: 10,
237
- MAX_LIMIT: 100,
238
- } as const;
239
-
240
- export const USER_ROLES = {
241
- USER: 'USER',
242
- ORG: 'ORGANIZATION',
243
- ADMIN: 'ADMIN',
244
- } as const;
245
-
246
- export const CURRENCIES = {
247
- GEL: 'GEL',
248
- USD: 'USD',
249
- EUR: 'EUR',
250
- } as const;
251
- ```
252
-
253
- ## Naming Conventions
254
-
255
- ### Variables
256
- - **camelCase**: `userName`, `resourceList`, `isLoading`
257
-
258
- ### Functions
259
- - **camelCase**: `getUserData()`, `handleSubmit()`, `formatPrice()`
260
-
261
- ### Constants
262
- - **UPPER_SNAKE_CASE**: `API_BASE_URL`, `MAX_FILE_SIZE`
263
-
264
- ### Types/Interfaces
265
- - **PascalCase**: `User`, `Resource`, `ResourceFilters`
266
- - **Interface prefix**: `IUser`, `IResource` (optional, be consistent)
267
-
268
- ### Enums/Type Unions
269
- - **PascalCase**: `UserRole`, `ResourceStatus`
270
-
271
- ## Export Patterns
272
-
273
- ### Named Exports (Preferred)
274
- ```tsx
275
- // ✅ GOOD
276
- export const ResourceCard = () => {};
277
- export const ResourceList = () => {};
278
-
279
- // Import
280
- import { ResourceCard, ResourceList } from './components';
281
- ```
282
-
283
- ### Default Export (Only for app.ts)
284
- ```tsx
285
- // ❌ AVOID for components
286
- export default ResourceCard;
287
-
288
- // ✅ OK for App
289
- export default App;
290
- ```
291
-
292
- ### Barrel Exports
293
- ```tsx
294
- // features/resources/index.ts
295
- export { ResourceCard } from './components/ResourceCard';
296
- export { ResourceList } from './components/ResourceList';
297
- export { useResources } from './hooks/useResources';
298
- export { resourceService } from './services/resource.service';
299
- export type * from './types/resource.types';
300
-
301
- // Usage
302
- import { ResourceCard, useResources, resourceService } from '@/features/resources';
303
- ```
304
-
305
- ## Environment Variables
306
-
307
- ```env
308
- # .env.development
309
- VITE_API_BASE_URL=http://localhost:3000/api/v1
310
- VITE_APP_NAME=My Application
311
-
312
- # .env.production
313
- VITE_API_BASE_URL=https://api.myapplication.com/api/v1
314
- VITE_APP_NAME=My Application
315
- ```
316
-
317
- **Rules:**
318
- - Prefix with `VITE_` to expose to client
319
- - Never commit `.env` files
320
- - Always provide `.env.example`
321
-
322
- ```tsx
323
- // Accessing env variables
324
- const apiUrl = import.meta.env.VITE_API_BASE_URL;
325
- const isDev = import.meta.env.DEV;
326
- const isProd = import.meta.env.PROD;
327
- ```
@@ -1,250 +0,0 @@
1
- ---
2
- trigger: always_on
3
- globs: "client/**/*"
4
- ---
5
-
6
- > **SCOPE**: These rules apply specifically to the **client** directory.
7
-
8
- # Component Patterns & Rules
9
-
10
- ## Component Structure Template
11
-
12
- ```tsx
13
- // 1. IMPORTS (grouped and ordered)
14
- import { useState, useCallback, useEffect } from 'react';
15
- import { useNavigate } from 'react-router-dom';
16
- import { Button, Card } from 'antd'; // Ant Design
17
- import { useResources } from '../hooks/useResources';
18
- import type { Resource } from '../types/resource.types';
19
-
20
- // Import CSS (Vanilla or Module)
21
- import './ResourceCard.css';
22
-
23
- // 2. TYPES (component-specific only)
24
- interface ResourceCardProps {
25
- resource: Resource;
26
- onEdit?: (id: string) => void;
27
- className?: string; // Standard className prop for custom styles
28
- }
29
-
30
- // 3. COMPONENT
31
- export const ResourceCard = ({ resource, onEdit, className }: ResourceCardProps) => {
32
- // 3a. HOOKS (router → Redux → React Query → state → custom)
33
- const navigate = useNavigate();
34
- const [isHovered, setIsHovered] = useState(false);
35
-
36
- // 3b. EVENT HANDLERS
37
- const handleClick = useCallback(() => {
38
- navigate(`/resources/${resource.id}`);
39
- }, [navigate, resource.id]);
40
-
41
- // 3c. EFFECTS
42
- useEffect(() => {
43
- // Side effects
44
- }, []);
45
-
46
- // 3d. EARLY RETURNS
47
- if (!resource) return null;
48
-
49
- // 3e. RENDER
50
- return (
51
- <Card
52
- className={`resource-card ${className || ''}`}
53
- onClick={handleClick}
54
- hoverable
55
- >
56
- <h3>{resource.title}</h3>
57
- {/* JSX */}
58
- </Card>
59
- );
60
- };
61
- ```
62
-
63
- ## Component Types
64
-
65
- ### 1. Presentational Components
66
- **Location**: `components/common/` or `features/*/components/`
67
-
68
- **Rules**:
69
- - NO business logic
70
- - NO API calls
71
- - NO Redux/Context (except theme)
72
- - Receive ALL data via props
73
- - Focus ONLY on UI
74
-
75
- ```tsx
76
- // ✅ GOOD - Pure presentation
77
- interface ResourceCardProps {
78
- resource: Resource;
79
- onClick: (id: string) => void;
80
- }
81
-
82
- export const ResourceCard = ({ resource, onClick }: ResourceCardProps) => {
83
- return (
84
- <div className="card-container" onClick={() => onClick(resource.id)}>
85
- <h3>{resource.title}</h3>
86
- <p>{resource.price}</p>
87
- </div>
88
- );
89
- };
90
- ```
91
-
92
- ### 2. Container Components
93
- **Location**: `features/*/pages/` or `features/*/components/`
94
-
95
- **Rules**:
96
- - Contains business logic
97
- - Makes API calls via hooks
98
- - Manages state
99
- - Passes data to presentational components
100
-
101
- ```tsx
102
- // ✅ GOOD - Container component
103
- export const ResourcesPage = () => {
104
- const [filters, setFilters] = useState<ResourceFilters>({});
105
- const { resources, isLoading } = useResources(filters);
106
- const navigate = useNavigate();
107
-
108
- const handleResourceClick = (id: string) => {
109
- navigate(`/resources/${id}`);
110
- };
111
-
112
- if (isLoading) return <LoadingSpinner />;
113
-
114
- return (
115
- <div className="page-container">
116
- <ResourceFilters value={filters} onChange={setFilters} />
117
- <div className="resource-list">
118
- {resources.map(res => (
119
- <ResourceCard key={res.id} resource={res} onClick={handleResourceClick} />
120
- ))}
121
- </div>
122
- </div>
123
- );
124
- };
125
- ```
126
-
127
- ## Styling Rules
128
-
129
- ### CSS Architecture
130
- Instead of Tailwind, use Vanilla CSS or CSS Modules.
131
-
132
- **Vanilla CSS Pattern**:
133
- ```css
134
- /* ResourceCard.css */
135
- .resource-card {
136
- padding: 16px;
137
- border: 1px solid var(--border-color);
138
- transition: all 0.3s ease;
139
- }
140
-
141
- .resource-card:hover {
142
- box-shadow: 0 4px 12px rgba(0,0,0,0.1);
143
- }
144
- ```
145
-
146
- **CSS Modules Pattern**:
147
- ```tsx
148
- import styles from './ResourceCard.module.css';
149
-
150
- <div className={styles.cardContainer}>...</div>
151
- ```
152
-
153
- **Rules**:
154
- 1. **NO Inline styles**: Avoid `<div style={{...}}>`.
155
- 2. **Use Variables**: Use CSS variables for theme colors (defined in `globals.css`).
156
- 3. **Consistency**: Use Ant Design's built-in props for standard spacing and layout where possible.
157
- 4. **Responsive**: Use media queries in CSS files.
158
-
159
- ```css
160
- /* ✅ GOOD - Responsive in CSS */
161
- .page-container {
162
- padding: 20px;
163
- }
164
-
165
- @media (min-width: 768px) {
166
- .page-container {
167
- padding: 40px;
168
- }
169
- }
170
- ```
171
-
172
- ## Component Size Rules
173
-
174
- ### Limits
175
- - **Max 250 lines** per component
176
- - **Max 5 props** (use object if more)
177
- - **Max 3 levels** of JSX nesting
178
-
179
- ### When to Split
180
- Split when:
181
- 1. Component exceeds 250 lines
182
- 2. JSX nesting exceeds 3 levels
183
- 3. Multiple responsibilities
184
- 4. Part is reusable elsewhere
185
-
186
- ## Props Rules
187
-
188
- ### Props Interface
189
- ```tsx
190
- // ✅ GOOD - Group related props
191
- interface ResourceCardProps {
192
- resource: Resource;
193
- actions?: ResourceActions;
194
- className?: string;
195
- }
196
- ```
197
-
198
- ### Children Prop
199
- ```tsx
200
- interface LayoutProps {
201
- children: React.ReactNode;
202
- headerContent?: React.ReactNode;
203
- }
204
-
205
- export const Layout = ({ children, headerContent }: LayoutProps) => {
206
- return (
207
- <div className="layout">
208
- {headerContent && <div className="header">{headerContent}</div>}
209
- {children}
210
- </div>
211
- );
212
- };
213
- ```
214
-
215
- ## Performance Optimization
216
-
217
- ### React.memo
218
- ```tsx
219
- // ✅ Use for components in lists
220
- export const ResourceCard = React.memo(({ resource }: ResourceCardProps) => {
221
- return <div>{resource.title}</div>;
222
- });
223
-
224
- ResourceCard.displayName = 'ResourceCard';
225
- ```
226
-
227
- ### useCallback
228
- ```tsx
229
- // ✅ For handlers passed to children
230
- const handleClick = useCallback((id: string) => {
231
- navigate(`/resources/${id}`);
232
- }, [navigate]);
233
-
234
- <ResourceCard resource={resource} onClick={handleClick} />
235
- ```
236
-
237
- ## Accessibility Rules
238
- - Use semantic HTML tags.
239
- - Use `aria-*` attributes when standard elements aren't enough.
240
- - Ensure Ant Design components are used with proper labels.
241
-
242
- ## Component Checklist
243
- - [ ] Under 250 lines
244
- - [ ] Props interface defined (max 5)
245
- - [ ] Event handlers use useCallback
246
- - [ ] Expensive computations use useMemo
247
- - [ ] Early returns for error/loading
248
- - [ ] CSS files used (no inline styles, no Tailwind)
249
- - [ ] Accessibility attributes
250
- - [ ] Named export (not default)