Skip to content

Configuration ​

Overview ​

All services use Pydantic Settings for validated configuration. Invalid or missing required values cause a startup error with a clear message.

Environment Variables ​

Create a .env file from the template:

bash
cp .env.example .env

Required Variables ​

VariableDescription
POSTGRES_USERPostgreSQL username
POSTGRES_PASSWORDPostgreSQL password
API_SECRET_KEYAPI authentication key (openssl rand -hex 32)

Database Settings ​

VariableDefaultDescription
POSTGRES_DBasn_registryPostgreSQL database name
DB_META_HOSTdb-metadataPostgreSQL host
DB_TS_HOSTdb-timeseriesClickHouse host
CLICKHOUSE_USERdefaultClickHouse username
CLICKHOUSE_PASSWORD(empty)ClickHouse password
REDIS_HOSTbroker-cacheRedis host
BROKER_URLredis://broker-cache:6379/0Celery broker URL

API Settings ​

VariableDefaultDescription
CACHE_TTL60API cache duration in seconds (0-3600)
API_RATE_LIMIT100Requests per minute per IP (1-10000)
CORS_ORIGINShttp://localhost:3000Comma-separated allowed origins (* disables credentialed requests)

Logging Settings ​

VariableDefaultDescription
LOG_FORMATjsonLog format: json or text
LOG_LEVELINFOLog level: DEBUG, INFO, WARNING, ERROR

Pool Settings ​

VariableDefaultDescription
DB_POOL_SIZE20PostgreSQL connection pool size (1-100)
DB_MAX_OVERFLOW10Max overflow connections (0-50)

Engine Settings ​

VariableDefaultDescription
ENRICHMENT_TIMEOUT3External API timeout in seconds (1-30)
CIRCUIT_BREAKER_THRESHOLD5Failures before circuit opens (1-50)
CIRCUIT_BREAKER_COOLDOWN300Cooldown period in seconds (30-3600)

Grafana ​

VariableDefaultDescription
GRAFANA_ADMIN_PASSWORD(required)Grafana admin password — no default, must be set explicitly

Docker Compose Overrides ​

For production, create a docker-compose.override.yml:

yaml
services:
  asn-api:
    deploy:
      replicas: 3

  db-metadata:
    volumes:
      - /data/postgres:/var/lib/postgresql/data

  db-timeseries:
    volumes:
      - /data/clickhouse:/var/lib/clickhouse

Database Migrations ​

Schema changes are managed with Alembic:

bash
# For existing databases (mark current schema as baseline)
cd services/api
alembic stamp 001_baseline

# For new databases
alembic upgrade head

# Create a new migration (hand-written: see note below)
alembic revision -m "description"

Migrations are written by hand. migrations/env.py sets target_metadata = None because the project has no declarative SQLAlchemy models, so --autogenerate would emit an empty migration rather than detecting your change.

Resource Allocation ​

Recommended resources for production:

ServiceCPUMemory
API0.5 core512MB
Engine1 core1GB
Ingestor0.5 core512MB
PostgreSQL0.5 core512MB
ClickHouse1 core2GB
Redis-256MB (capped)