api

Self-Hosting

Deploy the sus backend on your own infrastructure

Overview

Most users should use the hosted API at api.sus-pm.com. Self-hosting is for:

  • Enterprise deployments with strict data residency requirements
  • Air-gapped environments without external network access
  • Custom integrations that need direct database access

Self-hosting requires managing PostgreSQL, Redis, and multiple services. Consider the hosted API first.

Architecture

The sus backend consists of 4 services:

100%
ServiceDescription
API ServerHTTP API for package lookups and scan requests
WorkerProcesses scan jobs from the Redis queue
WatcherMonitors npm registry for new packages and updates
CVE EnricherFetches CVE data from OSV, NVD, and GitHub Advisory

Quick Start with Docker Compose

The fastest way to self-host is with Docker Compose:

Bash
git clone https://github.com/superagent-ai/sus
cd sus
cp .env.example .env

Edit .env with your API keys (at minimum, ANTHROPIC_API_KEY):

Bash
ANTHROPIC_API_KEY=sk-ant-xxxxx

Start all services:

Bash
docker-compose up -d

This starts PostgreSQL, Redis, and all 4 services. The API will be available at http://localhost:3000.

Environment Variables

VariableRequiredServiceDescription
DATABASE_URLYesAPI, Worker, CVEPostgreSQL connection string
REDIS_URLYesAPI, Worker, WatcherRedis connection string
PORTNoAPIServer port (default: 3000)
ANTHROPIC_API_KEYYesWorkerFor agentic threat detection
NVD_API_KEYNoCVENVD API key (reduces rate limits)
GITHUB_TOKENNoCVEGitHub token for Advisory API

Optional Configuration

VariableDefaultDescription
RUST_LOGinfoLogging level (debug, info, warn, error)
POLL_INTERVAL_SECS60npm registry polling interval
CHANGES_LIMIT100Max changes per poll
CVE_POLL_INTERVAL_MINS15CVE enrichment cycle interval

Configure CLI

Point the sus CLI to your self-hosted API:

Bash
export SUS_API_URL=https://your-api.example.com

Or per-command:

Bash
sus add express --api-url https://your-api.example.com

Add export SUS_API_URL=... to your shell profile for persistence.

Building from Source

Build individual Docker images:

Bash
docker build -f Dockerfile.api -t sus-api .
docker build -f Dockerfile.worker -t sus-worker .
docker build -f Dockerfile.watcher -t sus-watcher .
docker build -f Dockerfile.cve -t sus-cve .

Or run directly with Cargo:

Bash
# Start PostgreSQL and Redis first
docker-compose up -d db redis
 
# Run services
cargo run --package sus-api
cargo run --package sus-worker
cargo run --package sus-watcher
cargo run --package sus-cve

Scaling

The Docker Compose setup includes:

  • 2 worker replicas by default (configurable)
  • Single watcher (one instance monitors the registry)
  • Single CVE enricher (one instance fetches CVE data)
  • API server can be scaled behind a load balancer

For production, consider:

  • Running PostgreSQL and Redis as managed services
  • Using container orchestration (Kubernetes, ECS)
  • Adding a reverse proxy with TLS termination

Next Steps