# Deploying outside Lovable (AWS / Google Cloud)

The app is a standard **Vite + TanStack Start** project with **Nitro** as the SSR build engine, so it can be exported and self-hosted on any Node-capable platform.

## 1. Export the code
Use the **Export to GitHub** button in Lovable. You get a normal repo with `package.json`, `vite.config.ts`, `src/`, and migrations.

## 2. Required environment variables
Set these in your hosting provider:

| Variable | Where used | Notes |
|---|---|---|
| `VITE_SUPABASE_URL` | client | your Postgres/Supabase URL |
| `VITE_SUPABASE_PUBLISHABLE_KEY` | client | publishable/anon key |
| `SUPABASE_URL` | server | same URL, server-side |
| `SUPABASE_PUBLISHABLE_KEY` | server | publishable/anon key |
| `SUPABASE_SERVICE_ROLE_KEY` | server | only if you use admin paths |
| `LOVABLE_API_KEY` | server | for the AI generation endpoint. Replace with your own Gemini / OpenAI key + swap the fetch URL in `src/lib/photoshoot.functions.ts` if you want to leave the Lovable gateway. |

You can point `VITE_SUPABASE_URL` at a self-hosted Supabase or any Postgres + GoTrue compatible stack. Run the SQL in `supabase/migrations/` against that database.

## 3. Build targets

`vite.config.ts` uses `@lovable.dev/vite-tanstack-config` which wraps Nitro. By default it targets Cloudflare; for AWS/GCP swap the preset:

```ts
// vite.config.ts
export default defineConfig({
  tanstackStart: { server: { entry: "server" } },
  vite: {
    plugins: [],
  },
  nitro: { preset: "node-server" }, // or "aws-lambda", "google-cloud-functions"
});
```

### Option A — Docker container (recommended)
```dockerfile
FROM oven/bun:1 AS build
WORKDIR /app
COPY . .
RUN bun install --frozen-lockfile && bun run build

FROM node:20-alpine
WORKDIR /app
COPY --from=build /app/.output ./.output
ENV PORT=3000
EXPOSE 3000
CMD ["node", ".output/server/index.mjs"]
```
Deploy to **AWS ECS / App Runner / Fargate** or **Google Cloud Run**.

### Option B — AWS Lambda
Set `nitro.preset: "aws-lambda"`, then upload `.output/server/` behind API Gateway. Serve `.output/public/` from S3 + CloudFront.

### Option C — Google Cloud Run / Cloud Functions
Use the Docker option above for Cloud Run, or `preset: "google-cloud-functions"` for Functions Gen2.

## 4. Database
All schema lives in `supabase/migrations/`. Apply with `supabase db push` against your own project, or run the SQL files directly via `psql` against any Postgres.

## 5. Auth
Email/password and Google sign-in work out of the box on any Supabase-compatible Auth instance. For Google OAuth on your domain, add your domain to the OAuth provider's redirect URLs.
