Documentation
Project Structure
Understanding the monorepo structure and organization.
Page type
Product documentation
Best for
Setup, workflow, and implementation details
Next action
Copy, export, or continue deeper into the doc tree
Note: This is mock/placeholder content for demonstration purposes.
Learn how the codebase is organized and where to find things.
Monorepo Overview
This project uses Turborepo to manage a monorepo with multiple apps and packages.
project-root/ āāā apps/ # Applications ā āāā web/ # Main Next.js app ā āāā e2e/ # Playwright E2E tests ā āāā dev-tool/ # Development utilities āāā packages/ # Shared packages ā āāā features/ # Feature packages ā āāā ui/ # UI components ā āāā supabase/ # Supabase utilities ā āāā billing/ # Billing integrations āāā tooling/ # Development tools āāā supabase/ # Database schema & migrations āāā docs/ # Documentation
Main Application (apps/web)
The primary Next.js application:
apps/web/ āāā app/ # Next.js App Router ā āāā (marketing)/ # Public pages ā āāā (auth)/ # Authentication ā āāā home/ # Main application ā ā āāā (user)/ # Personal account ā ā āāā [account]/ # Team accounts ā āāā admin/ # Admin panel ā āāā api/ # API routes āāā components/ # Shared components āāā config/ # Configuration files āāā lib/ # Utility functions āāā public/ # Static assets āāā supabase/ # Supabase setup
Route Structure
Marketing Routes ((marketing))
Public-facing pages:
app/(marketing)/ āāā page.tsx # Landing page āāā pricing/ # Pricing page āāā blog/ # Blog āāā docs/ # Documentation
Auth Routes ((auth))
Authentication pages:
app/(auth)/ āāā sign-in/ āāā sign-up/ āāā password-reset/ āāā verify/
Application Routes (home)
Main application:
app/home/
āāā (user)/ # Personal account context
ā āāā page.tsx # Personal dashboard
ā āāā settings/ # User settings
ā āāā projects/ # Personal projects
āāā [account]/ # Team account context
āāā page.tsx # Team dashboard
āāā settings/ # Team settings
āāā projects/ # Team projects
āāā members/ # Team members
Packages Structure
Feature Packages (packages/features/)
Modular features:
packages/features/ āāā accounts/ # Account management āāā auth/ # Authentication āāā team-accounts/ # Team features āāā billing/ # Billing & subscriptions āāā admin/ # Admin features āāā notifications/ # Notification system
UI Package (packages/ui/)
Shared UI components:
packages/ui/
āāā src/
āāā components/ # Shadcn UI components
ā āāā button.tsx
ā āāā input.tsx
ā āāā dialog.tsx
ā āāā ...
āāā utils/ # UI utilities
Supabase Package (packages/supabase/)
Database utilities:
packages/supabase/ āāā schema/ # Declarative schemas ā āāā accounts.schema.ts ā āāā auth.schema.ts ā āāā ... āāā src/ ā āāā clients/ # Supabase clients ā āāā hooks/ # React hooks ā āāā middleware/ # Auth middleware āāā migrations/ # SQL migrations
Configuration Files
Root Level
project-root/ āāā package.json # Root package.json āāā turbo.json # Turborepo config āāā pnpm-workspace.yaml # PNPM workspace āāā tsconfig.json # Base TypeScript config
Application Level
apps/web/ āāā next.config.js # Next.js configuration āāā tailwind.config.ts # Tailwind CSS āāā tsconfig.json # TypeScript config āāā .env.local # Environment variables
Feature Configuration
apps/web/config/ āāā paths.config.ts # Route paths āāā billing.config.ts # Billing settings āāā feature-flags.config.ts # Feature flags āāā personal-account-navigation.config.tsx āāā team-account-navigation.config.tsx
Naming Conventions
Files
- Pages:
page.tsx(Next.js convention) - Layouts:
layout.tsx - Components:
kebab-case.tsx - Utilities:
kebab-case.ts - Types:
types.tsorcomponent-name.types.ts
Directories
- Route segments:
[param]for dynamic - Route groups:
(group)for organization - Private folders:
_components,_lib - Parallel routes:
@folder
Code Organization
feature/
āāā page.tsx # Route page
āāā layout.tsx # Route layout
āāā loading.tsx # Loading state
āāā error.tsx # Error boundary
āāā _components/ # Private components
ā āāā feature-list.tsx
ā āāā feature-form.tsx
āāā _lib/ # Private utilities
āāā server/ # Server-side code
ā āāā loaders.ts
ā āāā actions.ts
āāā schemas/ # Validation schemas
āāā feature.schema.ts
Import Paths
Use TypeScript path aliases:
// Absolute imports from packages
import { Button } from '@kit/ui/button';
import { createClient } from '@kit/supabase/server-client';
// Relative imports within app
import { FeatureList } from './_components/feature-list';
import { loadData } from './_lib/server/loaders';
Best Practices
- Keep route-specific code private - Use
_componentsand_lib - Share reusable code - Extract to packages
- Collocate related files - Keep files near where they're used
- Use consistent naming - Follow established patterns
- Organize by feature - Not by file type
Finding Your Way
| Looking for... | Location |
|---|---|
| UI Components | packages/ui/src/components/ |
| Database Schema | packages/supabase/schema/ |
| API Routes | apps/web/app/api/ |
| Auth Logic | packages/features/auth/ |
| Billing Code | packages/features/billing/ |
| Team Features | packages/features/team-accounts/ |
| Config Files | apps/web/config/ |
| Types | *.types.ts files throughout |
