Documentation 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.
All runtime configuration for the Hedge Fund Backend is centralised in app/core/config.py using pydantic-settings. At startup the Settings class is instantiated once via @lru_cache and shared across the entire process. Every field maps directly to an environment variable of the same name. You can supply values through the OS environment, a .env file in the project root, or both — environment variables take precedence over .env entries. No code changes are ever required to reconfigure the service.
Service Settings
| Variable | Default | Description |
|---|
APP_NAME | Research Layer | Human-readable service name; appears in the /health response and log output |
APP_ENV | local | Runtime environment label (local, staging, production) |
API_V1_PREFIX | /api/v1 | URL prefix mounted on all versioned routes |
Database
| Variable | Default | Description |
|---|
DATABASE_URL | postgresql+asyncpg://postgres:postgres@localhost:5432/research_layer | Primary async PostgreSQL connection string; must use the +asyncpg driver |
TIMESCALE_URL | (optional) | Secondary connection string for a TimescaleDB instance used for high-frequency time-series data; omit to disable |
Alembic migrations swap the +asyncpg driver for +psycopg2 internally when needed. Always set DATABASE_URL with +asyncpg; the migration runner handles the conversion automatically.
Cache & Broker
The platform uses three separate Redis logical databases to avoid key collisions between application cache, task messages, and task results.
| Variable | Default | Description |
|---|
REDIS_URL | redis://localhost:6379/0 | General-purpose application cache (db 0) |
CELERY_BROKER_URL | redis://localhost:6379/1 | Celery task queue broker (db 1) |
CELERY_RESULT_BACKEND | redis://localhost:6379/2 | Celery result storage, polled by GET /api/v1/tasks/{task_id} (db 2) |
Object Storage
MinIO or any S3-compatible store is used for persisting feature datasets and MLflow artifacts. The two buckets serve distinct purposes and are accessed by different subsystems.
| Variable | Default | Description |
|---|
S3_ENDPOINT_URL | http://localhost:9000 | Base URL of the S3-compatible object store |
S3_ACCESS_KEY | minioadmin | Access key ID |
S3_SECRET_KEY | minioadmin | Secret access key |
S3_BUCKET_ARTIFACTS | research-artifacts | Bucket for trained model files and MLflow run artifacts |
S3_BUCKET_FEATURES | feature-store | Bucket for generated feature dataset parquet files |
MLflow
| Variable | Default | Description |
|---|
MLFLOW_TRACKING_URI | http://localhost:5000 | URL of the MLflow tracking server |
MLFLOW_EXPERIMENT_NAME | research-layer | Default experiment name; created automatically if it does not exist |
MLFLOW_ARTIFACT_ROOT | s3://research-artifacts/mlflow | Root path for artifact storage; must be reachable from the tracking server |
External Integrations
| Variable | Default | Description |
|---|
MARKET_DATA_URL | http://localhost:8001 | Base URL of the Market Data Layer service; used by the feature engine to fetch OHLCV data |
Messaging
The event bus supports three backends selectable at runtime. Switch backends without any code changes.
| Variable | Default | Description |
|---|
KAFKA_BOOTSTRAP_SERVERS | localhost:9092 | Comma-separated list of Kafka broker addresses; only used when EVENT_BACKEND=kafka |
EVENT_BACKEND | kafka | Active messaging backend: kafka, nats, or noop. Use noop for local development and testing |
Events produced by the Research Layer include StrategyCreated, StrategyUpdated, ModelTrained, SignalGenerated, BacktestCompleted, and StrategyValidated. The noop backend logs events at DEBUG level instead of publishing them.
Security
| Variable | Default | Description |
|---|
SECRET_KEY | change-me-in-production | Signing key for session tokens and internal security material; must be replaced before production deployment |
CORS_ORIGINS | ["http://localhost:5173"] | JSON-encoded list of allowed CORS origins; e.g. ["https://app.example.com"] |
Sample .env File
Place this file in the project root for local development. Copy it, rename to .env, and adjust values for your environment:
# Service
APP_NAME=Research Layer
APP_ENV=local
API_V1_PREFIX=/api/v1
# Database
DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/research_layer
# TIMESCALE_URL=postgresql+asyncpg://postgres:postgres@localhost:5433/timeseries
# Cache & Celery broker
REDIS_URL=redis://localhost:6379/0
CELERY_BROKER_URL=redis://localhost:6379/1
CELERY_RESULT_BACKEND=redis://localhost:6379/2
# Object storage (MinIO)
S3_ENDPOINT_URL=http://localhost:9000
S3_ACCESS_KEY=minioadmin
S3_SECRET_KEY=minioadmin
S3_BUCKET_ARTIFACTS=research-artifacts
S3_BUCKET_FEATURES=feature-store
# MLflow
MLFLOW_TRACKING_URI=http://localhost:5000
MLFLOW_EXPERIMENT_NAME=research-layer
MLFLOW_ARTIFACT_ROOT=s3://research-artifacts/mlflow
# External services
MARKET_DATA_URL=http://localhost:8001
# Messaging
KAFKA_BOOTSTRAP_SERVERS=localhost:9092
EVENT_BACKEND=noop
# Security
SECRET_KEY=change-me-in-production
CORS_ORIGINS=["http://localhost:5173"]
Never commit a .env file containing real credentials, production database URLs, or secret keys to source control. Add .env to .gitignore immediately after creating it. Use a secrets manager (AWS Secrets Manager, HashiCorp Vault, Doppler, etc.) to inject secrets into production containers at runtime.