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
@@ -0,0 +1,34 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2017",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": true,
6
+ "skipLibCheck": true,
7
+ "strict": true,
8
+ "noEmit": true,
9
+ "esModuleInterop": true,
10
+ "module": "esnext",
11
+ "moduleResolution": "bundler",
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "jsx": "react-jsx",
15
+ "incremental": true,
16
+ "plugins": [
17
+ {
18
+ "name": "next"
19
+ }
20
+ ],
21
+ "paths": {
22
+ "@/*": ["./src/*"]
23
+ }
24
+ },
25
+ "include": [
26
+ "next-env.d.ts",
27
+ "**/*.ts",
28
+ "**/*.tsx",
29
+ ".next/types/**/*.ts",
30
+ ".next/dev/types/**/*.ts",
31
+ "**/*.mts"
32
+ ],
33
+ "exclude": ["node_modules"]
34
+ }
@@ -0,0 +1,34 @@
1
+ # Dependencies
2
+ node_modules/
3
+
4
+ # Build output
5
+ dist/
6
+ .next/
7
+ out/
8
+
9
+ # Environment files
10
+ .env
11
+ .env.local
12
+ .env.*.local
13
+
14
+ # OS files
15
+ .DS_Store
16
+ Thumbs.db
17
+
18
+ # IDE
19
+ .vscode/
20
+ .idea/
21
+
22
+ # Claude Code local settings
23
+ .claude/settings.local.json
24
+
25
+ # Playwright MCP artifacts
26
+ .playwright-mcp/
27
+
28
+ # Logs
29
+ *.log
30
+ npm-debug.log*
31
+ pnpm-debug.log*
32
+
33
+ # Uploads (local development)
34
+ uploads/
@@ -0,0 +1,66 @@
1
+ # Node modules (will be installed fresh in Docker)
2
+ node_modules
3
+ npm-debug.log*
4
+ yarn-debug.log*
5
+ yarn-error.log*
6
+ pnpm-debug.log*
7
+
8
+ # Build output (will be built fresh in Docker)
9
+ dist
10
+ build
11
+ *.tsbuildinfo
12
+
13
+ # Environment files (use Docker env vars instead)
14
+ .env
15
+ .env.local
16
+ .env.*.local
17
+ .env.development
18
+ .env.test
19
+
20
+ # Git
21
+ .git
22
+ .gitignore
23
+ .gitattributes
24
+
25
+ # IDE
26
+ .vscode
27
+ .idea
28
+ *.swp
29
+ *.swo
30
+ *~
31
+ .DS_Store
32
+
33
+ # Testing
34
+ coverage
35
+ .nyc_output
36
+ **/__tests__
37
+ **/*.test.ts
38
+ **/*.spec.ts
39
+ vitest.config.ts
40
+
41
+ # Documentation
42
+ *.md
43
+ !README.md
44
+ docs
45
+
46
+ # Docker
47
+ Dockerfile
48
+ .dockerignore
49
+ docker-compose.yml
50
+ phpmyadmin-config.php
51
+
52
+ # Postman
53
+ postman_collection.json
54
+ postman/
55
+
56
+ # CI/CD
57
+ .github
58
+ .gitlab-ci.yml
59
+ .circleci
60
+
61
+ # Misc
62
+ .prettierrc
63
+ .eslintrc
64
+ .eslintignore
65
+ .editorconfig
66
+ tsconfig.json
@@ -1,69 +1,96 @@
1
- # ==============================================
2
- # SERVER CONFIGURATION
3
- # ==============================================
4
-
5
- NODE_ENV=development
6
- PORT=3000
7
- API_PREFIX=/api/v1
8
- LOG_LEVEL=info
9
-
10
- # ==============================================
11
- # DATABASE CONFIGURATION (MySQL)
12
- # ==============================================
13
-
14
- DATABASE_URL="mysql://root:{{DATABASE_PASSWORD}}@localhost:3306/{{DATABASE_NAME}}"
15
-
16
-
17
- # ==============================================
18
- # REDIS CONFIGURATION
19
- # ==============================================
20
-
21
- REDIS_HOST=localhost
22
- REDIS_PORT=6379
23
- REDIS_PASSWORD=
24
- REDIS_DB=0
25
-
26
- # ==============================================
27
- # JWT AUTHENTICATION
28
- # =============================================='
29
-
30
- # enter strong jwt secret in production !
31
- JWT_SECRET=123412341234123412341234123412341234123412341234123412341234
32
- JWT_ACCESS_EXPIRATION=15m
33
- JWT_REFRESH_EXPIRATION=7d
34
- JWT_ISSUER={{PROJECT_NAME}}
35
-
36
- # ==============================================
37
- # CORS CONFIGURATION
38
- # ==============================================
39
-
40
- CORS_ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000
41
-
42
- # ==============================================
43
- # FILE UPLOAD CONFIGURATION
44
- # ==============================================
45
-
46
- MAX_FILE_SIZE=10485760
47
- ALLOWED_FILE_TYPES=image/jpeg,image/png,image/webp,application/pdf
48
- UPLOAD_DIR=./uploads
49
-
50
- # ==============================================
51
- # RATE LIMITING
52
- # ==============================================
53
-
54
- RATE_LIMIT_MAX=100
55
- RATE_LIMIT_WINDOW=900000
56
-
57
- # ==============================================
58
- # DEVELOPMENT TOOLS
59
- # ==============================================
60
-
61
- PRISMA_QUERY_LOG=false
62
- SLOW_QUERY_THRESHOLD=1000
63
-
64
- # ==============================================
65
- # ADMIN SEED (Initial Setup)
66
- # ==============================================
67
-
68
- ADMIN_EMAIL=admin@{{PROJECT_NAME}}.dev
69
- ADMIN_PASSWORD=Admin123!
1
+ # ===================================================================
2
+ # APPLICATION CONFIGURATION
3
+ # ===================================================================
4
+
5
+ # Environment: development | production | test
6
+ NODE_ENV=development
7
+
8
+ # Server port (default: 8000)
9
+ PORT=8000
10
+
11
+ # Server host (0.0.0.0 = listen on all interfaces)
12
+ HOST=0.0.0.0
13
+
14
+ # ===================================================================
15
+ # DATABASE CONFIGURATION (MySQL 8.0+)
16
+ # ===================================================================
17
+
18
+ # Database connection string
19
+ # Format: mysql://username:password@host:port/database
20
+ DATABASE_URL="mysql://root:rootpassword@localhost:3306/{{DATABASE_NAME}}"
21
+
22
+ # Connection pool settings (for high-traffic production)
23
+ # Min connections: 2-5 for low traffic, 5-10 for medium, 10-20 for high
24
+ # Max connections: 10 for dev, 20-50 for production (10K-100K users/day)
25
+ DATABASE_POOL_MIN=2
26
+ DATABASE_POOL_MAX=10
27
+
28
+ # ===================================================================
29
+ # REDIS CONFIGURATION
30
+ # ===================================================================
31
+
32
+ # Redis connection URL
33
+ # Format: redis://[:password@]host:port[/database]
34
+ REDIS_URL="redis://localhost:6379"
35
+
36
+ # Max retry attempts for failed Redis operations
37
+ REDIS_MAX_RETRIES=3
38
+
39
+ # Connection timeout in milliseconds
40
+ REDIS_CONNECT_TIMEOUT=10000
41
+
42
+ # ===================================================================
43
+ # JWT AUTHENTICATION
44
+ # ===================================================================
45
+
46
+ # JWT secret key (MUST be at least 32 characters)
47
+ # CRITICAL: Generate a strong random secret for production!
48
+ # Example: openssl rand -base64 48
49
+ JWT_SECRET="{{JWT_SECRET}}"
50
+
51
+ # Access token expiry (short-lived)
52
+ # Format: 1s, 1m, 1h, 1d (default: 15m)
53
+ JWT_ACCESS_EXPIRY="15m"
54
+
55
+ # Refresh token expiry (long-lived)
56
+ # Format: 1s, 1m, 1h, 1d (default: 7d)
57
+ JWT_REFRESH_EXPIRY="7d"
58
+
59
+ # Cookie signing secret (separate from JWT for defense-in-depth)
60
+ # Optional: defaults to JWT_SECRET if not set
61
+ # For production: generate a separate secret: openssl rand -base64 48
62
+ # COOKIE_SECRET="change-this-to-a-different-secret-at-least-32-chars"
63
+
64
+ # ===================================================================
65
+ # CORS (Cross-Origin Resource Sharing)
66
+ # ===================================================================
67
+
68
+ # Allowed origins for CORS
69
+ # Development: Optional (allows all origins for easier local dev)
70
+ # Production: REQUIRED (must be your frontend URL for security)
71
+ # Multiple origins: Separate with commas
72
+ # Examples:
73
+ # Single origin: CORS_ORIGIN="https://myapp.com"
74
+ # Multiple origins: CORS_ORIGIN="https://myapp.com,https://app.myapp.com"
75
+ # Local dev: CORS_ORIGIN="http://localhost:3001"
76
+ # CORS_ORIGIN="http://localhost:3001"
77
+
78
+ # ===================================================================
79
+ # LOGGING
80
+ # ===================================================================
81
+
82
+ # Log level: fatal | error | warn | info | debug | trace
83
+ # Production: info or warn (reduces noise)
84
+ # Development: debug (verbose logging)
85
+ # Staging: info
86
+ LOG_LEVEL=info
87
+
88
+ # ===================================================================
89
+ # ERROR TRACKING (Optional)
90
+ # ===================================================================
91
+
92
+ # Sentry DSN for error tracking and monitoring
93
+ # Get your DSN from: https://sentry.io/settings/projects/
94
+ # Leave empty to disable Sentry
95
+ # Example: SENTRY_DSN="https://examplePublicKey@o0.ingest.sentry.io/0"
96
+ # SENTRY_DSN=""
@@ -0,0 +1,90 @@
1
+ # ===================================================================
2
+ # PRODUCTION ENVIRONMENT CONFIGURATION
3
+ # ===================================================================
4
+ # This file contains production-optimized settings for high-traffic
5
+ # deployments (10K-100K users/day). Copy to .env and customize.
6
+ # ===================================================================
7
+
8
+ # ===================================================================
9
+ # APPLICATION
10
+ # ===================================================================
11
+
12
+ NODE_ENV=production
13
+ PORT=3000
14
+ HOST=0.0.0.0
15
+
16
+ # ===================================================================
17
+ # DATABASE (MySQL 8.0+)
18
+ # ===================================================================
19
+
20
+ # Production database connection
21
+ # CRITICAL: Use secure credentials, SSL/TLS, and private network
22
+ DATABASE_URL="mysql://prod_user:SECURE_PASSWORD@db.internal:3306/prod_db?ssl=true"
23
+
24
+ # Connection pool for high traffic (10K-100K users/day)
25
+ # Recommended: 20-50 connections for production
26
+ # Monitor and adjust based on load testing results
27
+ DATABASE_POOL_MIN=10
28
+ DATABASE_POOL_MAX=50
29
+
30
+ # ===================================================================
31
+ # REDIS
32
+ # ===================================================================
33
+
34
+ # Production Redis instance
35
+ # CRITICAL: Use authentication and private network
36
+ REDIS_URL="redis://:REDIS_PASSWORD@redis.internal:6379"
37
+
38
+ # Production retry settings
39
+ REDIS_MAX_RETRIES=5
40
+ REDIS_CONNECT_TIMEOUT=5000
41
+
42
+ # ===================================================================
43
+ # JWT AUTHENTICATION
44
+ # ===================================================================
45
+
46
+ # CRITICAL: Generate a cryptographically secure secret
47
+ # Example: openssl rand -base64 48
48
+ JWT_SECRET="YOUR_PRODUCTION_JWT_SECRET_MUST_BE_AT_LEAST_32_CHARS_LONG"
49
+
50
+ # Production token expiry (tighter security)
51
+ JWT_ACCESS_EXPIRY="15m"
52
+ JWT_REFRESH_EXPIRY="7d"
53
+
54
+ # ===================================================================
55
+ # CORS
56
+ # ===================================================================
57
+
58
+ # REQUIRED in production - your frontend domain(s)
59
+ # Multiple origins separated by commas
60
+ CORS_ORIGIN="https://yourdomain.com,https://app.yourdomain.com"
61
+
62
+ # ===================================================================
63
+ # LOGGING
64
+ # ===================================================================
65
+
66
+ # Production: info or warn (reduces log volume)
67
+ # Use warn to reduce costs in high-traffic scenarios
68
+ LOG_LEVEL=info
69
+
70
+ # ===================================================================
71
+ # ERROR TRACKING
72
+ # ===================================================================
73
+
74
+ # Sentry for production error monitoring
75
+ # Get your DSN from: https://sentry.io/settings/projects/
76
+ SENTRY_DSN="https://YOUR_PUBLIC_KEY@o0.ingest.sentry.io/YOUR_PROJECT_ID"
77
+
78
+ # ===================================================================
79
+ # PRODUCTION CHECKLIST
80
+ # ===================================================================
81
+ # [ ] DATABASE_URL uses secure credentials and SSL
82
+ # [ ] JWT_SECRET is a strong random string (48+ chars)
83
+ # [ ] CORS_ORIGIN is set to your exact frontend URL(s)
84
+ # [ ] REDIS_URL uses authentication if Redis is exposed
85
+ # [ ] LOG_LEVEL is set to info or warn
86
+ # [ ] SENTRY_DSN is configured for error tracking
87
+ # [ ] Database connection pool tested under load
88
+ # [ ] All secrets are stored in environment variables, not in code
89
+ # [ ] SSL/TLS certificates are configured
90
+ # [ ] Firewall rules restrict access to database and Redis
@@ -0,0 +1,94 @@
1
+ # ===================================================================
2
+ # Multi-stage Dockerfile for Production Deployment
3
+ # Optimized for Coolify, Docker Compose, and Kubernetes
4
+ # ===================================================================
5
+
6
+ # ===================================================================
7
+ # Stage 1: Dependencies (cached layer)
8
+ # ===================================================================
9
+ FROM node:20-alpine AS dependencies
10
+
11
+ # Install production dependencies only
12
+ WORKDIR /app
13
+
14
+ # Copy package files
15
+ COPY package.json package-lock.json* pnpm-lock.yaml* yarn.lock* ./
16
+
17
+ # Install dependencies (use the lockfile that exists)
18
+ RUN if [ -f pnpm-lock.yaml ]; then \
19
+ npm install -g pnpm && pnpm install --prod --frozen-lockfile; \
20
+ elif [ -f yarn.lock ]; then \
21
+ yarn install --production --frozen-lockfile; \
22
+ else \
23
+ npm ci --omit=dev; \
24
+ fi
25
+
26
+ # ===================================================================
27
+ # Stage 2: Build (compile TypeScript)
28
+ # ===================================================================
29
+ FROM node:20-alpine AS builder
30
+
31
+ WORKDIR /app
32
+
33
+ # Copy package files and install ALL dependencies (including dev)
34
+ COPY package.json package-lock.json* pnpm-lock.yaml* yarn.lock* ./
35
+
36
+ RUN if [ -f pnpm-lock.yaml ]; then \
37
+ npm install -g pnpm && pnpm install --frozen-lockfile; \
38
+ elif [ -f yarn.lock ]; then \
39
+ yarn install --frozen-lockfile; \
40
+ else \
41
+ npm ci; \
42
+ fi
43
+
44
+ # Copy source code and Prisma schema
45
+ COPY . .
46
+
47
+ # Generate Prisma Client
48
+ RUN npx prisma generate
49
+
50
+ # Build TypeScript
51
+ RUN npm run build
52
+
53
+ # ===================================================================
54
+ # Stage 3: Production Runtime
55
+ # ===================================================================
56
+ FROM node:20-alpine AS production
57
+
58
+ # Install dumb-init for proper signal handling
59
+ RUN apk add --no-cache dumb-init
60
+
61
+ # Create non-root user for security
62
+ RUN addgroup -g 1001 -S nodejs && \
63
+ adduser -S nodejs -u 1001
64
+
65
+ WORKDIR /app
66
+
67
+ # Copy production dependencies from dependencies stage
68
+ COPY --from=dependencies --chown=nodejs:nodejs /app/node_modules ./node_modules
69
+
70
+ # Copy generated Prisma client from builder stage (not present in prod deps)
71
+ COPY --from=builder --chown=nodejs:nodejs /app/node_modules/.prisma ./node_modules/.prisma
72
+
73
+ # Copy built application from builder stage
74
+ COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
75
+ COPY --from=builder --chown=nodejs:nodejs /app/package.json ./package.json
76
+
77
+ # Copy Prisma files (needed for migrations)
78
+ COPY --from=builder --chown=nodejs:nodejs /app/prisma ./prisma
79
+
80
+ # Switch to non-root user
81
+ USER nodejs
82
+
83
+ # Expose port (matches default PORT in env.ts; override via PORT env var)
84
+ EXPOSE 8000
85
+
86
+ # Health check for container orchestration
87
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
88
+ CMD node -e "const p=process.env.PORT||8000;require('http').get('http://localhost:'+p+'/api/v1/live',(r)=>{process.exit(r.statusCode===200?0:1)})"
89
+
90
+ # Use dumb-init to handle signals properly
91
+ ENTRYPOINT ["dumb-init", "--"]
92
+
93
+ # Start the application
94
+ CMD ["node", "dist/server.js"]
@@ -1,111 +1,82 @@
1
- version: '3.8'
2
- name: {{PROJECT_NAME}}
3
-
4
- services:
5
- # ==============================================
6
- # MySQL Database Service
7
- # ==============================================
8
- mysql:
9
- image: mysql:8.0
10
- container_name: {{PROJECT_NAME}}-mysql
11
- restart: unless-stopped
12
- ports:
13
- - '3306:3306'
14
- environment:
15
- MYSQL_ROOT_PASSWORD: {{DATABASE_PASSWORD}}
16
- MYSQL_DATABASE: {{DATABASE_NAME}}
17
- # Performance tuning
18
- MYSQL_INNODB_BUFFER_POOL_SIZE: 256M
19
- MYSQL_MAX_CONNECTIONS: 100
20
- volumes:
21
- # Persist MySQL data
22
- - {{PROJECT_NAME}}_mysql_data:/var/lib/mysql
23
- # Custom MySQL configuration (optional)
24
- # - ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
25
- networks:
26
- - {{PROJECT_NAME}}-network
27
- healthcheck:
28
- test: [ 'CMD', 'mysqladmin', 'ping', '-h', 'localhost', '-u', 'root', '-p{{DATABASE_PASSWORD}}' ]
29
- interval: 10s
30
- timeout: 5s
31
- retries: 5
32
- start_period: 30s
33
- command:
34
- - --character-set-server=utf8mb4
35
- - --collation-server=utf8mb4_unicode_ci
36
- - --default-authentication-plugin=mysql_native_password
37
-
38
- # ==============================================
39
- # Redis Cache Service
40
- # ==============================================
41
- redis:
42
- image: redis:7-alpine
43
- container_name: {{PROJECT_NAME}}-redis
44
- restart: unless-stopped
45
- ports:
46
- - '6379:6379'
47
- volumes:
48
- # Persist Redis data
49
- - {{PROJECT_NAME}}_redis_data:/data
50
- # Custom Redis configuration (optional)
51
- # - ./docker/redis/redis.conf:/usr/local/etc/redis/redis.conf
52
- networks:
53
- - {{PROJECT_NAME}}-network
54
- healthcheck:
55
- test: [ 'CMD', 'redis-cli', 'ping' ]
56
- interval: 10s
57
- timeout: 3s
58
- retries: 5
59
- start_period: 10s
60
- command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy noeviction
61
- # ==============================================
62
- # phpMyAdmin (Database Management UI)
63
- # ==============================================
64
- # Access at: http://localhost:8080
65
- phpmyadmin:
66
- image: phpmyadmin/phpmyadmin:latest
67
- container_name: {{PROJECT_NAME}}-phpmyadmin
68
- restart: unless-stopped
69
- ports:
70
- - '8080:80'
71
- environment:
72
- PMA_HOST: mysql
73
- PMA_ARBITRARY: 1
74
- # PMA_USER: root <-- Removed to allow manual login
75
- # PMA_PASSWORD: password <-- Removed to allow manual login
76
- networks:
77
- - {{PROJECT_NAME}}-network
78
- depends_on:
79
- - mysql
80
-
81
- # ==============================================
82
- # Redis Commander (Redis Management UI)
83
- # ==============================================
84
- # Access at: http://localhost:8081
85
- redis-commander:
86
- image: rediscommander/redis-commander:latest
87
- container_name: {{PROJECT_NAME}}-redis-commander
88
- restart: unless-stopped
89
- ports:
90
- - '8081:8081'
91
- environment:
92
- REDIS_HOSTS: local:redis:6379
93
- networks:
94
- - {{PROJECT_NAME}}-network
95
- depends_on:
96
- - redis
97
- # ==============================================
98
- # Named Volumes for Data Persistence
99
- # ==============================================
100
- volumes:
101
- {{PROJECT_NAME}}_mysql_data:
102
- driver: local
103
- {{PROJECT_NAME}}_redis_data:
104
- driver: local
105
-
106
- # ==============================================
107
- # Network Configuration
108
- # ==============================================
109
- networks:
110
- {{PROJECT_NAME}}-network:
111
- driver: bridge
1
+ # WARNING: These credentials are for LOCAL DEVELOPMENT ONLY.
2
+ # Change all passwords and secrets before using in any shared or production environment.
3
+
4
+ name: {{PROJECT_NAME}}
5
+
6
+ services:
7
+ mysql:
8
+ image: mysql:8.0
9
+ container_name: {{PROJECT_NAME}}-mysql
10
+ restart: unless-stopped
11
+ ports:
12
+ - '3306:3306'
13
+ environment:
14
+ MYSQL_ROOT_PASSWORD: rootpassword
15
+ MYSQL_DATABASE: {{DATABASE_NAME}}
16
+ volumes:
17
+ - mysql_data:/var/lib/mysql
18
+ networks:
19
+ - {{PROJECT_NAME}}-network
20
+ healthcheck:
21
+ test: ['CMD', 'mysqladmin', 'ping', '-h', 'localhost']
22
+ interval: 10s
23
+ timeout: 5s
24
+ retries: 5
25
+
26
+ phpmyadmin:
27
+ image: phpmyadmin:latest
28
+ container_name: {{PROJECT_NAME}}-phpmyadmin
29
+ restart: unless-stopped
30
+ ports:
31
+ - '8080:80'
32
+ environment:
33
+ PMA_HOST: mysql
34
+ PMA_PORT: 3306
35
+ MYSQL_ROOT_PASSWORD: rootpassword
36
+ PMA_ARBITRARY: 0
37
+ HIDE_PHP_VERSION: 'true'
38
+ volumes:
39
+ - ./phpmyadmin-config.php:/etc/phpmyadmin/config.user.inc.php
40
+ depends_on:
41
+ mysql:
42
+ condition: service_healthy
43
+ networks:
44
+ - {{PROJECT_NAME}}-network
45
+
46
+ redis:
47
+ image: redis:7-alpine
48
+ container_name: {{PROJECT_NAME}}-redis
49
+ restart: unless-stopped
50
+ ports:
51
+ - '6379:6379'
52
+ volumes:
53
+ - redis_data:/data
54
+ networks:
55
+ - {{PROJECT_NAME}}-network
56
+ healthcheck:
57
+ test: ['CMD', 'redis-cli', 'ping']
58
+ interval: 10s
59
+ timeout: 5s
60
+ retries: 5
61
+
62
+ redis-commander:
63
+ image: rediscommander/redis-commander:latest
64
+ container_name: {{PROJECT_NAME}}-redis-commander
65
+ restart: unless-stopped
66
+ ports:
67
+ - '8081:8081'
68
+ environment:
69
+ REDIS_HOSTS: local:redis:6379
70
+ depends_on:
71
+ redis:
72
+ condition: service_healthy
73
+ networks:
74
+ - {{PROJECT_NAME}}-network
75
+
76
+ volumes:
77
+ mysql_data:
78
+ redis_data:
79
+
80
+ networks:
81
+ {{PROJECT_NAME}}-network:
82
+ driver: bridge