Updating the control plane (Vercel)
The control plane auto-deploys when you push to the main branch (once GitHub is connected to Vercel).
Vercel builds and deploys automatically. Preview deployments are created for pull requests.
Manual deploy
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
Add the router
Create or edit a file in agent/src/db_agent/routers/. Use Pydantic schemas for request/response models.
Add service methods
Business logic goes in agent/src/db_agent/services/. Keep routers thin.
Register the router
Include it in agent/src/db_agent/main.py if it’s a new file.
Add TypeScript client method
Add a corresponding method to src/lib/agent-client.ts and update the interfaces if the response shape changes.
Write tests
Add tests in agent/tests/ using pytest + httpx.
Deploy
Push to VPS, restart systemd service. Deploy control plane to Vercel.