Skip to main content

Updating the control plane (Vercel)

The control plane auto-deploys when you push to the main branch (once GitHub is connected to Vercel).
git push origin main
Vercel builds and deploys automatically. Preview deployments are created for pull requests.

Manual deploy

vercel --prod

Updating the VPS agent

SSH into the VPS and pull the latest code:
ssh -i ~/Documents/dev/aws-upload/default_key/LightsailDefaultKey-eu-north-1.pem ubuntu@13.61.204.171

cd /opt/dbhost/agent

# Pull latest
git pull

# Reinstall if dependencies changed
uv sync

# Restart
sudo systemctl restart db-agent

# Verify
sudo systemctl status db-agent
curl https://agent.dbhost.app/health

Updating the database schema

When you change src/lib/db/schema.ts:
# Generate migration
npm run db:generate

# Apply (drizzle-kit doesn't read .env.local)
DATABASE_URL="postgresql://..." npm run db:migrate

# Commit the migration file
git add drizzle/
git commit -m "feat: add migration for ..."
Always review generated migration SQL before applying. Never remove columns without explicit confirmation — data loss is irreversible.

Adding new agent endpoints

1

Add the router

Create or edit a file in agent/src/db_agent/routers/. Use Pydantic schemas for request/response models.
2

Add service methods

Business logic goes in agent/src/db_agent/services/. Keep routers thin.
3

Register the router

Include it in agent/src/db_agent/main.py if it’s a new file.
4

Add TypeScript client method

Add a corresponding method to src/lib/agent-client.ts and update the interfaces if the response shape changes.
5

Write tests

Add tests in agent/tests/ using pytest + httpx.
6

Deploy

Push to VPS, restart systemd service. Deploy control plane to Vercel.