Monorepo Structure
Web Application Structure
The web application (apps/web
) follows a feature-based architecture:
Key Directories
app/
- Contains all Next.js pages and layouts
- Follows the App Router convention
- Includes route handlers and API endpoints
components/
- Shared UI components
- Organized by type (ui, layout, forms, etc.)
- Includes shadcn/ui components
features/
- Feature-specific components and logic
- Each feature is self-contained
- Includes business logic and UI components
services/
- API client configurations
- External service integrations
- tRPC client setup
Server Structure
The server application (apps/server
) follows a clean architecture pattern:
Key Components
controllers/
- Business logic implementation
- Handles incoming requests
- Input validation
- Response formatting
routers/
- tRPC router definitions
- API endpoint organization
- Middleware configuration
services/
- Database operations
- External service integrations
CMS Architecture
The CMS (apps/cms
) is powered by Payload CMS and is structured for extensibility and integration with the rest of the monorepo. Only the essential structure is shown below:
collections/
: Contains all collection schemas for Payload (e.g., Posts, Media, Users, Privacy).payload.config.ts
: The entry point for configuring Payload CMS, plugins, adapters, and collections.
For detailed configuration and customization, refer to the Payload CMS documentation.
Database Architecture
The project uses Prisma with Supabase (PostgreSQL):Authentication Flow
The authentication system uses BetterAuth:- User initiates auth (email, OAuth)
- BetterAuth handles the flow
- Session is created and stored
- User metadata is synced to database
API Architecture
The API layer uses tRPC for type-safe communication:- Frontend makes type-safe API calls
- tRPC router processes the request
- Controller handles the business logic
- Response is returned to the client
State Management
- React Context for global state
- Server state handled by tRPC
Styling Architecture
- Tailwind CSS for utility-first styling
- shadcn/ui for component library
- CSS Modules for component-specific styles
- Dark mode support built-in