# Cloud Compiler

Quickback offers a hosted compiler at `https://compiler.quickback.dev`. The CLI uses it to turn your definitions into a complete backend.

## How It Works

```
┌──────────────┐         ┌──────────────────────┐
│  quickback   │  POST   │  compiler.quickback   │
│  CLI         │────────▶│  .dev/compile         │
│              │         │                       │
│  Sends:      │         │  Returns:             │
│  - config    │         │  - Hono routes        │
│  - features  │◀────────│  - Drizzle migrations │
│  - meta      │         │  - TypeScript SDK     │
└──────────────┘         └──────────────────────┘
```

1. The CLI reads your `quickback.config.ts` and feature definitions.
2. It sends them to the cloud compiler as a JSON payload.
3. The compiler generates all backend files (routes, migrations, SDK, OpenAPI spec).
4. The CLI writes the generated files to your project.

## Quick Start

```bash
# 1. Scaffold + compile interactively
mkdir my-app && cd my-app
npx @quickback-dev/cli start
```

`start` walks through template selection, scaffolding, login (only when needed), and the first compile in one flow. Or do it scriptably:

```bash
npm install -g @quickback-dev/cli
quickback create cloudflare my-app
cd my-app
quickback compile   # prompts for login on the first run
```

## Existing Databases

When recompiling an existing project, the CLI automatically sends your Drizzle meta files so the compiler generates **incremental** migrations instead of fresh `CREATE TABLE` statements.

Meta files are loaded from `<project>/quickback/drizzle/` only — Quickback owns this state and never reads from a project-root `drizzle/` folder:
- `quickback/drizzle/auth/meta/`
- `quickback/drizzle/features/meta/`
- `quickback/drizzle/files/meta/`
- `quickback/drizzle/webhooks/meta/`
- `quickback/drizzle/audit/meta/`
- `quickback/drizzle/meta/` (single-database mode)

Migration and report artifacts are written to the `quickback/` state directory:
- `quickback/drizzle/...` for Drizzle migration SQL/meta artifacts
- `quickback/reports/...` for security contract report artifacts

No extra configuration needed — the CLI handles this automatically.

## Next Steps

- [CLI Reference](/compiler/cloud-compiler/cli) — All CLI commands
- [Authentication](/compiler/cloud-compiler/authentication) — Login flow and API keys
- [Endpoints](/compiler/cloud-compiler/endpoints) — Compiler API reference
- [Troubleshooting](/compiler/cloud-compiler/troubleshooting) — Common issues
- [Local Compiler](/compiler/cloud-compiler/local-compiler) — Run the compiler locally
