The Hedge Fund Backend ships as two separate Docker images — one for the FastAPI application server and one for the Celery background-worker pool. Both images are built fromDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/najmulhossainnj/Hedge-fund-backend/llms.txt
Use this file to discover all available pages before exploring further.
python:3.12-slim and install all Python dependencies from requirements.txt. The API server listens on port 8000 and communicates with the worker over Redis. No application code changes are required to switch between development and production; all runtime behaviour is driven entirely by environment variables.
Infrastructure Requirements
Before starting either container you need four external services running and reachable:| Service | Minimum version | Purpose |
|---|---|---|
| PostgreSQL | 15+ | Primary relational store for all domain models (strategies, features, ML models, backtests) |
| Redis | 7+ | Session cache (REDIS_URL), Celery broker (CELERY_BROKER_URL), and result backend (CELERY_RESULT_BACKEND) — three separate logical databases |
| MinIO (S3-compatible) | Any recent | Object storage for feature datasets and MLflow model artifacts |
| MLflow tracking server | 2.x | Experiment and model-artifact tracking via MLFLOW_TRACKING_URI |
All four services can be co-located on a single host for development. For production, place PostgreSQL, Redis, and MinIO behind private networking so only the application containers can reach them.
Building Docker Images
The repository contains two Dockerfiles. Build them from the project root:pip install -r requirements.txt step, so the build cache is shared when layers are identical. Expect the first build to take several minutes due to compiled dependencies (psycopg2, xgboost, lightgbm).
Running the API Server
Pass all required environment variables with
-e flags or mount a .env file. The container exposes port 8000 which you map to the host.docker run -d \
--name hedge-fund-api \
-p 8000:8000 \
-e APP_ENV=production \
-e DATABASE_URL=postgresql+asyncpg://postgres:secret@db:5432/research_layer \
-e REDIS_URL=redis://redis:6379/0 \
-e CELERY_BROKER_URL=redis://redis:6379/1 \
-e CELERY_RESULT_BACKEND=redis://redis:6379/2 \
-e S3_ENDPOINT_URL=http://minio:9000 \
-e S3_ACCESS_KEY=minioadmin \
-e S3_SECRET_KEY=minioadmin \
-e S3_BUCKET_ARTIFACTS=research-artifacts \
-e S3_BUCKET_FEATURES=feature-store \
-e MLFLOW_TRACKING_URI=http://mlflow:5000 \
-e MLFLOW_EXPERIMENT_NAME=research-layer \
-e MLFLOW_ARTIFACT_ROOT=s3://research-artifacts/mlflow \
-e MARKET_DATA_URL=http://market-data:8001 \
-e KAFKA_BOOTSTRAP_SERVERS=kafka:9092 \
-e EVENT_BACKEND=kafka \
-e SECRET_KEY=<your-secret-key> \
-e CORS_ORIGINS='["https://app.yourdomain.com"]' \
hedge-fund-backend:latest
Running the Celery Worker
The worker container uses the same image tag as a base but invokescelery instead of uvicorn. It shares identical database and broker credentials with the API container.
Dockerfile.worker default command starts the worker with --concurrency=2. Override concurrency at runtime:
Health Check
Once the API container is running, verify it is healthy with:service field reflects the APP_NAME setting and env reflects APP_ENV. If the response is anything other than 200 OK, inspect the container logs:
Database Migrations
Schema migrations are managed by Alembic. Run them inside the running API container before the service accepts traffic:
The Alembic environment (
alembic/env.py) reads DATABASE_URL from app.core.config.get_settings() automatically, so no separate alembic.ini edits are needed when environment variables are already set on the container.
Port Mapping
| Container | Internal port | Suggested host mapping |
|---|---|---|
hedge-fund-api | 8000 | 8000:8000 (dev) or reverse-proxy only (prod) |
hedge-fund-worker | — | None (outbound only) |
CORS
The default
CORS_ORIGINS value is ["http://localhost:5173"] (the Vite dev-server origin). In development you may wish to widen this to ["*"], but you must set CORS_ORIGINS to the exact origin(s) of your production frontend when deploying publicly. Wildcard origins disable cookie-based authentication and expose the API to cross-site requests.