# Project structure (/docs/starter/project-structure)

A generated project contains only the packages for the modules you chose.

<Files>
  <Folder name="apps" defaultOpen>
    <Folder name="web" defaultOpen>
      <Folder name="src">
        <Folder name="server" />
        <Folder name="config" />
        <Folder name="components" />
        <Folder name="jobs" />
      </Folder>
      <File name=".env.local" />
    </Folder>
    <Folder name="api">
      <Folder name="src">
        <Folder name="routes" />
        <Folder name="server" />
        <Folder name="config" />
        <Folder name="jobs" />
      </Folder>
      <File name=".env.local" />
      <File name="Dockerfile" />
    </Folder>
    <Folder name="mobile">
      <Folder name="assets" />
      <Folder name="src" />
      <File name="app.config.ts" />
      <File name=".env.local" />
    </Folder>
    <Folder name="shell">
      <Folder name="scripts" />
      <File name="capacitor.config.ts" />
      <File name=".env.local" />
    </Folder>
  </Folder>
  <Folder name="packages" defaultOpen>
    <Folder name="core" />
    <Folder name="db" />
    <Folder name="ui" />
    <Folder name="cache" />
    <Folder name="auth" />
    <Folder name="auth-supabase" />
    <Folder name="contract" />
    <Folder name="mobile" />
    <File name="… one package per module you chose" />
  </Folder>
  <Folder name="e2e" />
  <Folder name=".github" />
  <File name=".env.example" />
  <File name="Dockerfile" />
  <File name="docker-compose.yml" />
  <File name="SETUP.md" />
  <File name="package.json" />
</Files>

- **`apps/web`**: the web app. Routes and UI, with the composition root in `src/server/`, site config in `src/config/`, and app-only components in `src/components/`. Background jobs live in `src/jobs/` with any `--jobs` provider.
- **`packages/`**: framework-agnostic packages, one per interface and one per provider (below).
- **`apps/api`** and **`packages/contract`**: only in projects with a [frontend and its API](../cli/frontend-and-api.mdx). `apps/api` is the API (Hono or FastAPI, package `@clubedge/api`), with its own `.env.local` and `Dockerfile`; `apps/web` is then the React + Vite frontend, which has no `src/server/` or `src/jobs/`. The Hono API has the module routes in `src/routes/`, the composition root in `src/server/`, site config and plans in `src/config/`, and background jobs in `src/jobs/` with any `--jobs` provider. The FastAPI API has its code in the package `src/clubedge_api/` ([below](#the-fastapi-api)), site config in `src/config/`, and its tests in `tests/`.
- **`apps/mobile`**: only in projects with the [native app](./native-app.mdx) (`--mobile expo`, Starter v0.28.0 or newer), package `@clubedge/mobile-app`. It is an Expo and React Native app, with its screens under `src/app`, its site config in `src/config/site.json`, and its own `.env.local` (`EXPO_PUBLIC_API_URL`). Expo generates its `android/` and `ios/` projects when it builds, so they aren't committed.
- **No `apps/web`** in a project [without a website](../cli/without-a-website.mdx) (`--framework none`, Starter v0.28.0 or newer): it is the API and its contract, with neither `packages/ui`, the root `Dockerfile` and `.env.example`, nor the browser tests in `e2e/`.
- **`apps/shell`** and **`packages/mobile`**: only in projects with a [mobile app](./mobile-app.mdx) (`--shell capacitor`, Starter v0.27.0 or newer). `apps/shell` packages the React + Vite frontend for Android and iOS with Capacitor, with its own `.env.local` (`WEB_URL`), and holds the native projects, `android/` and `ios/`, once created. `packages/mobile` has the app's own code, which the frontend loads only in its build for the app.
- **`e2e/`**: Playwright browser checks.
- **`.github/`**: the CI workflow, the deploy workflow of every platform but Docker (from Starter v0.27.0), `clubedge-upgrade.yml` (a weekly pull request when a newer Starter release is out), `preview.yml` with `--infra neon` ([Preview environments](./deploy/preview-environments.mdx)), issue forms, and a pull request template. With Docker, `pnpm clubedge deploy` adds `release-images.yml`.
- **`Dockerfile`** and **`docker-compose.yml`**: the production image and a Compose file that builds it (with a separate API, both images). With Docker, `pnpm clubedge deploy` adds `compose.yaml` and a `Caddyfile`, for a server of your own. See [Docker](./docker.mdx).
- **Files for your modules**, only when you choose them: `docker-compose.dev.yml` (`--infra docker`), `supabase/` (`--infra supabase`), `firebase.json` (`--auth firebase`), and `fly.toml`, `render.yaml`, or `.railway/railway.ts` (`--deploy`).
- **`SETUP.md`**: setup guide for this project's modules.

## Packages [#packages]

| Package                          | Contents                                                                                      | Module                    |
| -------------------------------- | --------------------------------------------------------------------------------------------- | ------------------------- |
| `packages/core`                  | Errors, `Result` type, HTTP helpers, and the error reporting and tracing hooks (no dependencies) | always                 |
| `packages/db`                    | Drizzle schema, client factory, migrations, and seed script                                   | always                    |
| `packages/ui`                    | Shared shadcn/ui components, utilities, and global theme styles                               | `framework` not `none`    |
| `packages/cache`                 | `Cache` and `RateLimiter` interfaces with in-memory implementations                           | always                    |
| `packages/contract`              | `openapi.yaml` (the API contract), the TypeScript client generated from it, and the conformance suite | `api` not `none`  |
| `packages/mobile`                | The mobile app's native helpers (device storage and the app's version), its update notice, and its demo | `shell` not `none` |
| `packages/local-db`              | PGlite served over the PostgreSQL protocol, for development without Docker                    | `infra=local`             |
| `packages/cache-redis`           | Redis rate limiter and cache                                                                  | `cache=redis`             |
| `packages/auth`                  | `AuthProvider` and `CookieStore` interfaces                                                   | `auth` not `none`         |
| `packages/auth-supabase`         | Supabase Auth adapter                                                                         | `auth=supabase`           |
| `packages/auth-better-auth`      | Better Auth adapter, with its own tables and migrations                                       | `auth=better-auth`        |
| `packages/auth-firebase`         | Firebase Authentication adapter, with session cookies                                         | `auth=firebase`           |
| `packages/auth-appwrite`         | Appwrite adapter, with session cookies                                                        | `auth=appwrite`           |
| `packages/storage`               | `StorageProvider` interface                                                                   | `storage` not `none`      |
| `packages/storage-s3`            | S3-compatible storage adapter                                                                 | `storage=s3`              |
| `packages/storage-supabase`      | Supabase Storage adapter                                                                      | `storage=supabase`        |
| `packages/email`                 | `EmailProvider` interface with console and in-memory providers                                | `email` not `none`        |
| `packages/email-smtp`            | SMTP email provider                                                                           | `email=smtp`              |
| `packages/email-resend`          | Resend email provider                                                                         | `email=resend`            |
| `packages/payments`              | `PaymentProvider` interface, billing logic, and the subscription tables                       | `payments` not `none`     |
| `packages/payments-stripe`       | Stripe payment provider                                                                       | `payments=stripe`         |
| `packages/jobs`                  | `JobQueue` interface, job definitions, an in-memory queue, and the conformance suite          | `jobs` not `none`         |
| `packages/jobs-pg-boss`          | pg-boss job queue                                                                             | `jobs=pg-boss`            |
| `packages/jobs-bullmq`           | BullMQ job queue in Redis                                                                     | `jobs=bullmq`             |
| `packages/jobs-inngest`          | Inngest jobs, and the handler for `/api/inngest`                                              | `jobs=inngest`            |
| `packages/observability`         | `ObservabilityProvider` interface and an in-memory provider for tests                         | `observability` not `none` |
| `packages/observability-otel`    | OpenTelemetry provider (OTLP/HTTP traces and error logs)                                      | `observability=otel`      |
| `packages/observability-sentry`  | Sentry provider                                                                               | `observability=sentry`    |

## The composition root [#the-composition-root]

`apps/web/src/server/` is the only place that reads environment variables and chooses providers. Routes and components import from it, such as `email` from `@/server/email`, rather than a provider SDK. To replace a provider, implement the package's interface in a new package and return it from the matching file in `apps/web/src/server/`.

In a project with a frontend and a separate API, or without a website, the API owns the composition root, in `apps/api/src/server/` for Hono (such as `email.ts`, `storage.ts`, `payments.ts`, and `jobs.ts`) and `apps/api/src/clubedge_api/server.py` for FastAPI. The frontend calls the API only through the client in `packages/contract`. In production, the frontend runs `server.mjs`, which serves the build and forwards the API routes of the modules you chose; with Better Auth, it also answers `/api/auth` from `auth.server.mjs`.

### The FastAPI API [#the-fastapi-api]

The FastAPI API doesn't use the TypeScript packages, so its package, `apps/api/src/clubedge_api/`, has each module's code in Python, with the same interfaces and tables. `server.py` is the composition root, `app.py` has the contract's routes, and each module you chose adds a few files:

| Module | Files in `apps/api/src/clubedge_api/` |
| --- | --- |
| `auth` | `auth.py` (the provider's check), `users.py`, and the settings in `account.py` and `routes/account.py` |
| `storage` | `storage.py` (`get_storage`), `storage_provider.py` (the protocol), and `storage_s3.py` with `storage_local.py`, or `storage_supabase.py` |
| `cache` | `cache.py` (Redis, or process memory with `--cache memory`), `rate_limit.py`, and `memory_cache.py` |
| `email` | `email.py` (`email`), `email_provider.py` (the protocol), and `email_smtp.py` or `email_resend.py` |
| `payments` | `payments.py` (the protocol, billing, and tables), `payments_stripe.py`, `plans.py`, and `routes/billing.py` |
| `jobs` | `jobs.py` (your jobs), `background_jobs.py` (`get_jobs`), `job_queue.py` (the protocol), `jobs_bullmq.py` or `jobs_inngest.py`, and `routes/jobs.py` |
| `observability` | `observability.py` (starts the tool), `telemetry.py` (the protocol), `tracing.py`, `telemetry_otel.py` or `telemetry_sentry.py`, and `routes/client_errors.py` |

Its tests are in `apps/api/tests/`, such as `test_storage_s3.py` and `test_billing.py`.

## Site config [#site-config]

The project name, description, service identifier, and documentation links live in `apps/web/src/config/site.json`. Edit that file to rename the app; create-clubedge-app writes it for generated projects. A separate API has its own copy, `apps/api/src/config/site.json`, which the CLI writes too: the API's `/api/health` reports its service identifier. Without a website, the API's copy is the project's.

The native app has a copy as well, `apps/mobile/src/config/site.json`, from which `app.config.ts` takes its name and address scheme. With Better Auth, the server trusts the scheme it makes from its own copy, so keep the `serviceId` the same in both.
