Skip to main content

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

VariableDefaultDescription
APP_NAMEResearch LayerHuman-readable service name; appears in the /health response and log output
APP_ENVlocalRuntime environment label (local, staging, production)
API_V1_PREFIX/api/v1URL prefix mounted on all versioned routes

Database

VariableDefaultDescription
DATABASE_URLpostgresql+asyncpg://postgres:postgres@localhost:5432/research_layerPrimary 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.
VariableDefaultDescription
REDIS_URLredis://localhost:6379/0General-purpose application cache (db 0)
CELERY_BROKER_URLredis://localhost:6379/1Celery task queue broker (db 1)
CELERY_RESULT_BACKENDredis://localhost:6379/2Celery 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.
VariableDefaultDescription
S3_ENDPOINT_URLhttp://localhost:9000Base URL of the S3-compatible object store
S3_ACCESS_KEYminioadminAccess key ID
S3_SECRET_KEYminioadminSecret access key
S3_BUCKET_ARTIFACTSresearch-artifactsBucket for trained model files and MLflow run artifacts
S3_BUCKET_FEATURESfeature-storeBucket for generated feature dataset parquet files

MLflow

VariableDefaultDescription
MLFLOW_TRACKING_URIhttp://localhost:5000URL of the MLflow tracking server
MLFLOW_EXPERIMENT_NAMEresearch-layerDefault experiment name; created automatically if it does not exist
MLFLOW_ARTIFACT_ROOTs3://research-artifacts/mlflowRoot path for artifact storage; must be reachable from the tracking server

External Integrations

VariableDefaultDescription
MARKET_DATA_URLhttp://localhost:8001Base 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.
VariableDefaultDescription
KAFKA_BOOTSTRAP_SERVERSlocalhost:9092Comma-separated list of Kafka broker addresses; only used when EVENT_BACKEND=kafka
EVENT_BACKENDkafkaActive 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

VariableDefaultDescription
SECRET_KEYchange-me-in-productionSigning 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.

Build docs developers (and LLMs) love