Skip to main content
The Autonome backend is a Hono API server that runs on a VPS with persistent connections to PostgreSQL. This guide covers Docker-based deployment for production environments.

Architecture

The backend consists of:
  • Hono HTTP Server: Handles oRPC endpoints and SSE streams
  • Schedulers: Background jobs for trading, price tracking, portfolio snapshots
  • PostgreSQL: Primary data store
  • AI Integrations: Anthropic, OpenRouter, NIM, Mistral APIs

Prerequisites

  • VPS with Docker and Docker Compose installed
  • PostgreSQL 15+ (can be containerized)
  • Domain or subdomain for API (e.g., api.autonome.app)
  • SSL certificate (use Caddy or nginx for HTTPS)

Docker Deployment

Dockerfile

The project includes Dockerfile for the backend:
Dockerfile

docker-compose.yml

The full stack configuration:
docker-compose.yml

Deployment Steps

1

Prepare VPS

Install Docker and Docker Compose:
2

Clone Repository

3

Configure Environment

Create .env file:
See Environment Variables section below.
4

Build Docker Image

Or pull from registry:
5

Start Services

This will:
  1. Start PostgreSQL and wait for health check
  2. Run migrations (db:push)
  3. Seed database with initial models
  4. Start API server
6

Verify Deployment

Check API health:
Expected response:

Environment Variables

Create a .env file with the following configuration:

Core Configuration

AI Provider Keys

Lighter Trading API

Simulator Options

Optional Services

Security: Never commit .env files to Git. Use .env.example as a template and keep real credentials secure.

Manual Deployment (Without Docker)

If you prefer not to use Docker:
1

Install Dependencies

2

Build API

This creates api/dist/index.js
3

Run Migrations

4

Start Server

Or use a process manager:

HTTPS Setup with Caddy

For production, use Caddy as a reverse proxy:
Caddyfile
Install and start Caddy:

Monitoring

Health Checks

The API exposes health endpoints:

Docker Logs

Process Management

Monitor container status:

Troubleshooting

Database Connection Fails

Problem: ECONNREFUSED or timeout errors Solutions:
  1. Verify DATABASE_URL format: postgresql://user:pass@host:port/dbname
  2. Check PostgreSQL is running: docker-compose ps db
  3. Test connection: docker exec -it autonome-db psql -U autonome -d autonome
  4. Review firewall rules if using external database

Schedulers Not Starting

Problem: Health check shows schedulers as false Solutions:
  1. Check API logs: docker logs autonome-api
  2. Verify environment variables are set correctly
  3. Ensure trading mode is configured (TRADING_MODE=simulated)
  4. Check for port conflicts

CORS Errors

Problem: Frontend can’t connect to API Solutions:
  1. Add frontend domain to CORS_ORIGINS
  2. Restart API after changing environment variables
  3. Verify frontend is using correct VITE_API_URL
  4. Check browser console for specific CORS error messages

Updates and Maintenance

Update to Latest Version

Database Backups

View Application Logs

Next Steps

Database Setup

Learn about PostgreSQL configuration and migrations

Frontend Deployment

Deploy the TanStack Start frontend