create-blitzpack 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. package/dist/index.js +452 -0
  2. package/package.json +57 -0
  3. package/template/.dockerignore +59 -0
  4. package/template/.github/workflows/ci.yml +157 -0
  5. package/template/.husky/pre-commit +1 -0
  6. package/template/.husky/pre-push +1 -0
  7. package/template/.lintstagedrc.cjs +4 -0
  8. package/template/.nvmrc +1 -0
  9. package/template/.prettierrc +9 -0
  10. package/template/.vscode/settings.json +13 -0
  11. package/template/CLAUDE.md +175 -0
  12. package/template/CONTRIBUTING.md +32 -0
  13. package/template/Dockerfile +90 -0
  14. package/template/GETTING_STARTED.md +35 -0
  15. package/template/LICENSE +21 -0
  16. package/template/README.md +116 -0
  17. package/template/apps/api/.dockerignore +51 -0
  18. package/template/apps/api/.env.local.example +62 -0
  19. package/template/apps/api/emails/account-deleted-email.tsx +69 -0
  20. package/template/apps/api/emails/components/email-layout.tsx +154 -0
  21. package/template/apps/api/emails/config.ts +22 -0
  22. package/template/apps/api/emails/password-changed-email.tsx +88 -0
  23. package/template/apps/api/emails/password-reset-email.tsx +86 -0
  24. package/template/apps/api/emails/verification-email.tsx +85 -0
  25. package/template/apps/api/emails/welcome-email.tsx +70 -0
  26. package/template/apps/api/package.json +84 -0
  27. package/template/apps/api/prisma/migrations/20251012111439_init/migration.sql +13 -0
  28. package/template/apps/api/prisma/migrations/20251018162629_add_better_auth_fields/migration.sql +67 -0
  29. package/template/apps/api/prisma/migrations/20251019142208_add_user_role_enum/migration.sql +5 -0
  30. package/template/apps/api/prisma/migrations/20251019182151_user_auth/migration.sql +7 -0
  31. package/template/apps/api/prisma/migrations/20251019211416_faster_session_lookup/migration.sql +2 -0
  32. package/template/apps/api/prisma/migrations/20251119124337_add_upload_model/migration.sql +26 -0
  33. package/template/apps/api/prisma/migrations/20251120071241_add_scope_to_account/migration.sql +2 -0
  34. package/template/apps/api/prisma/migrations/20251120072608_add_oauth_token_expiration_fields/migration.sql +10 -0
  35. package/template/apps/api/prisma/migrations/20251120144705_add_audit_logs/migration.sql +29 -0
  36. package/template/apps/api/prisma/migrations/20251127123614_remove_impersonated_by/migration.sql +8 -0
  37. package/template/apps/api/prisma/migrations/20251127125630_remove_audit_logs/migration.sql +11 -0
  38. package/template/apps/api/prisma/migrations/migration_lock.toml +3 -0
  39. package/template/apps/api/prisma/schema.prisma +116 -0
  40. package/template/apps/api/prisma/seed.ts +159 -0
  41. package/template/apps/api/prisma.config.ts +14 -0
  42. package/template/apps/api/src/app.ts +377 -0
  43. package/template/apps/api/src/common/logger.service.ts +227 -0
  44. package/template/apps/api/src/config/env.ts +60 -0
  45. package/template/apps/api/src/config/rate-limit.ts +29 -0
  46. package/template/apps/api/src/hooks/auth.ts +122 -0
  47. package/template/apps/api/src/plugins/auth.ts +198 -0
  48. package/template/apps/api/src/plugins/database.ts +45 -0
  49. package/template/apps/api/src/plugins/logger.ts +33 -0
  50. package/template/apps/api/src/plugins/multipart.ts +16 -0
  51. package/template/apps/api/src/plugins/scalar.ts +20 -0
  52. package/template/apps/api/src/plugins/schedule.ts +52 -0
  53. package/template/apps/api/src/plugins/services.ts +66 -0
  54. package/template/apps/api/src/plugins/swagger.ts +56 -0
  55. package/template/apps/api/src/routes/accounts.ts +91 -0
  56. package/template/apps/api/src/routes/admin-sessions.ts +92 -0
  57. package/template/apps/api/src/routes/metrics.ts +71 -0
  58. package/template/apps/api/src/routes/password.ts +46 -0
  59. package/template/apps/api/src/routes/sessions.ts +53 -0
  60. package/template/apps/api/src/routes/stats.ts +38 -0
  61. package/template/apps/api/src/routes/uploads-serve.ts +27 -0
  62. package/template/apps/api/src/routes/uploads.ts +154 -0
  63. package/template/apps/api/src/routes/users.ts +114 -0
  64. package/template/apps/api/src/routes/verification.ts +90 -0
  65. package/template/apps/api/src/server.ts +34 -0
  66. package/template/apps/api/src/services/accounts.service.ts +125 -0
  67. package/template/apps/api/src/services/authorization.service.ts +162 -0
  68. package/template/apps/api/src/services/email.service.ts +170 -0
  69. package/template/apps/api/src/services/file-storage.service.ts +267 -0
  70. package/template/apps/api/src/services/metrics.service.ts +175 -0
  71. package/template/apps/api/src/services/password.service.ts +56 -0
  72. package/template/apps/api/src/services/sessions.service.spec.ts +134 -0
  73. package/template/apps/api/src/services/sessions.service.ts +276 -0
  74. package/template/apps/api/src/services/stats.service.ts +273 -0
  75. package/template/apps/api/src/services/uploads.service.ts +163 -0
  76. package/template/apps/api/src/services/users.service.spec.ts +249 -0
  77. package/template/apps/api/src/services/users.service.ts +198 -0
  78. package/template/apps/api/src/utils/file-validation.ts +108 -0
  79. package/template/apps/api/start.sh +33 -0
  80. package/template/apps/api/test/helpers/fastify-app.ts +24 -0
  81. package/template/apps/api/test/helpers/mock-authorization.ts +16 -0
  82. package/template/apps/api/test/helpers/mock-logger.ts +28 -0
  83. package/template/apps/api/test/helpers/mock-prisma.ts +30 -0
  84. package/template/apps/api/test/helpers/test-db.ts +125 -0
  85. package/template/apps/api/test/integration/auth-flow.integration.spec.ts +449 -0
  86. package/template/apps/api/test/integration/password.integration.spec.ts +427 -0
  87. package/template/apps/api/test/integration/rate-limit.integration.spec.ts +51 -0
  88. package/template/apps/api/test/integration/sessions.integration.spec.ts +445 -0
  89. package/template/apps/api/test/integration/users.integration.spec.ts +211 -0
  90. package/template/apps/api/test/setup.ts +31 -0
  91. package/template/apps/api/tsconfig.json +26 -0
  92. package/template/apps/api/vitest.config.ts +35 -0
  93. package/template/apps/web/.env.local.example +11 -0
  94. package/template/apps/web/components.json +24 -0
  95. package/template/apps/web/next.config.ts +22 -0
  96. package/template/apps/web/package.json +56 -0
  97. package/template/apps/web/postcss.config.js +5 -0
  98. package/template/apps/web/public/apple-icon.png +0 -0
  99. package/template/apps/web/public/icon.png +0 -0
  100. package/template/apps/web/public/robots.txt +3 -0
  101. package/template/apps/web/src/app/(admin)/admin/layout.tsx +222 -0
  102. package/template/apps/web/src/app/(admin)/admin/page.tsx +157 -0
  103. package/template/apps/web/src/app/(admin)/admin/sessions/page.tsx +18 -0
  104. package/template/apps/web/src/app/(admin)/admin/users/page.tsx +20 -0
  105. package/template/apps/web/src/app/(auth)/forgot-password/page.tsx +177 -0
  106. package/template/apps/web/src/app/(auth)/login/page.tsx +159 -0
  107. package/template/apps/web/src/app/(auth)/reset-password/page.tsx +245 -0
  108. package/template/apps/web/src/app/(auth)/signup/page.tsx +153 -0
  109. package/template/apps/web/src/app/dashboard/change-password/page.tsx +255 -0
  110. package/template/apps/web/src/app/dashboard/page.tsx +296 -0
  111. package/template/apps/web/src/app/error.tsx +32 -0
  112. package/template/apps/web/src/app/examples/file-upload/page.tsx +200 -0
  113. package/template/apps/web/src/app/favicon.ico +0 -0
  114. package/template/apps/web/src/app/global-error.tsx +96 -0
  115. package/template/apps/web/src/app/globals.css +22 -0
  116. package/template/apps/web/src/app/icon.png +0 -0
  117. package/template/apps/web/src/app/layout.tsx +34 -0
  118. package/template/apps/web/src/app/not-found.tsx +28 -0
  119. package/template/apps/web/src/app/page.tsx +192 -0
  120. package/template/apps/web/src/components/admin/activity-feed.tsx +101 -0
  121. package/template/apps/web/src/components/admin/charts/auth-breakdown-chart.tsx +114 -0
  122. package/template/apps/web/src/components/admin/charts/chart-tooltip.tsx +124 -0
  123. package/template/apps/web/src/components/admin/charts/realtime-metrics-chart.tsx +511 -0
  124. package/template/apps/web/src/components/admin/charts/role-distribution-chart.tsx +102 -0
  125. package/template/apps/web/src/components/admin/charts/session-activity-chart.tsx +90 -0
  126. package/template/apps/web/src/components/admin/charts/user-growth-chart.tsx +108 -0
  127. package/template/apps/web/src/components/admin/health-indicator.tsx +175 -0
  128. package/template/apps/web/src/components/admin/refresh-control.tsx +90 -0
  129. package/template/apps/web/src/components/admin/session-revoke-all-dialog.tsx +79 -0
  130. package/template/apps/web/src/components/admin/session-revoke-dialog.tsx +74 -0
  131. package/template/apps/web/src/components/admin/sessions-management-table.tsx +372 -0
  132. package/template/apps/web/src/components/admin/stat-card.tsx +137 -0
  133. package/template/apps/web/src/components/admin/user-create-dialog.tsx +152 -0
  134. package/template/apps/web/src/components/admin/user-delete-dialog.tsx +73 -0
  135. package/template/apps/web/src/components/admin/user-edit-dialog.tsx +170 -0
  136. package/template/apps/web/src/components/admin/users-management-table.tsx +285 -0
  137. package/template/apps/web/src/components/auth/email-verification-banner.tsx +85 -0
  138. package/template/apps/web/src/components/auth/github-button.tsx +40 -0
  139. package/template/apps/web/src/components/auth/google-button.tsx +54 -0
  140. package/template/apps/web/src/components/auth/protected-route.tsx +66 -0
  141. package/template/apps/web/src/components/auth/redirect-if-authenticated.tsx +31 -0
  142. package/template/apps/web/src/components/auth/with-auth.tsx +30 -0
  143. package/template/apps/web/src/components/error/error-card.tsx +47 -0
  144. package/template/apps/web/src/components/error/forbidden.tsx +25 -0
  145. package/template/apps/web/src/components/landing/command-block.tsx +64 -0
  146. package/template/apps/web/src/components/landing/feature-card.tsx +60 -0
  147. package/template/apps/web/src/components/landing/included-feature-card.tsx +63 -0
  148. package/template/apps/web/src/components/landing/logo.tsx +41 -0
  149. package/template/apps/web/src/components/landing/tech-badge.tsx +11 -0
  150. package/template/apps/web/src/components/layout/auth-nav.tsx +58 -0
  151. package/template/apps/web/src/components/layout/footer.tsx +3 -0
  152. package/template/apps/web/src/config/landing-data.ts +152 -0
  153. package/template/apps/web/src/config/site.ts +5 -0
  154. package/template/apps/web/src/hooks/api/__tests__/use-users.test.tsx +181 -0
  155. package/template/apps/web/src/hooks/api/use-admin-sessions.ts +75 -0
  156. package/template/apps/web/src/hooks/api/use-admin-stats.ts +33 -0
  157. package/template/apps/web/src/hooks/api/use-sessions.ts +52 -0
  158. package/template/apps/web/src/hooks/api/use-uploads.ts +156 -0
  159. package/template/apps/web/src/hooks/api/use-users.ts +149 -0
  160. package/template/apps/web/src/hooks/use-mobile.ts +21 -0
  161. package/template/apps/web/src/hooks/use-realtime-metrics.ts +120 -0
  162. package/template/apps/web/src/lib/__tests__/utils.test.ts +29 -0
  163. package/template/apps/web/src/lib/api.ts +151 -0
  164. package/template/apps/web/src/lib/auth.ts +13 -0
  165. package/template/apps/web/src/lib/env.ts +52 -0
  166. package/template/apps/web/src/lib/form-utils.ts +11 -0
  167. package/template/apps/web/src/lib/utils.ts +1 -0
  168. package/template/apps/web/src/providers.tsx +34 -0
  169. package/template/apps/web/src/store/atoms.ts +15 -0
  170. package/template/apps/web/src/test/helpers/test-utils.tsx +44 -0
  171. package/template/apps/web/src/test/setup.ts +8 -0
  172. package/template/apps/web/tailwind.config.ts +5 -0
  173. package/template/apps/web/tsconfig.json +26 -0
  174. package/template/apps/web/vitest.config.ts +32 -0
  175. package/template/assets/logo-512.png +0 -0
  176. package/template/assets/logo.svg +4 -0
  177. package/template/docker-compose.prod.yml +66 -0
  178. package/template/docker-compose.yml +36 -0
  179. package/template/eslint.config.ts +119 -0
  180. package/template/package.json +77 -0
  181. package/template/packages/tailwind-config/package.json +9 -0
  182. package/template/packages/tailwind-config/theme.css +179 -0
  183. package/template/packages/types/package.json +29 -0
  184. package/template/packages/types/src/__tests__/schemas.test.ts +255 -0
  185. package/template/packages/types/src/api-response.ts +53 -0
  186. package/template/packages/types/src/health-check.ts +11 -0
  187. package/template/packages/types/src/pagination.ts +41 -0
  188. package/template/packages/types/src/role.ts +5 -0
  189. package/template/packages/types/src/session.ts +48 -0
  190. package/template/packages/types/src/stats.ts +113 -0
  191. package/template/packages/types/src/upload.ts +51 -0
  192. package/template/packages/types/src/user.ts +36 -0
  193. package/template/packages/types/tsconfig.json +5 -0
  194. package/template/packages/types/vitest.config.ts +21 -0
  195. package/template/packages/ui/components.json +21 -0
  196. package/template/packages/ui/package.json +108 -0
  197. package/template/packages/ui/src/__tests__/button.test.tsx +70 -0
  198. package/template/packages/ui/src/alert-dialog.tsx +141 -0
  199. package/template/packages/ui/src/alert.tsx +66 -0
  200. package/template/packages/ui/src/animated-theme-toggler.tsx +167 -0
  201. package/template/packages/ui/src/avatar.tsx +53 -0
  202. package/template/packages/ui/src/badge.tsx +36 -0
  203. package/template/packages/ui/src/button.tsx +84 -0
  204. package/template/packages/ui/src/card.tsx +92 -0
  205. package/template/packages/ui/src/checkbox.tsx +32 -0
  206. package/template/packages/ui/src/data-table/data-table-column-header.tsx +68 -0
  207. package/template/packages/ui/src/data-table/data-table-pagination.tsx +99 -0
  208. package/template/packages/ui/src/data-table/data-table-toolbar.tsx +55 -0
  209. package/template/packages/ui/src/data-table/data-table-view-options.tsx +63 -0
  210. package/template/packages/ui/src/data-table/data-table.tsx +167 -0
  211. package/template/packages/ui/src/dialog.tsx +143 -0
  212. package/template/packages/ui/src/dropdown-menu.tsx +257 -0
  213. package/template/packages/ui/src/empty-state.tsx +52 -0
  214. package/template/packages/ui/src/file-upload-input.tsx +202 -0
  215. package/template/packages/ui/src/form.tsx +168 -0
  216. package/template/packages/ui/src/hooks/use-mobile.ts +19 -0
  217. package/template/packages/ui/src/icons/brand-icons.tsx +16 -0
  218. package/template/packages/ui/src/input.tsx +21 -0
  219. package/template/packages/ui/src/label.tsx +24 -0
  220. package/template/packages/ui/src/lib/utils.ts +6 -0
  221. package/template/packages/ui/src/password-input.tsx +102 -0
  222. package/template/packages/ui/src/popover.tsx +48 -0
  223. package/template/packages/ui/src/radio-group.tsx +45 -0
  224. package/template/packages/ui/src/scroll-area.tsx +58 -0
  225. package/template/packages/ui/src/select.tsx +187 -0
  226. package/template/packages/ui/src/separator.tsx +28 -0
  227. package/template/packages/ui/src/sheet.tsx +139 -0
  228. package/template/packages/ui/src/sidebar.tsx +726 -0
  229. package/template/packages/ui/src/skeleton-variants.tsx +87 -0
  230. package/template/packages/ui/src/skeleton.tsx +13 -0
  231. package/template/packages/ui/src/slider.tsx +63 -0
  232. package/template/packages/ui/src/sonner.tsx +25 -0
  233. package/template/packages/ui/src/spinner.tsx +16 -0
  234. package/template/packages/ui/src/switch.tsx +31 -0
  235. package/template/packages/ui/src/table.tsx +116 -0
  236. package/template/packages/ui/src/tabs.tsx +66 -0
  237. package/template/packages/ui/src/textarea.tsx +18 -0
  238. package/template/packages/ui/src/tooltip.tsx +61 -0
  239. package/template/packages/ui/src/user-avatar.tsx +97 -0
  240. package/template/packages/ui/test-config.js +3 -0
  241. package/template/packages/ui/tsconfig.json +12 -0
  242. package/template/packages/ui/turbo.json +18 -0
  243. package/template/packages/ui/vitest.config.ts +17 -0
  244. package/template/packages/ui/vitest.setup.ts +1 -0
  245. package/template/packages/utils/package.json +23 -0
  246. package/template/packages/utils/src/__tests__/utils.test.ts +223 -0
  247. package/template/packages/utils/src/array.ts +18 -0
  248. package/template/packages/utils/src/async.ts +3 -0
  249. package/template/packages/utils/src/date.ts +77 -0
  250. package/template/packages/utils/src/errors.ts +73 -0
  251. package/template/packages/utils/src/number.ts +11 -0
  252. package/template/packages/utils/src/string.ts +13 -0
  253. package/template/packages/utils/tsconfig.json +5 -0
  254. package/template/packages/utils/vitest.config.ts +21 -0
  255. package/template/pnpm-workspace.yaml +4 -0
  256. package/template/tsconfig.base.json +32 -0
  257. package/template/turbo.json +133 -0
  258. package/template/vitest.shared.ts +26 -0
  259. package/template/vitest.workspace.ts +9 -0
@@ -0,0 +1,157 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, development]
6
+ pull_request:
7
+ branches: [main, development]
8
+
9
+ # Cancel in-progress runs when a new commit is pushed
10
+ concurrency:
11
+ group: ${{ github.workflow }}-${{ github.ref }}
12
+ cancel-in-progress: true
13
+
14
+ jobs:
15
+ # Fast checks that can run in parallel
16
+ lint:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Setup pnpm
22
+ uses: pnpm/action-setup@v4
23
+
24
+ - name: Setup Node.js
25
+ uses: actions/setup-node@v4
26
+ with:
27
+ node-version: '20'
28
+ cache: 'pnpm'
29
+
30
+ - name: Install dependencies
31
+ run: pnpm install --frozen-lockfile
32
+
33
+ - name: Run lint
34
+ run: pnpm run lint
35
+
36
+ typecheck:
37
+ runs-on: ubuntu-latest
38
+ steps:
39
+ - uses: actions/checkout@v4
40
+
41
+ - name: Setup pnpm
42
+ uses: pnpm/action-setup@v4
43
+
44
+ - name: Setup Node.js
45
+ uses: actions/setup-node@v4
46
+ with:
47
+ node-version: '20'
48
+ cache: 'pnpm'
49
+
50
+ - name: Install dependencies
51
+ run: pnpm install --frozen-lockfile
52
+
53
+ - name: Create .env for Prisma
54
+ run: echo "DATABASE_URL=postgresql://user:pass@localhost:5432/db" > apps/api/.env
55
+
56
+ - name: Generate Prisma Client
57
+ run: pnpm --filter @repo/api db:generate
58
+
59
+ - name: Run typecheck
60
+ run: pnpm run typecheck --filter '!@repo/api' # FIXME: Temporary workaround because of prisma v7 issues
61
+
62
+ # Tests and build run after lint/typecheck pass
63
+ test:
64
+ runs-on: ubuntu-latest
65
+ needs: [lint, typecheck]
66
+
67
+ # PostgreSQL service for integration tests
68
+ services:
69
+ postgres:
70
+ image: postgres:17-alpine
71
+ env:
72
+ POSTGRES_USER: postgres
73
+ POSTGRES_PASSWORD: postgres
74
+ POSTGRES_DB: app_dev_test
75
+ POSTGRES_HOST_AUTH_METHOD: trust
76
+ options: >-
77
+ --health-cmd "pg_isready -U postgres"
78
+ --health-interval 10s
79
+ --health-timeout 5s
80
+ --health-retries 5
81
+ ports:
82
+ - 5432:5432
83
+
84
+ env:
85
+ NODE_ENV: test
86
+ DATABASE_URL: postgresql://postgres:postgres@localhost:5432/app_dev
87
+ API_URL: http://localhost:8080
88
+ FRONTEND_URL: http://localhost:3000
89
+ PORT: 8080
90
+ LOG_LEVEL: minimal
91
+ COOKIE_SECRET: test-cookie-secret-for-ci
92
+ BETTER_AUTH_SECRET: test-secret-minimum-32-characters-long-for-ci
93
+ BETTER_AUTH_URL: http://localhost:8080
94
+
95
+ steps:
96
+ - uses: actions/checkout@v4
97
+
98
+ - name: Setup pnpm
99
+ uses: pnpm/action-setup@v4
100
+
101
+ - name: Setup Node.js
102
+ uses: actions/setup-node@v4
103
+ with:
104
+ node-version: '20'
105
+ cache: 'pnpm'
106
+
107
+ - name: Install dependencies
108
+ run: pnpm install --frozen-lockfile
109
+
110
+ - name: Generate Prisma Client
111
+ run: cd apps/api && npx prisma generate
112
+
113
+ - name: Run tests
114
+ run: pnpm run test
115
+
116
+ build:
117
+ runs-on: ubuntu-latest
118
+ needs: [lint, typecheck]
119
+ steps:
120
+ - uses: actions/checkout@v4
121
+
122
+ - name: Setup pnpm
123
+ uses: pnpm/action-setup@v4
124
+
125
+ - name: Setup Node.js
126
+ uses: actions/setup-node@v4
127
+ with:
128
+ node-version: '20'
129
+ cache: 'pnpm'
130
+
131
+ - name: Install dependencies
132
+ run: pnpm install --frozen-lockfile
133
+
134
+ - name: Generate Prisma Client
135
+ run: pnpm --filter @repo/api db:generate
136
+
137
+ - name: Setup Turborepo cache
138
+ uses: actions/cache@v4
139
+ with:
140
+ path: .turbo
141
+ key: ${{ runner.os }}-turbo-${{ github.sha }}
142
+ restore-keys: |
143
+ ${{ runner.os }}-turbo-
144
+
145
+ - name: Build
146
+ run: pnpm run build
147
+ env:
148
+ NODE_ENV: production
149
+ API_URL: 'http://localhost:8080'
150
+ FRONTEND_URL: 'http://localhost:3000'
151
+ DATABASE_URL: 'postgresql://user:pass@localhost:5432/db'
152
+ PORT: '8080'
153
+ LOG_LEVEL: 'minimal'
154
+ COOKIE_SECRET: 'ci-test-secret-not-for-production'
155
+ BETTER_AUTH_SECRET: 'ci-test-secret-not-for-production'
156
+ BETTER_AUTH_URL: 'http://localhost:8080'
157
+ NEXT_PUBLIC_API_URL: 'http://localhost:8080/api'
@@ -0,0 +1 @@
1
+ pnpm lint-staged
@@ -0,0 +1 @@
1
+ pnpm typecheck && pnpm test
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ '*.{ts,tsx,js,jsx}': ['eslint --fix', 'prettier --write'],
3
+ '*.{json,md,yml,yaml}': ['prettier --write'],
4
+ };
@@ -0,0 +1 @@
1
+ 20.0.0
@@ -0,0 +1,9 @@
1
+ {
2
+ "semi": true,
3
+ "trailingComma": "es5",
4
+ "singleQuote": true,
5
+ "printWidth": 80,
6
+ "tabWidth": 2,
7
+ "useTabs": false,
8
+ "plugins": ["prettier-plugin-tailwindcss"]
9
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "editor.formatOnSave": true,
3
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
4
+ "editor.codeActionsOnSave": {
5
+ "source.fixAll.eslint": "explicit"
6
+ },
7
+ "eslint.workingDirectories": [{ "mode": "auto" }],
8
+ "typescript.tsdk": "node_modules/typescript/lib",
9
+ "typescript.enablePromptUseWorkspaceTsdk": true,
10
+ "typescript.preferences.includePackageJsonAutoImports": "on",
11
+ "typescript.validate.enable": true,
12
+ "prisma.pinToPrisma6": false
13
+ }
@@ -0,0 +1,175 @@
1
+ # CLAUDE.md
2
+
3
+ You are a Senior Full-stack Developer and an Expert in TypeScript, Next.js 16, React 19, Fastify, Prisma v7, PostgreSQL, TailwindCSS v5, and shadcn/ui. You are collaborating with a human developer on a production-ready full-stack application.
4
+
5
+ ---
6
+
7
+ ## Critical Requirements & Constraints
8
+
9
+ ### Forbidden Behaviors
10
+
11
+ - NEVER create markdown files unless the user explicitly asks for it. This is very important
12
+ - NEVER create `index.ts` barrel files. This is a strict requirement
13
+ - AVOID writing comments in code unless absolutely necessary for non-obvious edge cases
14
+
15
+ ### Workflow Requirements
16
+
17
+ - Make sure you aggressively prefer planning and waiting for user confirmation before writing code for medium to big tasks. This is a strict requirement
18
+ - If you are unsure about anything, ask the user for clarification. This is a strict requirement
19
+ - Prefer using commands or exec scripts (like `pnpm dlx`) for setup related tasks instead of making all the files manually. In case the command requires interactive input, ask the user to do it themselves and provide them with suitable guidance
20
+
21
+ ### Collaboration Principles
22
+
23
+ - Always be unbiased towards the code, the user's preference and opinions. If you do not agree with the user, make it clear with them. Treat them like a peer
24
+ - Always mention alternative approaches to the user if you think it's necessary
25
+ - Do not be afraid of hurting the user's feelings or making them feel bad about their skills. Having well-written and maintainable code is significantly more important than cozying up to the user
26
+ - Always give a brief and compact summary of all the changes done
27
+
28
+ ---
29
+
30
+ ## Common Commands
31
+
32
+ ### Development Commands
33
+
34
+ ```bash
35
+ pnpm dev
36
+ pnpm build
37
+ pnpm typecheck
38
+ pnpm test
39
+ pnpm test:unit
40
+ pnpm test:integration
41
+ pnpm lint
42
+ ```
43
+
44
+ ### Individual Package Commands
45
+
46
+ ```bash
47
+ # Web (Next.js on port 3000)
48
+ cd apps/web
49
+ pnpm dev
50
+ pnpm typecheck
51
+
52
+ # API (Fastify on port 8080)
53
+ cd apps/api
54
+ pnpm dev
55
+ pnpm start
56
+ ```
57
+
58
+ ### Database Commands (run from `apps/api`)
59
+
60
+ ```bash
61
+ pnpm db:generate # Generate Prisma Client
62
+ pnpm db:migrate # Create and apply migrations
63
+ pnpm db:push # Push schema changes (no migration files)
64
+ pnpm db:studio # Open Prisma Studio UI
65
+ pnpm db:seed # Seed database
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Coding Standards
71
+
72
+ ### Code Style
73
+
74
+ - Type Definitions: Prefer `interface` for public-facing types and object shapes, `type` for unions, intersections, and computed types
75
+ - Use descriptive variable names with auxiliary verbs (`isLoading`, `hasError`, `canSubmit`)
76
+ - Favor default exports for pages and named exports for utilities or functions
77
+ - **IMPORTANT**: Always use import aliases for files in apps. For packages, use relative imports.
78
+
79
+ ### Error Handling
80
+
81
+ - Use our custom error classes from `packages/utils/src/errors.ts`
82
+ - Provide user-friendly error messages and avoid leaking implementation details
83
+
84
+ ---
85
+
86
+ ## Project Architecture
87
+
88
+ ### Packages
89
+
90
+ - All packages (`@repo/packages-types`, `@repo/packages-utils`) are consumed directly as TypeScript source files
91
+ - No build or watch required for these packages
92
+
93
+ ### Environment
94
+
95
+ - Environment variables are managed per-app with Zod validation
96
+ - Web: Only `NEXT_PUBLIC_*` variables are exposed to the browser
97
+ - Prisma CLI commands are wrapped with `dotenv-cli` to read from `.env.local`
98
+
99
+ ### Database
100
+
101
+ - The API uses Prisma 7 as the ORM with PostgreSQL
102
+ - Prisma queries are automatically logged based on `LOG_LEVEL`
103
+
104
+ ### Type Safety & Validation
105
+
106
+ - The codebase emphasizes runtime and compile-time type safety with **Zod v4 as the single validation library** across the entire stack
107
+ - No class-validator
108
+
109
+ ### Testing
110
+
111
+ Unit Tests: `*.spec.ts`
112
+ Integration Tests: `*.integration.spec.ts`
113
+
114
+ ### Authentication
115
+
116
+ - Uses Better Auth
117
+ - When creating test users with password auth, set `accountId` to the user's email (not user.id)
118
+
119
+ ---
120
+
121
+ ## Web Architecture Patterns
122
+
123
+ ### State Management
124
+
125
+ - TanStack Query (React Query): For API calls and data synchronization
126
+ - Jotai: For client-side global state (UI state, user preferences)
127
+
128
+ ### API Integration
129
+
130
+ - API config centralized in `apps/web/src/lib/api.ts`
131
+ - **API Response Unwrapping**: The `api.ts` fetcher unwraps `{ data: T }` to `T` but preserves `{ data: T[], pagination: {...} }` responses intact
132
+
133
+ ### Authentication & Protected Routes
134
+
135
+ The web app uses Better Auth for authentication with modern patterns:
136
+
137
+ - **Auth Client**: Configured in `apps/web/src/lib/auth.ts`
138
+ - Provides `useSession()` hook for accessing current user/session
139
+ - Handles sign in/out, session persistence via cookies
140
+ - **Protected Routes**: `<ProtectedRoute>` wrapper component for page-level protection
141
+
142
+ ### UI Component Patterns
143
+
144
+ - Use Shadcn UI components as base, extend them before creating custom ones
145
+ - Implement thoughtful micro-interactions and hover states wherever needed
146
+ - Use Framer Motion for animations, Lucide React for icons
147
+ - Prefer using `Skeleton` components for loading states instead of spinners (especially for data fetching components)
148
+ - Always create a proper loading state for data fetching components.
149
+ - Always use `cn` helper for class name merging
150
+ - Never write svg code. Always use existing icons from code or Lucide.
151
+
152
+ ---
153
+
154
+ ## API Architecture Patterns
155
+
156
+ ### Fastify Structure
157
+
158
+ - The Fastify API follows a plugin-based architecture
159
+ - Validation: Zod schemas directly in route definitions via `fastify-type-provider-zod`
160
+ - Dependency Injection: Manual DI via Fastify decorators
161
+
162
+ ### Logging
163
+
164
+ - The API uses Pino for structured logging with request tracing
165
+ - Verbosity controlled by `LOG_LEVEL` env var: `minimal` | `normal` | `detailed` | `verbose`
166
+ - **IMPORTANT**: Never use `console.log` in the API. Use the logger service instead
167
+
168
+ **Log Methods:**
169
+
170
+ - `logger.info(message, context?)` - Standard information
171
+ - `logger.error(message, error?, context?)` - Errors with automatic Error serialization
172
+ - `logger.warn(message, context?)` - Warnings
173
+ - `logger.debug(message, context?)` - Debug information (detailed+ level)
174
+ - `logger.trace(message, context?)` - Trace logs (verbose level only)
175
+ - `logger.perf(message, metrics)` - Performance metrics
@@ -0,0 +1,32 @@
1
+ # Contributing to Blitzpack
2
+
3
+ Thank you for your interest in contributing! This is a TypeScript monorepo template designed to help developers ship full-stack applications super fast.
4
+
5
+ ---
6
+
7
+ ## Setup
8
+
9
+ 1. Fork and clone the repository
10
+ 2. Run `pnpm install && pnpm init:project`
11
+ 3. Start development: `pnpm dev`
12
+
13
+ ## Development
14
+
15
+ 1. Create a feature branch: `git checkout -b feature/your-feature`
16
+ 2. Make changes following the code style in `CLAUDE.md`
17
+ 3. Run checks: `pnpm typecheck && pnpm lint && pnpm test && pnpm build`
18
+ 4. Commit like a sane person
19
+ 5. Push and create a Pull request
20
+
21
+ ## Code Style
22
+
23
+ - Follow patterns in `CLAUDE.md`
24
+ - Always use import aliases (`@/...`)
25
+
26
+ ## Pull Requests
27
+
28
+ - Rebase on latest main before submitting
29
+ - Ensure all CI checks pass
30
+ - Update documentation if needed
31
+
32
+ For detailed architecture and patterns, see `CLAUDE.md`.
@@ -0,0 +1,90 @@
1
+ # Multi-stage Dockerfile for API deployment
2
+ # Optimized for pnpm monorepo with Prisma
3
+
4
+ # Stage 1: Dependencies
5
+ FROM node:22-alpine AS deps
6
+ RUN apk add --no-cache libc6-compat openssl
7
+
8
+ # Install pnpm
9
+ RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
10
+
11
+ WORKDIR /app
12
+
13
+ # Copy workspace files
14
+ COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
15
+
16
+ # Copy all package.json files for workspace dependencies
17
+ COPY apps/api/package.json apps/api/
18
+ COPY packages/types/package.json packages/types/
19
+ COPY packages/utils/package.json packages/utils/
20
+
21
+ # Install dependencies (frozen lockfile for reproducible builds)
22
+ RUN pnpm install --frozen-lockfile --prod=false
23
+
24
+ # Stage 2: Builder
25
+ FROM node:22-alpine AS builder
26
+ RUN apk add --no-cache libc6-compat openssl
27
+
28
+ RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
29
+
30
+ WORKDIR /app
31
+
32
+ # Copy installed dependencies from deps stage
33
+ COPY --from=deps /app/node_modules ./node_modules
34
+ COPY --from=deps /app/apps/api/node_modules ./apps/api/node_modules
35
+ COPY --from=deps /app/packages/types/node_modules ./packages/types/node_modules
36
+ COPY --from=deps /app/packages/utils/node_modules ./packages/utils/node_modules
37
+
38
+ # Copy source code
39
+ COPY . .
40
+
41
+ # Build shared packages first (types and utils)
42
+ RUN pnpm --filter @repo/packages-types build
43
+ RUN pnpm --filter @repo/packages-utils build
44
+
45
+ # Generate Prisma Client
46
+ RUN pnpm --filter @repo/api db:generate
47
+
48
+ # Build the API
49
+ RUN pnpm --filter @repo/api build
50
+
51
+ # Stage 3: Runner (production)
52
+ FROM node:22-alpine AS runner
53
+ RUN apk add --no-cache openssl
54
+
55
+ RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
56
+
57
+ WORKDIR /app
58
+
59
+ # Create non-root user for security
60
+ RUN addgroup --system --gid 1001 nodejs && \
61
+ adduser --system --uid 1001 fastify
62
+
63
+ # Copy necessary files from builder
64
+ COPY --from=builder --chown=fastify:nodejs /app/apps/api/dist ./apps/api/dist
65
+ COPY --from=builder --chown=fastify:nodejs /app/apps/api/package.json ./apps/api/
66
+ COPY --from=builder --chown=fastify:nodejs /app/apps/api/prisma ./apps/api/prisma
67
+ COPY --from=builder --chown=fastify:nodejs /app/apps/api/start.sh ./apps/api/
68
+ COPY --from=builder --chown=fastify:nodejs /app/packages ./packages
69
+ COPY --from=builder --chown=fastify:nodejs /app/node_modules ./node_modules
70
+ COPY --from=builder --chown=fastify:nodejs /app/apps/api/node_modules ./apps/api/node_modules
71
+ COPY --from=builder --chown=fastify:nodejs /app/package.json ./package.json
72
+ COPY --from=builder --chown=fastify:nodejs /app/pnpm-workspace.yaml ./pnpm-workspace.yaml
73
+
74
+ # Make start script executable
75
+ RUN chmod +x /app/apps/api/start.sh
76
+
77
+ # Switch to non-root user
78
+ USER fastify
79
+
80
+ WORKDIR /app/apps/api
81
+
82
+ # Expose the API port
83
+ EXPOSE 8080
84
+
85
+ # Health check
86
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
87
+ CMD node -e "require('http').get('http://localhost:8080/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
88
+
89
+ # Start command (handles database wake-up, runs migrations, then starts server)
90
+ CMD ["/app/apps/api/start.sh"]
@@ -0,0 +1,35 @@
1
+ # Blitzpack Template Setup
2
+
3
+ After clicking "Use this template" and cloning your repository:
4
+
5
+ ## Quick Start (Use As-Is)
6
+
7
+ ```bash
8
+ pnpm install
9
+ pnpm init:project
10
+ pnpm dev
11
+ ```
12
+
13
+ **That's it!** The template works out of the box. Customize when ready.
14
+
15
+ ## When You're Ready to Customize
16
+
17
+ ### Update Branding
18
+
19
+ - `apps/web/src/config/site.ts` → Project name, description, GitHub URL
20
+ - `README.md` → Replace Blitzpack README.md with yours
21
+
22
+ ### Optional: Change Database Credentials
23
+
24
+ Default credentials: `postgres/postgres_dev_password/app_dev`
25
+
26
+ To use different credentials:
27
+
28
+ 1. Update `docker-compose.yml` (POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB)
29
+ 2. Update `apps/api/.env.local` (DATABASE_URL must match step 1)
30
+ 3. Restart Docker: `docker compose down && docker compose up -d`
31
+ 4. Run migrations: `pnpm --filter @repo/api db:migrate`
32
+
33
+ ---
34
+
35
+ **Delete this file when done.**
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Arman Ganjoo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,116 @@
1
+ <div align="center">
2
+ <img src="assets/logo.svg" alt="Blitzpack Logo" width="200">
3
+ <h1>Blitzpack</h1>
4
+ <p>Full-stack TypeScript monorepo template with Next.js, Fastify, and Turborepo. From zero to production in minutes.</p>
5
+
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
7
+ [![Node.js](https://img.shields.io/badge/Node.js-≥20.0.0-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
8
+ [![pnpm](https://img.shields.io/badge/pnpm-≥9.0.0-F69220?logo=pnpm&logoColor=white)](https://pnpm.io/)
9
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
10
+ [![CI](https://github.com/CarboxyDev/blitzpack/actions/workflows/ci.yml/badge.svg)](https://github.com/CarboxyDev/blitzpack/actions/workflows/ci.yml)
11
+
12
+ </div>
13
+
14
+ ---
15
+
16
+ ## Why Blitzpack?
17
+
18
+ Stop wasting days bootstrapping your next project. Most templates hand you a skeleton and leave you to figure out database migrations, API documentation, logging infrastructure, and much more. Blitzpack ships with all of it configured and working. You just need to run a single script to get started with a production-ready full-stack application.
19
+
20
+ **Ship your next project faster with battle-tested infrastructure already wired up.**
21
+
22
+ - **Zero-config setup**: Run one command and you're ready to code. Environment files, Docker containers, database migrations—all handled automatically.
23
+
24
+ - **Full-stack type safety**: Zod schemas define your API contracts once in `packages/types`, then flow automatically to web forms, API validation, and database queries. No duplicate validation logic.
25
+
26
+ - **Production-grade infrastructure**: Better-auth with session management and OAuth ready. Request ID tracing, automatic validation, rate limiting, structured logging, and environment-aware error responses out of the box.
27
+
28
+ - **AI pair programming ready**: Comprehensive CLAUDE.md file means AI assistants understand your architecture instantly and can accelerate your development.
29
+
30
+ ## Tech Stack
31
+
32
+ **Web:** Next.js, React, TanStack Query, Tailwind CSS
33
+
34
+ **Backend:** Fastify, Prisma, PostgreSQL
35
+
36
+ **Monorepo:** Turborepo, pnpm workspaces
37
+
38
+ <details>
39
+ <summary>Full stack details</summary>
40
+
41
+ <p>
42
+
43
+ **Web**
44
+
45
+ - Next.js 16 + React 19
46
+ - TanStack Query v5 for server state
47
+ - shadcn/ui + Tailwind CSS v4
48
+ - React Hook Form + Zod validation
49
+ - Jotai for client state
50
+
51
+ **API**
52
+
53
+ - Fastify 5
54
+ - Prisma 7 + PostgreSQL 17
55
+ - Better-auth for authentication
56
+ - Pino for logging
57
+ - Scalar API docs
58
+ - Helmet + rate limiting
59
+
60
+ **Monorepo**
61
+
62
+ - pnpm workspaces + Turborepo
63
+ - Shared packages for types, utils, config in `packages/`
64
+ - Vitest for testing
65
+ - Husky + lint-staged for pre-commit hooks
66
+ </p>
67
+ </details>
68
+
69
+ ## Quick Start
70
+
71
+ ```bash
72
+ # Install dependencies
73
+ pnpm install
74
+
75
+ # Automated setup (creates .env files, starts docker, runs migrations)
76
+ pnpm init:project
77
+
78
+ # Start development
79
+ pnpm dev
80
+ ```
81
+
82
+ The setup script handles everything: environment files, docker containers, database migrations, and optional seeding. Safe to run multiple times.
83
+
84
+ You must have docker installed and running on your machine.
85
+
86
+ **What's running:**
87
+
88
+ - Web: [http://localhost:3000](http://localhost:3000)
89
+ - API: [http://localhost:8080/api](http://localhost:8080/api)
90
+ - API Docs: [http://localhost:8080/docs](http://localhost:8080/docs)
91
+ - Health Check: [http://localhost:8080/health](http://localhost:8080/health)
92
+
93
+ **Database tools:**
94
+
95
+ - Prisma Studio: Run `pnpm db:studio` to open [http://localhost:5555](http://localhost:5555) (recommended for data inspection)
96
+
97
+ **Built-in pages:**
98
+
99
+ - `/examples` - Component examples
100
+ - `/dashboard` - Protected user dashboard
101
+ - `/login` - Sign in page
102
+ - `/signup` - Create new account
103
+ - `/forgot-password` - Forgot password page
104
+ - `/reset-password` - Reset password page
105
+
106
+ ## Project Structure
107
+
108
+ ```
109
+ blitzpack/
110
+ ├── apps/
111
+ │ ├── web/ # Next.js app
112
+ │ └── api/ # Fastify API
113
+ └── packages/
114
+ ├── types/ # Zod schemas + inferred types
115
+ └── utils/ # Shared utilities
116
+ ```