Project Structure

Understanding the monorepo structure and organization.

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.ts or component-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

  1. Keep route-specific code private - Use _components and _lib
  2. Share reusable code - Extract to packages
  3. Collocate related files - Keep files near where they're used
  4. Use consistent naming - Follow established patterns
  5. Organize by feature - Not by file type

Finding Your Way

Looking for...Location
UI Componentspackages/ui/src/components/
Database Schemapackages/supabase/schema/
API Routesapps/web/app/api/
Auth Logicpackages/features/auth/
Billing Codepackages/features/billing/
Team Featurespackages/features/team-accounts/
Config Filesapps/web/config/
Types*.types.ts files throughout