Architecture
Understand the monorepo structure and key architectural decisions
Architecture
Datyze is built as a monorepo using pnpm workspaces and Turbo for efficient builds. This architecture enables code sharing between packages while maintaining clear separation of concerns.
Monorepo Structure
Package Overview
@lucashochart/auth
NextAuth.js v5 configuration package:
- OAuth providers (Google, GitHub)
- JWT-based sessions
- DrizzleAdapter integration
- Session helpers with React cache optimization
- Admin impersonation support
@lucashochart/database
DrizzleORM + PostgreSQL schema:
- User and authentication tables
- Multi-tenant team structure
- Subscription and payment tables
- Team invitation system
@lucashochart/email
React Email templates:
- Verification emails
- Password reset
- Team invitations
- Customizable templates
@lucashochart/stripe
Stripe payment integration:
- Checkout sessions
- Customer portal
- Webhook handling
- Subscription management
@lucashochart/lemonsqueezy
Lemon Squeezy payment integration:
- Alternative to Stripe
- Checkout and subscriptions
- Webhook handling
- Same pricing tiers
@lucashochart/ui
Shared UI components:
- Radix UI primitives
- shadcn/ui components
- Tailwind CSS styling
- Accessible by default
Multi-tenancy
Datyze implements a team-based multi-tenancy model:
Key concepts:
- Users can belong to multiple teams
- Teams are the core tenant entity
- Each team has one subscription
- TeamMember defines roles (owner, admin, member)
- Data is isolated by
teamId
Role-Based Access
Environment Variables
Type-safe environment variables using @t3-oss/env-nextjs:
@/env instead of using process.env directly.Import Conventions
Package Imports
Use workspace package names for shared packages:
Path Aliases
Use @/ for absolute imports within the web app:
Server Components
Datyze uses Server Components by default. Only add "use client" when necessary:
API Routes
API routes follow Next.js App Router conventions:
Build System
Turbo handles the build pipeline:
Next Steps
- Authentication - Configure auth providers
- Database - Understand the schema
- Deployment - Deploy to production