# Deploying Billsline

Billsline is a TanStack Start app. It builds with Nitro, so it runs on Vercel,
Netlify, Cloudflare, Render, Fly, or any Node host — the only difference is one
build-time preset variable.

## 1. Create the new Supabase project

Create a project, then collect:

- Project URL: `https://<ref>.supabase.co`
- `anon` / publishable key
- `service_role` key (secret)
- A Supabase **personal access token** (Account → Access Tokens) — the wizard
  needs it to run the database scripts.

## 2. Deploy the code

### Vercel

1. Import the repository.
2. Vercel picks up `vercel.json` (build command `NITRO_PRESET=vercel npm run build`,
   output `.vercel/output`).
3. Add the environment variables from `.env.example`.
4. Deploy.

### Netlify

Build command: `NITRO_PRESET=netlify npm run build` · Publish directory: `dist`

### Cloudflare Workers/Pages

Build command: `npm run build` (Cloudflare is the default preset).

### Any Node server (VPS, Render, Fly, Docker)

```bash
NITRO_PRESET=node-server npm run build
node .output/server/index.mjs
```

## 3. Environment variables

Copy `.env.example`. `PUBLIC_SITE_URL` / `VITE_SITE_URL` must be the public
address of the deployment (no trailing slash) — sitemap, webhook URLs shown in
the admin panel and push notification links all read from it.

## 4. Run the installation wizard

Open `https://your-domain.com/install`. A fresh deployment also redirects there
automatically from the home page. The wizard:

1. tests the Supabase credentials (service role + management token),
2. applies every database migration, the signup trigger, storage bucket and
   realtime publication, then verifies all tables and money routines,
3. saves and live-tests provider credentials (Husmodata, Flutterwave, Paystack, Aspfy),
4. creates the first Super Admin owner account,
5. runs an end-to-end health check,
6. writes the installation record and prints the final env block.

Once finished the wizard locks itself; further changes happen in
**Admin → System**.

## 5. Webhooks

Point each provider at your own domain:

- Paystack: `https://your-domain.com/api/public/paystack-webhook`
- Flutterwave: `https://your-domain.com/api/public/flutterwave-webhook`
- Aspfy: `https://your-domain.com/api/public/aspfiy-funding/<token>`

The exact URLs for your deployment are shown in **Admin → API Keys**.
