
description: "Agentbot build process and deployment"

# Build & Deployment

<img src="https://indigo-decent-condor-546.mypinata.cloud/ipfs/bafybeibstpvk6pqo23ks3vork3yzr6ns5mdeltkv5snrkpgxn3j6pkgoau" alt="Agentbot build and deployment" height="360" style={{borderRadius: '12px', width: '100%', objectFit: 'cover', marginBottom: '24px'}} />

## Vercel Setup

### Project Settings

- **Project Name:** agentbot
- **Root Directory:** `web`
- **Framework:** Next.js (auto-detected)

### Environment Variables

Required for production:

| Variable | Description |
|----------|-------------|
| `DATABASE_URL` | Neon PostgreSQL connection string |
| `NEXTAUTH_SECRET` | Auth secret (generate with `openssl rand -base64 32`) |
| `NEXTAUTH_URL` | Production URL (https://agentbot.sh) |
| `STRIPE_SECRET_KEY` | Stripe secret key |
| `ADMIN_EMAILS` | Comma-separated admin emails |

Optional but recommended:

| Variable | Description |
|----------|-------------|
| `RESEND_API_KEY` | For welcome emails |
| `DISCORD_WEBHOOK_URL` | For notifications |
| `TELEGRAM_BOT_TOKEN` | For Telegram bot |

## Build Commands

```bash
# Development
cd web && npm run dev

# Production build
cd web && npm run build

# Production runtime
cd web && node .next/standalone/server.js

# Lint
cd web && npm run lint
```

## Deployment

### Automatic (Git Push)

Push to main branch triggers Vercel deployment automatically.

### Manual

```bash
cd web
vercel --prod --yes
```

## Build Stability

### Pre-build Validation

The build includes:
1. Prisma client generation
2. Next.js webpack production build
3. Standalone server output for runtime deploys

### Common Issues

| Issue | Solution |
|-------|----------|
| Module resolution errors | Check tsconfig.json path mappings |
| Prisma errors | Run `npx prisma generate` |
| Environment errors | Verify all required env vars set |

## Rollback

Vercel automatically keeps deployment history. To rollback:
1. Go to Vercel Dashboard
2. Find previous working deployment
3. Click "..." → "Promote to Production"
