@amirulabu/create-recurring-rabbit-app 0.0.0-alpha

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 (64) hide show
  1. package/bin/index.js +2 -0
  2. package/dist/index.js +592 -0
  3. package/package.json +43 -0
  4. package/templates/default/.editorconfig +21 -0
  5. package/templates/default/.env.example +15 -0
  6. package/templates/default/.eslintrc.json +35 -0
  7. package/templates/default/.prettierrc.json +7 -0
  8. package/templates/default/README.md +346 -0
  9. package/templates/default/app.config.ts +20 -0
  10. package/templates/default/docs/adding-features.md +439 -0
  11. package/templates/default/docs/adr/001-use-sqlite-for-development-database.md +22 -0
  12. package/templates/default/docs/adr/002-use-tanstack-start-over-nextjs.md +22 -0
  13. package/templates/default/docs/adr/003-use-better-auth-over-nextauth.md +22 -0
  14. package/templates/default/docs/adr/004-use-drizzle-over-prisma.md +22 -0
  15. package/templates/default/docs/adr/005-use-trpc-for-api-layer.md +22 -0
  16. package/templates/default/docs/adr/006-use-tailwind-css-v4-with-shadcn-ui.md +22 -0
  17. package/templates/default/docs/architecture.md +241 -0
  18. package/templates/default/docs/database.md +376 -0
  19. package/templates/default/docs/deployment.md +435 -0
  20. package/templates/default/docs/troubleshooting.md +668 -0
  21. package/templates/default/drizzle/migrations/0001_initial_schema.sql +39 -0
  22. package/templates/default/drizzle/migrations/meta/0001_snapshot.json +225 -0
  23. package/templates/default/drizzle/migrations/meta/_journal.json +12 -0
  24. package/templates/default/drizzle.config.ts +10 -0
  25. package/templates/default/lighthouserc.json +78 -0
  26. package/templates/default/src/app/__root.tsx +32 -0
  27. package/templates/default/src/app/api/auth/$.ts +15 -0
  28. package/templates/default/src/app/api/trpc.server.ts +12 -0
  29. package/templates/default/src/app/auth/forgot-password.tsx +107 -0
  30. package/templates/default/src/app/auth/login.tsx +34 -0
  31. package/templates/default/src/app/auth/register.tsx +34 -0
  32. package/templates/default/src/app/auth/reset-password.tsx +171 -0
  33. package/templates/default/src/app/auth/verify-email.tsx +111 -0
  34. package/templates/default/src/app/dashboard/index.tsx +122 -0
  35. package/templates/default/src/app/dashboard/settings.tsx +161 -0
  36. package/templates/default/src/app/globals.css +55 -0
  37. package/templates/default/src/app/index.tsx +83 -0
  38. package/templates/default/src/components/features/auth/login-form.tsx +172 -0
  39. package/templates/default/src/components/features/auth/register-form.tsx +202 -0
  40. package/templates/default/src/components/layout/dashboard-layout.tsx +27 -0
  41. package/templates/default/src/components/layout/header.tsx +29 -0
  42. package/templates/default/src/components/layout/sidebar.tsx +38 -0
  43. package/templates/default/src/components/ui/button.tsx +57 -0
  44. package/templates/default/src/components/ui/card.tsx +79 -0
  45. package/templates/default/src/components/ui/input.tsx +24 -0
  46. package/templates/default/src/lib/api.ts +42 -0
  47. package/templates/default/src/lib/auth.ts +292 -0
  48. package/templates/default/src/lib/email.ts +221 -0
  49. package/templates/default/src/lib/env.ts +119 -0
  50. package/templates/default/src/lib/hydration-timing.ts +289 -0
  51. package/templates/default/src/lib/monitoring.ts +336 -0
  52. package/templates/default/src/lib/utils.ts +6 -0
  53. package/templates/default/src/server/api/root.ts +10 -0
  54. package/templates/default/src/server/api/routers/dashboard.ts +37 -0
  55. package/templates/default/src/server/api/routers/user.ts +31 -0
  56. package/templates/default/src/server/api/trpc.ts +132 -0
  57. package/templates/default/src/server/auth/config.ts +241 -0
  58. package/templates/default/src/server/db/index.ts +153 -0
  59. package/templates/default/src/server/db/migrate.ts +125 -0
  60. package/templates/default/src/server/db/schema.ts +170 -0
  61. package/templates/default/src/server/db/seed.ts +130 -0
  62. package/templates/default/src/types/global.d.ts +25 -0
  63. package/templates/default/tailwind.config.js +46 -0
  64. package/templates/default/tsconfig.json +36 -0
@@ -0,0 +1,435 @@
1
+ # Deployment Guide
2
+
3
+ ## Platform Options
4
+
5
+ ### Vercel (Recommended)
6
+
7
+ **Zero-config deployment from GitHub**
8
+
9
+ ```bash
10
+ vercel deploy
11
+ ```
12
+
13
+ **Features:**
14
+
15
+ - Automatic HTTPS and CDN
16
+ - Environment variable management
17
+ - PostgreSQL add-on available
18
+ - Automatic builds on git push
19
+ - Preview deployments for pull requests
20
+
21
+ **Steps:**
22
+
23
+ 1. Push code to GitHub
24
+ 2. Import project in Vercel
25
+ 3. Configure environment variables (see below)
26
+ 4. Add Vercel Postgres or Railway database
27
+ 5. Deploy
28
+
29
+ **Vercel Postgres Setup:**
30
+
31
+ - Go to project settings → Storage → Postgres
32
+ - Create database
33
+ - Copy connection string to `DATABASE_URL`
34
+
35
+ ### Railway
36
+
37
+ **Simple git-based deployment**
38
+
39
+ ```bash
40
+ railway up
41
+ ```
42
+
43
+ **Features:**
44
+
45
+ - Built-in PostgreSQL hosting
46
+ - Automatic domain assignment
47
+ - Environment variable management
48
+ - Auto-scaling
49
+
50
+ **Steps:**
51
+
52
+ 1. Push code to GitHub
53
+ 2. New Project in Railway
54
+ 3. Connect GitHub repository
55
+ 4. Configure environment variables
56
+ 5. Railway Postgres is auto-created
57
+ 6. Deploy
58
+
59
+ ### Self-Hosted Docker
60
+
61
+ **Full control over infrastructure**
62
+
63
+ ```dockerfile
64
+ FROM node:18-alpine
65
+ WORKDIR /app
66
+ COPY package*.json ./
67
+ RUN npm ci --only=production
68
+ COPY . .
69
+ RUN npm run build
70
+ EXPOSE 3000
71
+ CMD ["npm", "start"]
72
+ ```
73
+
74
+ ```bash
75
+ docker build -t my-app .
76
+ docker run -p 3000:3000 -e DATABASE_URL="postgres://..." my-app
77
+ ```
78
+
79
+ **Features:**
80
+
81
+ - Complete infrastructure control
82
+ - Cost-effective for higher traffic
83
+ - Custom domain and SSL
84
+
85
+ ## Production Checklist
86
+
87
+ ### Database Setup
88
+
89
+ - [ ] PostgreSQL instance created (Vercel Postgres, Railway, Supabase, etc.)
90
+ - [ ] Database URL added to environment variables
91
+ - [ ] Migrations run against production database
92
+ - [ ] Connection pooling configured (automatic in app)
93
+
94
+ ### Environment Variables
95
+
96
+ #### Required Variables
97
+
98
+ | Variable | Description | How to Generate |
99
+ | -------------------- | ---------------------------- | ------------------------------------------------- |
100
+ | `BETTER_AUTH_SECRET` | Secret for session signing | Generate 32+ random chars: `openssl rand -hex 32` |
101
+ | `DATABASE_URL` | PostgreSQL connection string | Get from database provider |
102
+ | `RESEND_API_KEY` | Email service API key | Get from [Resend](https://resend.com) |
103
+
104
+ #### Optional Variables
105
+
106
+ | Variable | Description | Default |
107
+ | ----------------- | ---------------------- | ----------------------- |
108
+ | `BETTER_AUTH_URL` | Your production domain | `PUBLIC_APP_URL` |
109
+ | `PUBLIC_APP_URL` | Your production domain | `http://localhost:3000` |
110
+ | `NODE_ENV` | Environment | `production` |
111
+
112
+ **Vercel Environment Variables:**
113
+
114
+ - Go to project settings → Environment Variables
115
+ - Add all required variables
116
+ - Select appropriate scope (production, preview, development)
117
+
118
+ **Railway Environment Variables:**
119
+
120
+ - Go to project → Variables
121
+ - Add all required variables
122
+ - Railway provides DATABASE_URL automatically
123
+
124
+ ### Domain & SSL
125
+
126
+ - [ ] Custom domain configured
127
+ - [ ] SSL certificate active (automatic on Vercel/Railway)
128
+ - [ ] Redirects from www/non-www setup
129
+
130
+ **Vercel Domain Setup:**
131
+
132
+ - Go to project settings → Domains
133
+ - Add custom domain
134
+ - Update DNS records as instructed
135
+
136
+ ### Email Configuration
137
+
138
+ - [ ] Resend account verified with production domain
139
+ - [ ] Email templates customized with your branding
140
+ - [ ] SPF/DKIM records configured for deliverability
141
+
142
+ **SPF Record:**
143
+
144
+ ```
145
+ @ IN TXT "v=spf1 include:resend.com ~all"
146
+ ```
147
+
148
+ **DKIM Record:**
149
+ Get from Resend → Domains → Your domain → DKIM
150
+ Add as TXT record in your DNS provider.
151
+
152
+ ### Performance & Monitoring
153
+
154
+ - [ ] Error tracking configured (Sentry, Vercel Analytics)
155
+ - [ ] Performance monitoring enabled
156
+ - [ ] Database connection limits appropriate for plan
157
+ - [ ] CDN configured (automatic on Vercel)
158
+
159
+ ## Scaling Considerations
160
+
161
+ ### Database Optimization
162
+
163
+ #### Monitor Slow Queries
164
+
165
+ Check database provider's dashboard for slow query logs.
166
+ Add indexes for frequently queried columns:
167
+
168
+ ```typescript
169
+ export const users = sqliteTable(
170
+ 'users',
171
+ {
172
+ id: text('id').primaryKey(),
173
+ email: text('email').notNull(),
174
+ // Add index
175
+ },
176
+ (table) => ({
177
+ emailIdx: index('email_idx').on(table.email),
178
+ })
179
+ )
180
+ ```
181
+
182
+ #### Connection Pooling
183
+
184
+ Production app uses connection pooling:
185
+
186
+ - Development: 5 connections
187
+ - Production: 20 connections
188
+
189
+ Adjust in `src/server/db/index.ts` if needed:
190
+
191
+ ```typescript
192
+ const pool = new Pool({
193
+ connectionString: env.DATABASE_URL,
194
+ max: 20, // Adjust based on plan
195
+ })
196
+ ```
197
+
198
+ ### CDN & Caching
199
+
200
+ #### Static Assets
201
+
202
+ Automatic on Vercel/Railway:
203
+
204
+ - CSS/JS files cached
205
+ - Images optimized
206
+ - Gzip compression enabled
207
+
208
+ #### API Response Caching
209
+
210
+ Cache tRPC queries with TanStack Query:
211
+
212
+ ```typescript
213
+ const { data } = api.myQuery.useQuery({
214
+ staleTime: 1000 * 60 * 5, // 5 minutes
215
+ })
216
+ ```
217
+
218
+ ### Security Hardening
219
+
220
+ - [ ] Rate limiting on authentication endpoints (already configured)
221
+ - [ ] Regular dependency updates
222
+ - [ ] Security headers configured
223
+
224
+ **Content Security Policy** (Vercel):
225
+
226
+ ```javascript
227
+ // vercel.json
228
+ {
229
+ "headers": [
230
+ {
231
+ "source": "/(.*)",
232
+ "headers": [
233
+ {
234
+ "key": "X-Content-Type-Options",
235
+ "value": "nosniff"
236
+ },
237
+ {
238
+ "key": "X-Frame-Options",
239
+ "value": "DENY"
240
+ }
241
+ ]
242
+ }
243
+ ]
244
+ }
245
+ ```
246
+
247
+ ## Migration to Production
248
+
249
+ ### Step-by-Step Process
250
+
251
+ 1. **Prepare Production Database**
252
+ - Create PostgreSQL instance
253
+ - Copy connection string
254
+ - Test connection locally if possible
255
+
256
+ 2. **Configure Environment Variables**
257
+ - Set `BETTER_AUTH_SECRET` (new random string)
258
+ - Set `DATABASE_URL` (PostgreSQL connection)
259
+ - Set `RESEND_API_KEY` (production key)
260
+ - Set `PUBLIC_APP_URL` (your domain)
261
+
262
+ 3. **Run Migrations**
263
+
264
+ ```bash
265
+ DATABASE_URL="postgres://..." npm run db:migrate
266
+ ```
267
+
268
+ 4. **Build Production Bundle**
269
+
270
+ ```bash
271
+ npm run build
272
+ ```
273
+
274
+ 5. **Deploy**
275
+ - Vercel: `vercel deploy --prod`
276
+ - Railway: `git push railway master`
277
+
278
+ 6. **Verify Deployment**
279
+ - Check build logs
280
+ - Test authentication flow
281
+ - Verify database connectivity
282
+ - Test email delivery
283
+
284
+ ### Common Deployment Issues
285
+
286
+ #### Database Connection Failed
287
+
288
+ **Issue:** `Error: connect ENOENT /data/app.db`
289
+
290
+ **Cause:** Production trying to use SQLite instead of PostgreSQL
291
+
292
+ **Solution:** Ensure `DATABASE_URL` environment variable is set in production
293
+
294
+ #### Environment Variables Not Found
295
+
296
+ **Issue:** `BETTER_AUTH_SECRET is required`
297
+
298
+ **Cause:** Missing environment variable in deployment platform
299
+
300
+ **Solution:**
301
+
302
+ - Vercel: Check Environment Variables section
303
+ - Railway: Check Variables section
304
+ - Docker: Use `-e DATABASE_URL="..."` flag
305
+
306
+ #### Build Fails
307
+
308
+ **Issue:** Build fails during deployment
309
+
310
+ **Common Causes:**
311
+
312
+ - Missing dependency in package.json
313
+ - TypeScript errors not caught locally
314
+ - Environment validation errors
315
+
316
+ **Solution:**
317
+
318
+ 1. Run `npm run typecheck` locally
319
+ 2. Run `npm run build` locally
320
+ 3. Check build logs in platform dashboard
321
+
322
+ #### Email Not Sending in Production
323
+
324
+ **Issue:** Emails work in dev but not in production
325
+
326
+ **Cause:** RESEND_API_KEY not set or wrong
327
+
328
+ **Solution:**
329
+
330
+ 1. Verify API key is set in production environment variables
331
+ 2. Check API key is not from test environment
332
+ 3. Verify domain is verified in Resend dashboard
333
+
334
+ ## Monitoring & Observability
335
+
336
+ ### Vercel Analytics
337
+
338
+ Automatically enabled on Vercel deployments:
339
+
340
+ - Page views
341
+ - Web Vitals (LCP, FID, CLS)
342
+ - Geolocation data
343
+
344
+ ### Database Monitoring
345
+
346
+ Check provider dashboard for:
347
+
348
+ - Connection counts
349
+ - Query performance
350
+ - Storage usage
351
+ - CPU usage
352
+
353
+ ### Application Monitoring
354
+
355
+ Consider adding:
356
+
357
+ - **Sentry** for error tracking
358
+ - **LogRocket** for session replay
359
+ - **Datadog** for infrastructure monitoring
360
+
361
+ ## Continuous Deployment
362
+
363
+ ### GitHub Integration
364
+
365
+ **Vercel:**
366
+
367
+ 1. Go to project settings → Git
368
+ 2. Connect GitHub repository
369
+ 3. Configure branch (master → production)
370
+ 4. Every push triggers deployment
371
+
372
+ **Railway:**
373
+
374
+ 1. Go to project → GitHub
375
+ 2. Connect repository
376
+ 3. Configure branch
377
+ 4. Every push triggers deployment
378
+
379
+ ### Preview Deployments
380
+
381
+ Test changes before production:
382
+
383
+ ```bash
384
+ # Create pull request
385
+ # Vercel creates preview deployment
386
+ # Test on preview URL
387
+ # Merge when ready
388
+ ```
389
+
390
+ ## Backup & Recovery
391
+
392
+ ### Database Backups
393
+
394
+ **Vercel Postgres:**
395
+
396
+ - Automatic backups included
397
+ - Restorable from dashboard
398
+
399
+ **Railway:**
400
+
401
+ - Automatic snapshots included
402
+ - Point-in-time recovery
403
+
404
+ **Supabase:**
405
+
406
+ - Daily backups included
407
+ - 30-day retention
408
+
409
+ ### Rollback Procedure
410
+
411
+ If deployment breaks production:
412
+
413
+ ```bash
414
+ # Vercel
415
+ vercel rollback --scope=your-project
416
+
417
+ # Railway
418
+ # Revert git commit and push
419
+ git revert HEAD
420
+ git push
421
+ ```
422
+
423
+ ## Post-Launch Checklist
424
+
425
+ - [ ] All environment variables set
426
+ - [ ] Database migrations applied
427
+ - [ ] Email sending verified
428
+ - [ ] Domain SSL active
429
+ - [ ] Analytics working
430
+ - [ ] Error tracking enabled
431
+ - [ ] Performance budgets met
432
+ - [ ] Backup plan configured
433
+ - [ ] Monitoring set up
434
+ - [ ] Team has access to deployment platform
435
+ - [ ] On-call rotation established (if team)