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

# Deploy a FastAPI app with Postgres from Claude Code

> Paste one prompt into Claude Code and your FastAPI app goes live at https://<app>-dev.getfloo.app with managed Postgres, DATABASE_URL injected, and Alembic migrations run on every deploy.

Claude Code writes the floo config, pushes it, and connects your GitHub repository. floo builds the image, provisions Postgres, runs your migrations, and serves the app at `https://<app>-dev.getfloo.app`.

Requires a FastAPI project in a GitHub repository with a `Dockerfile` that starts uvicorn on `0.0.0.0:$PORT`. The [FastAPI guide](https://getfloo.com/docs/build/fastapi.md#1-add-a-dockerfile) has one to copy, and `floo init` offers to write one when none exists.

## Set up your agent

Install the floo skill and allow floo commands, from the project root:

```bash theme={null}
curl -fsSL https://getfloo.com/install.sh | bash
floo auth login
floo skills install --path .claude/skills/floo
```

In `.claude/settings.json`:

```json theme={null}
{
  "permissions": {
    "allow": [
      "Bash(floo *)"
    ]
  }
}
```

floo still enforces your account's role and any approval policy. See [Agent setup](https://getfloo.com/docs/guides/agent-setup.md#allow-floo-commands).

## Agent prompt

Paste into Claude Code. Replace `my-fastapi-app` with your app name.

```text theme={null}
Deploy this FastAPI app to floo with managed Postgres. App name: my-fastapi-app.
1. Confirm the floo org with `floo orgs list`. If the org has no plan, have me run `floo billing upgrade`.
2. Run `floo init my-fastapi-app`. In floo.app.toml, set port 8000 on [services.web], add [managed.default] with type = "postgres", and set migrate_command = "alembic upgrade head" if this repo uses Alembic.
3. Read DATABASE_URL from the environment in the app's database setup. Never hard-code a connection string.
4. Run `floo preflight --json` and fix every error.
5. Commit and push to the default branch.
6. Have me open https://github.com/apps/getfloo/installations/new, choose the repository's owner, and select this repository. Wait for me to confirm.
7. Run `floo apps github setup --no-browser` and give me the printed link. Wait for me to confirm GitHub access.
8. Run `floo apps github connect <owner>/<repo> --no-browser`.
9. Run `floo deploys status --app my-fastapi-app --json` until the deploy is live, then report the URL.
```

Claude Code asks you for two browser steps: installing the floo GitHub App and authorizing floo with GitHub. Everything else runs in the terminal.

## floo.app.toml

What the prompt produces:

```toml floo.app.toml theme={null}
[app]
name = "my-fastapi-app"

[services.web]
type = "web"
path = "."
port = 8000
ingress = "public"
dev_command = "uvicorn app.main:app --reload --port 8000"
migrate_command = "alembic upgrade head"

[managed.default]
type = "postgres"
```

`[managed.default]` provisions one Postgres database per environment and injects `DATABASE_URL` and `PG*` into the service. `migrate_command` runs with the new image before traffic moves to it; a failed migration stops the deploy. Drop the line if the repo has no Alembic setup.

For the async SQLAlchemy engine that reads `DATABASE_URL` with TLS kept on, see [FastAPI: add a Postgres database](https://getfloo.com/docs/build/fastapi.md#4-add-a-postgres-database).

## CLI commands

The same deploy by hand. Replace `owner/my-fastapi-app` with your repository.

```bash theme={null}
floo init my-fastapi-app
floo preflight
git add . && git commit -m "chore: deploy to floo with postgres"
git push origin main
floo apps github setup
floo apps github connect owner/my-fastapi-app
floo deploys watch --app my-fastapi-app
```

`floo apps github setup` needs the floo GitHub App installed on the repository's owner first. See [Quickstart steps 2 and 3](https://getfloo.com/docs/introduction.md#2-give-floo-access-to-your-github-repository).

## Verify

```bash theme={null}
floo deploys status --app my-fastapi-app --json
floo db schema --app my-fastapi-app
curl https://my-fastapi-app-dev.getfloo.app/health
```

`deploys status` reports the live URL once the deploy is live. `db schema` lists the tables your migrations created in the dev database. Replace `/health` with any route your app serves.

Every push to `main` deploys to dev. To publish to prod, run `gh release create v1 --repo <owner>/<repo>`; prod gets its own database. See [Environments](https://getfloo.com/docs/guides/environments.md#the-flow).

## Next steps

> **[Build a FastAPI app](https://getfloo.com/docs/build/fastapi.md)**
>
> Dockerfile, async engine, App sign-in, custom domain, and local dev.

> **[Postgres](https://getfloo.com/docs/guides/postgres.md)**
>
> Injected variables, pgvector, preview branches, and migrations across dev and prod.

> **[App sign-in](https://getfloo.com/docs/guides/app-auth.md)**
>
> Put invite-only sign-in in front of the app with one config line.

> **[Agent setup](https://getfloo.com/docs/guides/agent-setup.md)**
>
> JSON output, verification, and credential rules for agents.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.