> ## Documentation Index
> Fetch the complete documentation index at: https://docs.launchtoday.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Start the Backend

> Start the API and database for Launch

This guide focuses on getting the API and database running locally. You do not
need to configure integrations to boot the backend.

## Prerequisites

If you are new to the codebase, complete the
[Prerequisites](/getting-started/prerequisites) first, then follow
[Project Setup](/getting-started/setup).

## Steps

## 1. Set Up Database

<Tabs>
  <Tab title="Docker (Recommended)">
    First, replace `YOUR_DB_NAME` (the value of `POSTGRES_DB`) in
    `apps/api/docker-compose.yml` with a real database name (required). You can
    optionally change the default user or password. Make sure the name matches
    the `DATABASE_URL` you set in `.env`.

    ```bash theme={null}
    cd apps/api
    pnpm docker:up
    ```

    Use the API shortcuts if you need them:

    ```bash theme={null}
    pnpm docker:down
    pnpm docker:restart
    pnpm docker:logs
    ```
  </Tab>

  <Tab title="Local PostgreSQL">
    ```bash theme={null}
    # macOS
    brew install postgresql
    brew services start postgresql

    # Create database
    createdb launch
    ```
  </Tab>
</Tabs>

## 2. Configure Environment

```bash theme={null}
cd apps/api
cp example.env .env
```

For quickstart, only `DATABASE_URL` is required to boot the API. Most
integrations (auth, payments, SMS, AI, uploads) can stay unset until you enable
them in their respective guides.

When you do enable auth, set `BETTER_AUTH_SECRET` to a secure value (32+ chars).
You can generate one with:

```bash theme={null}
openssl rand -base64 32
```

If you changed the database name in Docker, update `DATABASE_URL` in `.env` to
match.

## 3. Run Migrations

```bash theme={null}
cd apps/api
pnpm db:migrate
pnpm db:generate
```

If you see a "Cannot find module '../generated/client'" error, run
`pnpm db:generate` to create the Prisma client.

## 4. Start the Backend

```bash theme={null}
cd apps/api
pnpm dev
```

You should see:

```
[INFO] Database connected successfully
[INFO] Database connection info
[INFO] API Server started on http://localhost:3001
[INFO] tRPC endpoint: http://localhost:3001/trpc
[INFO] Health check: http://localhost:3001/health
[INFO] Server Environment
  Env: development
  Host: localhost
```

<Note>
  The mobile app needs the API and database running to work end-to-end. If the
  backend is not running, sign-in and data fetches will fail.
</Note>

## Next Steps

<CardGroup cols={2}>
  <Card title="Start the Mobile App" icon="device-mobile" href="/getting-started/run-mobile">
    Install dependencies and run the app
  </Card>

  <Card title="Project Structure" icon="folder" href="/project-structure">
    Understand how the codebase is organized
  </Card>
</CardGroup>
