@odvi/create-dtt-framework 0.1.3 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +16 -13
- package/dist/commands/create.js.map +1 -1
- package/package.json +3 -2
- package/template/.env.example +106 -0
- package/template/components.json +22 -0
- package/template/docs/framework/01-overview.md +289 -0
- package/template/docs/framework/02-techstack.md +503 -0
- package/template/docs/framework/api-layer.md +681 -0
- package/template/docs/framework/clerk-authentication.md +649 -0
- package/template/docs/framework/cli-installation.md +564 -0
- package/template/docs/framework/deployment/ci-cd.md +907 -0
- package/template/docs/framework/deployment/digitalocean.md +991 -0
- package/template/docs/framework/deployment/domain-setup.md +972 -0
- package/template/docs/framework/deployment/environment-variables.md +862 -0
- package/template/docs/framework/deployment/monitoring.md +927 -0
- package/template/docs/framework/deployment/production-checklist.md +649 -0
- package/template/docs/framework/deployment/vercel.md +791 -0
- package/template/docs/framework/environment-variables.md +646 -0
- package/template/docs/framework/health-check-system.md +583 -0
- package/template/docs/framework/implementation.md +559 -0
- package/template/docs/framework/snowflake-integration.md +594 -0
- package/template/docs/framework/state-management.md +615 -0
- package/template/docs/framework/supabase-integration.md +582 -0
- package/template/docs/framework/testing-guide.md +544 -0
- package/template/docs/framework/what-did-i-miss.md +526 -0
- package/template/drizzle.config.ts +11 -0
- package/template/next.config.js +21 -0
- package/template/postcss.config.js +5 -0
- package/template/prettier.config.js +4 -0
- package/template/public/favicon.ico +0 -0
- package/template/src/app/(auth)/layout.tsx +4 -0
- package/template/src/app/(auth)/sign-in/[[...sign-in]]/page.tsx +10 -0
- package/template/src/app/(auth)/sign-up/[[...sign-up]]/page.tsx +10 -0
- package/template/src/app/(dashboard)/dashboard/page.tsx +8 -0
- package/template/src/app/(dashboard)/health/page.tsx +16 -0
- package/template/src/app/(dashboard)/layout.tsx +17 -0
- package/template/src/app/api/[[...route]]/route.ts +11 -0
- package/template/src/app/api/debug-files/route.ts +33 -0
- package/template/src/app/api/webhooks/clerk/route.ts +112 -0
- package/template/src/app/layout.tsx +28 -0
- package/template/src/app/page.tsx +12 -0
- package/template/src/app/providers.tsx +20 -0
- package/template/src/components/layouts/navbar.tsx +14 -0
- package/template/src/components/shared/loading-spinner.tsx +6 -0
- package/template/src/components/ui/badge.tsx +46 -0
- package/template/src/components/ui/button.tsx +62 -0
- package/template/src/components/ui/card.tsx +92 -0
- package/template/src/components/ui/collapsible.tsx +33 -0
- package/template/src/components/ui/scroll-area.tsx +58 -0
- package/template/src/components/ui/sheet.tsx +139 -0
- package/template/src/config/__tests__/env.test.ts +164 -0
- package/template/src/config/__tests__/site.test.ts +46 -0
- package/template/src/config/env.ts +36 -0
- package/template/src/config/site.ts +10 -0
- package/template/src/env.js +44 -0
- package/template/src/features/__tests__/health-check-config.test.ts +142 -0
- package/template/src/features/__tests__/health-check-types.test.ts +201 -0
- package/template/src/features/documentation/components/doc-sidebar.tsx +109 -0
- package/template/src/features/documentation/components/doc-viewer.tsx +70 -0
- package/template/src/features/documentation/index.tsx +92 -0
- package/template/src/features/documentation/utils/doc-loader.ts +177 -0
- package/template/src/features/health-check/components/health-dashboard.tsx +374 -0
- package/template/src/features/health-check/config.ts +71 -0
- package/template/src/features/health-check/index.ts +4 -0
- package/template/src/features/health-check/stores/health-store.ts +14 -0
- package/template/src/features/health-check/types.ts +18 -0
- package/template/src/hooks/__tests__/use-debounce.test.tsx +28 -0
- package/template/src/hooks/queries/use-health-checks.ts +16 -0
- package/template/src/hooks/utils/use-debounce.ts +20 -0
- package/template/src/lib/__tests__/utils.test.ts +52 -0
- package/template/src/lib/__tests__/validators.test.ts +114 -0
- package/template/src/lib/nextbank/client.ts +67 -0
- package/template/src/lib/snowflake/client.ts +102 -0
- package/template/src/lib/supabase/admin.ts +7 -0
- package/template/src/lib/supabase/client.ts +7 -0
- package/template/src/lib/supabase/server.ts +23 -0
- package/template/src/lib/utils.ts +6 -0
- package/template/src/lib/validators.ts +9 -0
- package/template/src/middleware.ts +22 -0
- package/template/src/server/api/index.ts +22 -0
- package/template/src/server/api/middleware/auth.ts +19 -0
- package/template/src/server/api/middleware/logger.ts +4 -0
- package/template/src/server/api/routes/health/clerk.ts +214 -0
- package/template/src/server/api/routes/health/database.ts +141 -0
- package/template/src/server/api/routes/health/edge-functions.ts +107 -0
- package/template/src/server/api/routes/health/framework.ts +48 -0
- package/template/src/server/api/routes/health/index.ts +102 -0
- package/template/src/server/api/routes/health/nextbank.ts +46 -0
- package/template/src/server/api/routes/health/snowflake.ts +83 -0
- package/template/src/server/api/routes/health/storage.ts +177 -0
- package/template/src/server/api/routes/users.ts +79 -0
- package/template/src/server/db/index.ts +17 -0
- package/template/src/server/db/queries/users.ts +8 -0
- package/template/src/server/db/schema/__tests__/health-checks.test.ts +31 -0
- package/template/src/server/db/schema/__tests__/users.test.ts +46 -0
- package/template/src/server/db/schema/health-checks.ts +11 -0
- package/template/src/server/db/schema/index.ts +2 -0
- package/template/src/server/db/schema/users.ts +16 -0
- package/template/src/server/db/schema.ts +1 -0
- package/template/src/stores/__tests__/ui-store.test.ts +87 -0
- package/template/src/stores/ui-store.ts +14 -0
- package/template/src/styles/globals.css +129 -0
- package/template/src/test/mocks/clerk.ts +35 -0
- package/template/src/test/mocks/snowflake.ts +28 -0
- package/template/src/test/mocks/supabase.ts +37 -0
- package/template/src/test/setup.ts +69 -0
- package/template/src/test/utils/test-helpers.ts +158 -0
- package/template/src/types/index.ts +14 -0
- package/template/tsconfig.json +43 -0
- package/template/vitest.config.ts +44 -0
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
# DTT Framework - Tech Stack
|
|
2
|
+
|
|
3
|
+
## Complete Technology Stack
|
|
4
|
+
|
|
5
|
+
The DTT Framework uses a carefully curated set of modern technologies to provide a robust, type-safe, and developer-friendly foundation for building enterprise applications.
|
|
6
|
+
|
|
7
|
+
### Technology Stack Overview
|
|
8
|
+
|
|
9
|
+
| Layer | Technology | Version | Purpose |
|
|
10
|
+
|-------|-----------|---------|---------|
|
|
11
|
+
| **Framework** | Next.js | ^15.2.3 | Full-stack React framework with App Router |
|
|
12
|
+
| **Language** | TypeScript | ^5.8.2 | Type-safe development |
|
|
13
|
+
| **Runtime** | Node.js | 20+ | JavaScript runtime |
|
|
14
|
+
| **Package Manager** | pnpm | 10.26.1 | Fast, disk space efficient package manager |
|
|
15
|
+
| **Styling** | Tailwind CSS | ^4.0.15 | Utility-first CSS framework |
|
|
16
|
+
| **UI Components** | Shadcn/ui | Latest | Accessible component primitives |
|
|
17
|
+
| **Icons** | Lucide React | ^0.562.0 | Icon library |
|
|
18
|
+
| **Authentication** | Clerk | ^6.36.5 | User authentication & management |
|
|
19
|
+
| **Webhooks** | Svix | ^1.82.0 | Webhook delivery and verification |
|
|
20
|
+
| **Database** | Supabase (PostgreSQL) | Latest | Primary database |
|
|
21
|
+
| **ORM** | Drizzle ORM | ^0.41.0 | Type-safe database queries |
|
|
22
|
+
| **Database Driver** | postgres | ^3.4.4 | PostgreSQL driver |
|
|
23
|
+
| **Storage** | Supabase Storage | Latest | File storage |
|
|
24
|
+
| **Edge Functions** | Supabase Edge Functions | Latest | Serverless compute |
|
|
25
|
+
| **Data Warehouse** | Snowflake SDK | ^2.3.3 | Analytics & reporting |
|
|
26
|
+
| **API Framework** | Hono | ^4.11.3 | Lightweight API framework |
|
|
27
|
+
| **Server State** | TanStack Query | ^5.90.14 | Data fetching & caching |
|
|
28
|
+
| **Client State** | Zustand | ^5.0.9 | UI state management |
|
|
29
|
+
| **Validation** | Zod | ^3.24.2 | Schema validation |
|
|
30
|
+
| **Environment** | @t3-oss/env-nextjs | ^0.12.0 | Type-safe environment variables |
|
|
31
|
+
| **CSS Utilities** | clsx | ^2.1.1 | Conditional className utility |
|
|
32
|
+
| **CSS Utilities** | tailwind-merge | ^3.4.0 | Merge Tailwind classes |
|
|
33
|
+
| **Component Variants** | class-variance-authority | ^0.7.1 | Component variant management |
|
|
34
|
+
| **UI Primitives** | @radix-ui/react-slot | ^1.2.4 | Radix UI primitives |
|
|
35
|
+
| **UI Primitives** | @radix-ui/react-collapsible | ^1.1.12 | Collapsible component |
|
|
36
|
+
|
|
37
|
+
### Dev Dependencies
|
|
38
|
+
|
|
39
|
+
| Technology | Version | Purpose |
|
|
40
|
+
|------------|---------|---------|
|
|
41
|
+
| **Drizzle Kit** | ^0.30.5 | Database migrations and studio |
|
|
42
|
+
| **ESLint** | ^9.23.0 | Code linting |
|
|
43
|
+
| **ESLint Config Next** | ^15.2.3 | Next.js ESLint configuration |
|
|
44
|
+
| **ESLint Plugin Drizzle** | ^0.2.3 | Drizzle ORM linting |
|
|
45
|
+
| **TypeScript ESLint** | ^8.27.0 | TypeScript linting |
|
|
46
|
+
| **Prettier** | ^3.5.3 | Code formatting |
|
|
47
|
+
| **Prettier Plugin Tailwind** | ^0.6.11 | Tailwind class sorting |
|
|
48
|
+
| **PostCSS** | ^8.5.3 | CSS processing |
|
|
49
|
+
| **Tailwind PostCSS** | ^4.0.15 | Tailwind CSS PostCSS plugin |
|
|
50
|
+
| **Tw Animate CSS** | ^1.4.0 | Tailwind animations |
|
|
51
|
+
| **Type Definitions** | @types/node | ^20.14.10 | Node.js type definitions |
|
|
52
|
+
| **Type Definitions** | @types/react | ^19.0.0 | React type definitions |
|
|
53
|
+
| **Type Definitions** | @types/react-dom | ^19.0.0 | React DOM type definitions |
|
|
54
|
+
| **Type Definitions** | @types/snowflake-sdk | ^1.6.24 | Snowflake SDK type definitions |
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Technology Choices Explained
|
|
59
|
+
|
|
60
|
+
### Framework Layer
|
|
61
|
+
|
|
62
|
+
#### Next.js 15 with App Router
|
|
63
|
+
|
|
64
|
+
**Why Next.js?**
|
|
65
|
+
- **Full-Stack Capability**: Combines frontend and backend in a single framework
|
|
66
|
+
- **App Router**: Modern routing with React Server Components
|
|
67
|
+
- **Built-in Optimizations**: Image optimization, font optimization, automatic code splitting
|
|
68
|
+
- **API Routes**: Built-in API endpoint support
|
|
69
|
+
- **Edge Runtime**: Support for edge computing
|
|
70
|
+
- **Vercel Integration**: Seamless deployment to Vercel
|
|
71
|
+
|
|
72
|
+
**Why App Router?**
|
|
73
|
+
- **React Server Components**: Reduced client-side JavaScript
|
|
74
|
+
- **Streaming**: Progressive rendering for faster perceived performance
|
|
75
|
+
- **Nested Layouts**: Shared UI across routes
|
|
76
|
+
- **Route Groups**: Organize routes without affecting URL structure
|
|
77
|
+
|
|
78
|
+
**Version Requirements:**
|
|
79
|
+
- Node.js 20+ required
|
|
80
|
+
- React 19+ required
|
|
81
|
+
|
|
82
|
+
#### TypeScript 5.8
|
|
83
|
+
|
|
84
|
+
**Why TypeScript?**
|
|
85
|
+
- **Type Safety**: Catch errors at compile time
|
|
86
|
+
- **Better IDE Support**: Autocomplete, refactoring, inline documentation
|
|
87
|
+
- **Self-Documenting Code**: Types serve as documentation
|
|
88
|
+
- **Improved Maintainability**: Easier to understand and modify code
|
|
89
|
+
- **AI-Friendly**: Type information helps AI assistants understand code better
|
|
90
|
+
|
|
91
|
+
**Key Features Used:**
|
|
92
|
+
- **Type Inference**: Automatic type deduction
|
|
93
|
+
- **Generics**: Reusable type-safe components
|
|
94
|
+
- **Utility Types**: `Pick`, `Omit`, `Partial`, etc.
|
|
95
|
+
- **Strict Mode**: Maximum type safety
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
### Styling Layer
|
|
100
|
+
|
|
101
|
+
#### Tailwind CSS 4
|
|
102
|
+
|
|
103
|
+
**Why Tailwind CSS?**
|
|
104
|
+
- **Utility-First**: Rapid UI development without writing custom CSS
|
|
105
|
+
- **Consistency**: Design system enforced by utility classes
|
|
106
|
+
- **Responsive Design**: Built-in responsive modifiers
|
|
107
|
+
- **Dark Mode**: Native dark mode support
|
|
108
|
+
- **Small Bundle Size**: Purge unused styles in production
|
|
109
|
+
- **Customization**: Easy to extend with custom utilities
|
|
110
|
+
|
|
111
|
+
**Tailwind CSS 4 Features:**
|
|
112
|
+
- **New Syntax**: Improved CSS-first configuration
|
|
113
|
+
- **Better Performance**: Faster build times
|
|
114
|
+
- **Native CSS Variables**: Improved theming support
|
|
115
|
+
|
|
116
|
+
#### Shadcn/ui
|
|
117
|
+
|
|
118
|
+
**Why Shadcn/ui?**
|
|
119
|
+
- **Copy-Paste Components**: Components are copied to your codebase, full control
|
|
120
|
+
- **Radix UI Primitives**: Accessible, unstyled components
|
|
121
|
+
- **Tailwind Integration**: Styled with Tailwind CSS
|
|
122
|
+
- **Customizable**: Easy to modify to fit your design
|
|
123
|
+
- **No Runtime Dependencies**: Lightweight, no library overhead
|
|
124
|
+
|
|
125
|
+
**Components Used:**
|
|
126
|
+
- `Button` - Interactive buttons
|
|
127
|
+
- `Card` - Content containers
|
|
128
|
+
- `Badge` - Status indicators
|
|
129
|
+
- `Collapsible` - Expandable content
|
|
130
|
+
|
|
131
|
+
#### Lucide React
|
|
132
|
+
|
|
133
|
+
**Why Lucide?**
|
|
134
|
+
- **Tree-Shakeable**: Only import icons you use
|
|
135
|
+
- **Consistent Style**: Uniform icon design
|
|
136
|
+
- **Customizable**: Easy to modify size, color, stroke
|
|
137
|
+
- **React Native Support**: Same icons across platforms
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
### Authentication Layer
|
|
142
|
+
|
|
143
|
+
#### Clerk 6
|
|
144
|
+
|
|
145
|
+
**Why Clerk?**
|
|
146
|
+
- **Complete Auth Solution**: Sign-in, sign-up, password reset, email verification
|
|
147
|
+
- **Built-in Components**: Pre-built auth UI components
|
|
148
|
+
- **Organization Support**: Multi-tenant architecture out of the box
|
|
149
|
+
- **Webhooks**: Real-time user data synchronization
|
|
150
|
+
- **Session Management**: Secure session handling
|
|
151
|
+
- **Social Providers**: Easy integration with OAuth providers
|
|
152
|
+
- **MFA Support**: Multi-factor authentication
|
|
153
|
+
|
|
154
|
+
**Key Features Used:**
|
|
155
|
+
- `<SignIn />` - Sign-in page component
|
|
156
|
+
- `<SignUp />` - Sign-up page component
|
|
157
|
+
- `<UserButton />` - User menu component
|
|
158
|
+
- `getAuth()` - Server-side auth access
|
|
159
|
+
- `clerkMiddleware()` - Route protection
|
|
160
|
+
- Webhooks - User data sync
|
|
161
|
+
|
|
162
|
+
#### Svix
|
|
163
|
+
|
|
164
|
+
**Why Svix?**
|
|
165
|
+
- **Webhook Delivery**: Reliable webhook delivery
|
|
166
|
+
- **Verification**: Webhook signature verification
|
|
167
|
+
- **Retry Logic**: Automatic retries on failure
|
|
168
|
+
- **Webhook Dashboard**: Monitor webhook delivery
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
### Database Layer
|
|
173
|
+
|
|
174
|
+
#### Supabase (PostgreSQL)
|
|
175
|
+
|
|
176
|
+
**Why Supabase?**
|
|
177
|
+
- **PostgreSQL**: Powerful, open-source relational database
|
|
178
|
+
- **Managed Service**: No database administration needed
|
|
179
|
+
- **Real-time**: Real-time database subscriptions
|
|
180
|
+
- **Storage**: Built-in file storage
|
|
181
|
+
- **Edge Functions**: Serverless functions
|
|
182
|
+
- **Auth Integration**: Built-in authentication (not used, we use Clerk)
|
|
183
|
+
- **Connection Pooling**: Transaction mode for serverless
|
|
184
|
+
|
|
185
|
+
**PostgreSQL Features:**
|
|
186
|
+
- **ACID Compliance**: Reliable transactions
|
|
187
|
+
- **JSON Support**: Store and query JSON data
|
|
188
|
+
- **Full-Text Search**: Built-in search capabilities
|
|
189
|
+
- **Extensions**: Rich ecosystem of extensions
|
|
190
|
+
|
|
191
|
+
#### Drizzle ORM 0.41
|
|
192
|
+
|
|
193
|
+
**Why Drizzle?**
|
|
194
|
+
- **Type-Safe**: Full TypeScript support with inferred types
|
|
195
|
+
- **SQL-Like**: Queries resemble SQL, easy to learn
|
|
196
|
+
- **Lightweight**: Small bundle size, minimal overhead
|
|
197
|
+
- **Migration Support**: Built-in migration system
|
|
198
|
+
- **Multiple Dialects**: Support for PostgreSQL, MySQL, SQLite
|
|
199
|
+
- **Performance**: No query builder overhead, compiles to SQL
|
|
200
|
+
|
|
201
|
+
**Key Features Used:**
|
|
202
|
+
- **Schema Definition**: Define tables with TypeScript
|
|
203
|
+
- **Type Inference**: Infer types from schema
|
|
204
|
+
- **Query Building**: Type-safe query construction
|
|
205
|
+
- **Migrations**: Database schema management
|
|
206
|
+
|
|
207
|
+
#### postgres (Driver)
|
|
208
|
+
|
|
209
|
+
**Why postgres driver?**
|
|
210
|
+
- **Recommended by Drizzle**: Officially supported by Drizzle
|
|
211
|
+
- **Connection Pooling**: Built-in connection pooling
|
|
212
|
+
- **Prepared Statements**: SQL injection protection
|
|
213
|
+
- **Async/Await**: Modern async API
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
### Storage & Edge Computing
|
|
218
|
+
|
|
219
|
+
#### Supabase Storage
|
|
220
|
+
|
|
221
|
+
**Why Supabase Storage?**
|
|
222
|
+
- **S3-Compatible**: S3-compatible API
|
|
223
|
+
- **CDN Integration**: Built-in CDN for fast delivery
|
|
224
|
+
- **Signed URLs**: Temporary access URLs
|
|
225
|
+
- **Bucket Management**: Organized file storage
|
|
226
|
+
- **Transformations**: Image transformations on the fly
|
|
227
|
+
|
|
228
|
+
**Features Used:**
|
|
229
|
+
- **Upload**: File upload to buckets
|
|
230
|
+
- **Download**: File download with signed URLs
|
|
231
|
+
- **Delete**: File deletion
|
|
232
|
+
- **List**: List files in buckets
|
|
233
|
+
|
|
234
|
+
#### Supabase Edge Functions
|
|
235
|
+
|
|
236
|
+
**Why Supabase Edge Functions?**
|
|
237
|
+
- **Deno Runtime**: Secure, fast JavaScript runtime
|
|
238
|
+
- **Edge Deployment**: Deploy close to users
|
|
239
|
+
- **Auth Integration**: Built-in auth context
|
|
240
|
+
- **TypeScript Support**: Full TypeScript support
|
|
241
|
+
- **Environment Variables**: Secure environment variable access
|
|
242
|
+
|
|
243
|
+
**Features Used:**
|
|
244
|
+
- **Function Invocation**: Call edge functions from app
|
|
245
|
+
- **Auth Header Passthrough**: Forward auth headers
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
### Data Warehouse
|
|
250
|
+
|
|
251
|
+
#### Snowflake SDK
|
|
252
|
+
|
|
253
|
+
**Why Snowflake?**
|
|
254
|
+
- **Cloud-Native**: Fully managed data warehouse
|
|
255
|
+
- **Separation of Compute and Storage**: Scale independently
|
|
256
|
+
- **Performance**: Fast query execution
|
|
257
|
+
- **SQL Support**: Standard SQL with extensions
|
|
258
|
+
- **Data Sharing**: Secure data sharing
|
|
259
|
+
- **Ecosystem**: Rich partner ecosystem
|
|
260
|
+
|
|
261
|
+
**Snowflake SDK Features:**
|
|
262
|
+
- **Connection Management**: Create and manage connections
|
|
263
|
+
- **Query Execution**: Execute SQL queries
|
|
264
|
+
- **Result Streaming**: Stream large result sets
|
|
265
|
+
- **Parameter Binding**: Secure parameter binding
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
### API Layer
|
|
270
|
+
|
|
271
|
+
#### Hono 4
|
|
272
|
+
|
|
273
|
+
**Why Hono?**
|
|
274
|
+
- **Lightweight**: Small bundle size, fast execution
|
|
275
|
+
- **Type-Safe**: Full TypeScript support
|
|
276
|
+
- **Middleware Support**: Composable middleware
|
|
277
|
+
- **Fast**: Built on Web Standards, optimized for performance
|
|
278
|
+
- **Flexible**: Works with multiple runtimes (Node.js, Edge, Deno)
|
|
279
|
+
- **Easy to Learn**: Simple, intuitive API
|
|
280
|
+
|
|
281
|
+
**Key Features Used:**
|
|
282
|
+
- **Route Organization**: Modular route structure
|
|
283
|
+
- **Middleware**: Auth, logging, CORS
|
|
284
|
+
- **Type Inference**: Infer request/response types
|
|
285
|
+
- **Error Handling**: Centralized error handling
|
|
286
|
+
|
|
287
|
+
**Comparison with tRPC:**
|
|
288
|
+
- **Hono**: More flexible, framework-agnostic, better for REST APIs
|
|
289
|
+
- **tRPC**: Type-safe client-server communication, better for full-stack TypeScript
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
### State Management
|
|
294
|
+
|
|
295
|
+
#### TanStack Query 5
|
|
296
|
+
|
|
297
|
+
**Why TanStack Query?**
|
|
298
|
+
- **Server State**: Specialized for server state management
|
|
299
|
+
- **Caching**: Automatic caching and invalidation
|
|
300
|
+
- **Background Updates**: Keep data fresh
|
|
301
|
+
- **Optimistic Updates**: Better UX with instant feedback
|
|
302
|
+
- **Pagination**: Built-in pagination support
|
|
303
|
+
- **DevTools**: Excellent debugging tools
|
|
304
|
+
|
|
305
|
+
**Key Features Used:**
|
|
306
|
+
- **useQuery**: Fetch and cache data
|
|
307
|
+
- **useMutation**: Mutate server data
|
|
308
|
+
- **Query Keys**: Cache management
|
|
309
|
+
- **Stale Time**: Control cache freshness
|
|
310
|
+
|
|
311
|
+
#### Zustand 5
|
|
312
|
+
|
|
313
|
+
**Why Zustand?**
|
|
314
|
+
- **Lightweight**: Small bundle size (~1KB)
|
|
315
|
+
- **Simple**: Minimal boilerplate, easy to learn
|
|
316
|
+
- **No Context**: Avoids context-related re-renders
|
|
317
|
+
- **Type-Safe**: Full TypeScript support
|
|
318
|
+
- **DevTools**: Built-in DevTools integration
|
|
319
|
+
- **Persistence**: Optional state persistence
|
|
320
|
+
|
|
321
|
+
**Key Features Used:**
|
|
322
|
+
- **Create Store**: Define state and actions
|
|
323
|
+
- **Hooks**: React hooks for accessing state
|
|
324
|
+
- **Selectors**: Subscribe to specific state slices
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
### Validation
|
|
329
|
+
|
|
330
|
+
#### Zod 3
|
|
331
|
+
|
|
332
|
+
**Why Zod?**
|
|
333
|
+
- **Type-Safe**: Infer TypeScript types from schemas
|
|
334
|
+
- **Composable**: Combine schemas for complex validation
|
|
335
|
+
- **Error Messages**: Customizable error messages
|
|
336
|
+
- **Runtime Validation**: Validate data at runtime
|
|
337
|
+
- **Parser Integration**: Works with many parsers
|
|
338
|
+
|
|
339
|
+
**Key Features Used:**
|
|
340
|
+
- **Schema Definition**: Define validation schemas
|
|
341
|
+
- **Type Inference**: Infer types from schemas
|
|
342
|
+
- **Environment Validation**: Validate environment variables
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
### Environment Variables
|
|
347
|
+
|
|
348
|
+
#### @t3-oss/env-nextjs
|
|
349
|
+
|
|
350
|
+
**Why @t3-oss/env-nextjs?**
|
|
351
|
+
- **Type-Safe**: Infer types from environment variable schemas
|
|
352
|
+
- **Runtime Validation**: Validate environment variables at startup
|
|
353
|
+
- **Client/Server Separation**: Separate client and server variables
|
|
354
|
+
- **Error Messages**: Clear error messages for missing variables
|
|
355
|
+
- **Build-Time Validation**: Catch missing variables at build time
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## Technology Interactions and Dependencies
|
|
360
|
+
|
|
361
|
+
### Dependency Graph
|
|
362
|
+
|
|
363
|
+
```
|
|
364
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
365
|
+
│ Application Layer │
|
|
366
|
+
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
|
|
367
|
+
│ │ Next.js │ │ React 19 │ │ TypeScript │ │
|
|
368
|
+
│ └──────────────┘ └──────────────┘ └──────────────┘ │
|
|
369
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
370
|
+
│
|
|
371
|
+
┌─────────────────────┼─────────────────────┐
|
|
372
|
+
▼ ▼ ▼
|
|
373
|
+
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
|
|
374
|
+
│ Clerk Auth │ │ Hono API │ │ TanStack Q │
|
|
375
|
+
└──────────────┘ └──────────────┘ └──────────────┘
|
|
376
|
+
│ │ │
|
|
377
|
+
▼ ▼ ▼
|
|
378
|
+
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
|
|
379
|
+
│ Svix Web- │ │ Drizzle ORM │ │ Zustand │
|
|
380
|
+
│ hooks │ └──────────────┘ └──────────────┘
|
|
381
|
+
└──────────────┘ │
|
|
382
|
+
▼ ▼
|
|
383
|
+
┌──────────────┐ ┌──────────────┐
|
|
384
|
+
│ Supabase │ │ Snowflake │
|
|
385
|
+
│ (PostgreSQL)│ │ Warehouse │
|
|
386
|
+
└──────────────┘ └──────────────┘
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Key Interactions
|
|
390
|
+
|
|
391
|
+
#### Authentication Flow
|
|
392
|
+
1. User signs in via Clerk components
|
|
393
|
+
2. Clerk creates session and stores tokens
|
|
394
|
+
3. Clerk middleware validates session on protected routes
|
|
395
|
+
4. Svix handles webhook delivery for user data sync
|
|
396
|
+
5. Webhook handler updates local database via Drizzle
|
|
397
|
+
|
|
398
|
+
#### Data Fetching Flow
|
|
399
|
+
1. Component renders and calls TanStack Query hook
|
|
400
|
+
2. TanStack Query calls Hono API endpoint
|
|
401
|
+
3. Hono middleware validates Clerk auth
|
|
402
|
+
4. Hono route handler queries database via Drizzle
|
|
403
|
+
5. Drizzle executes SQL via postgres driver
|
|
404
|
+
6. Results flow back through the chain
|
|
405
|
+
|
|
406
|
+
#### State Management Flow
|
|
407
|
+
1. Server state fetched via TanStack Query
|
|
408
|
+
2. Client state managed via Zustand
|
|
409
|
+
3. UI components subscribe to state changes
|
|
410
|
+
4. State updates trigger re-renders
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
## Version Requirements
|
|
415
|
+
|
|
416
|
+
### Minimum Requirements
|
|
417
|
+
|
|
418
|
+
| Technology | Minimum Version | Recommended Version |
|
|
419
|
+
|------------|-----------------|---------------------|
|
|
420
|
+
| Node.js | 20.x | Latest LTS |
|
|
421
|
+
| pnpm | 10.x | Latest |
|
|
422
|
+
| Next.js | 15.x | Latest |
|
|
423
|
+
| React | 19.x | Latest |
|
|
424
|
+
| TypeScript | 5.x | Latest |
|
|
425
|
+
|
|
426
|
+
### Compatibility Matrix
|
|
427
|
+
|
|
428
|
+
| Next.js | React | TypeScript | Status |
|
|
429
|
+
|---------|-------|------------|--------|
|
|
430
|
+
| 15.x | 19.x | 5.8+ | ✅ Supported |
|
|
431
|
+
| 14.x | 18.x | 5.x | ⚠️ Legacy |
|
|
432
|
+
| 13.x | 18.x | 5.x | ❌ Not Supported |
|
|
433
|
+
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
## Technology Alternatives
|
|
437
|
+
|
|
438
|
+
### Authentication Alternatives
|
|
439
|
+
|
|
440
|
+
| Alternative | Pros | Cons |
|
|
441
|
+
|-------------|------|------|
|
|
442
|
+
| **NextAuth.js** | Open source, flexible | More setup required |
|
|
443
|
+
| **Auth0** | Enterprise features | Expensive for small teams |
|
|
444
|
+
| **Supabase Auth** | Built-in to Supabase | Less feature-rich than Clerk |
|
|
445
|
+
|
|
446
|
+
### Database Alternatives
|
|
447
|
+
|
|
448
|
+
| Alternative | Pros | Cons |
|
|
449
|
+
|-------------|------|------|
|
|
450
|
+
| **Prisma** | More features | Larger bundle size |
|
|
451
|
+
| **TypeORM** | Mature, widely used | Less type-safe than Drizzle |
|
|
452
|
+
| **Sequelize** | Mature, SQL/NoSQL support | Less TypeScript support |
|
|
453
|
+
|
|
454
|
+
### API Framework Alternatives
|
|
455
|
+
|
|
456
|
+
| Alternative | Pros | Cons |
|
|
457
|
+
|-------------|------|------|
|
|
458
|
+
| **Express** | Widely used | Less type-safe |
|
|
459
|
+
| **tRPC** | End-to-end type safety | Requires React on client |
|
|
460
|
+
| **Fastify** | Fast performance | Less middleware ecosystem |
|
|
461
|
+
|
|
462
|
+
### State Management Alternatives
|
|
463
|
+
|
|
464
|
+
| Alternative | Pros | Cons |
|
|
465
|
+
|-------------|------|------|
|
|
466
|
+
| **Redux Toolkit** | Rich ecosystem | More boilerplate |
|
|
467
|
+
| **SWR** | Simpler API | Fewer features than TanStack Query |
|
|
468
|
+
| **Jotai** | Atomic state | Different mental model |
|
|
469
|
+
|
|
470
|
+
---
|
|
471
|
+
|
|
472
|
+
## Technology Roadmap
|
|
473
|
+
|
|
474
|
+
### Current Stack (v0.1.0)
|
|
475
|
+
|
|
476
|
+
- ✅ Next.js 15 with App Router
|
|
477
|
+
- ✅ Clerk Authentication
|
|
478
|
+
- ✅ Supabase Database & Storage
|
|
479
|
+
- ✅ Drizzle ORM
|
|
480
|
+
- ✅ Hono API
|
|
481
|
+
- ✅ TanStack Query & Zustand
|
|
482
|
+
- ✅ Snowflake Integration
|
|
483
|
+
|
|
484
|
+
### Potential Future Additions
|
|
485
|
+
|
|
486
|
+
- 🔄 Real-time subscriptions (Supabase Realtime)
|
|
487
|
+
- 🔄 Email service (Resend/SendGrid)
|
|
488
|
+
- 🔄 File processing (FFmpeg/ImageMagick)
|
|
489
|
+
- 🔄 Caching layer (Redis)
|
|
490
|
+
- 🔄 Queue system (BullMQ)
|
|
491
|
+
- 🔄 Monitoring (Sentry/Vercel Analytics)
|
|
492
|
+
- 🔄 Testing (Vitest/Playwright)
|
|
493
|
+
|
|
494
|
+
---
|
|
495
|
+
|
|
496
|
+
## Related Documentation
|
|
497
|
+
|
|
498
|
+
- [Environment Variables](./environment-variables.md) - Configuration details
|
|
499
|
+
- [Clerk Authentication](./clerk-authentication.md) - Auth setup
|
|
500
|
+
- [Supabase Integration](./supabase-integration.md) - Database setup
|
|
501
|
+
- [Snowflake Integration](./snowflake-integration.md) - Data warehouse setup
|
|
502
|
+
- [API Layer](./api-layer.md) - Hono API details
|
|
503
|
+
- [State Management](./state-management.md) - State management patterns
|