This guide covers deploying FIML in various environments from development to production.
FIML is designed to work with minimal configuration. Here are the API key requirements:
FIML works out-of-the-box with these free providers:
- Yahoo Finance - Real-time and historical stock data (no API key)
- CoinGecko - Cryptocurrency data (no API key for basic tier)
- Mock Provider - For testing and development
For additional data sources and features, you can configure these optional API keys:
| Provider | Environment Variable | Purpose | Free Tier |
|---|---|---|---|
| Alpha Vantage | ALPHA_VANTAGE_API_KEY |
Stock fundamentals, forex | Yes (5 calls/min) |
| FMP | FMP_API_KEY |
Financial modeling data | Yes (250 calls/day) |
| Polygon | POLYGON_API_KEY |
Real-time market data | Yes (limited) |
| Finnhub | FINNHUB_API_KEY |
Stock & crypto data | Yes (60 calls/min) |
| NewsAPI | NEWSAPI_API_KEY |
Financial news | Yes (100 calls/day) |
| TwelveData | TWELVEDATA_API_KEY |
Time series data | Yes (800 calls/day) |
| Tiingo | TIINGO_API_KEY |
Stock & crypto prices | Yes (limited) |
| CoinMarketCap | COINMARKETCAP_API_KEY |
Cryptocurrency data | Yes (333 calls/day) |
For narrative generation and AI-powered insights:
| Service | Environment Variables | Purpose |
|---|---|---|
| Azure OpenAI | AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY, AZURE_OPENAI_DEPLOYMENT_NAME |
AI narrative generation |
| Service | Environment Variables | Purpose |
|---|---|---|
| Email (SMTP) | SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASSWORD |
Email alerts |
| Telegram | TELEGRAM_BOT_TOKEN |
Telegram notifications |
See Installation Guide for development setup.
git clone https://github.com/kiarashplusplus/FIML.git
cd FIML
./quickstart.shBest for: Single server deployments, staging environments
# Clone repository
git clone https://github.com/kiarashplusplus/FIML.git
cd FIML
# Create production environment file
cp .env.example .env.productionEdit .env.production with production settings:
ENVIRONMENT=production
LOG_LEVEL=WARNING
SERVER_WORKERS=8
# Use strong passwords
POSTGRES_PASSWORD=your_strong_password
REDIS_PASSWORD=your_redis_password
# Add monitoring
SENTRY_DSN=your_sentry_dsn# Build production images
docker-compose -f docker-compose.yml build
# Start services
docker-compose -f docker-compose.yml up -d
# Verify deployment
curl http://localhost:8000/healthUse Nginx or Caddy for SSL termination and load balancing.
Nginx Example:
server {
listen 80;
server_name fiml.yourdomain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name fiml.yourdomain.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# WebSocket support
location /ws {
proxy_pass http://localhost:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}Best for: Production clusters, high availability, auto-scaling
- Kubernetes cluster (v1.25+)
- kubectl configured
- Helm 3.x
kubectl create namespace fimlkubectl create secret generic fiml-secrets \
--from-literal=postgres-password=your_password \
--from-literal=redis-password=your_password \
--from-literal=alpha-vantage-key=your_key \
--from-literal=fmp-key=your_key \
-n fiml# Add FIML Helm repository (if available)
helm repo add fiml https://charts.fiml.ai
helm repo update
# Install
helm install fiml fiml/fiml \
--namespace fiml \
--values values-production.yamlOr deploy using kubectl:
kubectl apply -f k8s/kubectl get pods -n fiml
kubectl logs -f deployment/fiml-api -n fimlUse the provided CloudFormation template:
aws cloudformation create-stack \
--stack-name fiml-production \
--template-body file://cloudformation/ecs-deployment.yaml \
--parameters file://cloudformation/parameters.jsonDeploy to Amazon EKS:
# Create EKS cluster
eksctl create cluster -f eks-cluster.yaml
# Deploy application
kubectl apply -f k8s/# Create GKE cluster
gcloud container clusters create fiml-cluster \
--num-nodes=3 \
--machine-type=n1-standard-2
# Deploy
kubectl apply -f k8s/# Create AKS cluster
az aks create \
--resource-group fiml-rg \
--name fiml-cluster \
--node-count 3
# Deploy
kubectl apply -f k8s/# In .env.production
POSTGRES_HOST=your-postgres-host
POSTGRES_PORT=5432
POSTGRES_DB=fiml
POSTGRES_USER=fiml
POSTGRES_PASSWORD=strong_password
# Connection pooling
DATABASE_POOL_SIZE=20
DATABASE_MAX_OVERFLOW=10- AWS RDS: Use PostgreSQL 14+ with TimescaleDB extension
- Google Cloud SQL: PostgreSQL with high availability
- Azure Database: PostgreSQL flexible server
# In .env.production
REDIS_HOST=your-redis-host
REDIS_PORT=6379
REDIS_PASSWORD=strong_password
REDIS_MAX_CONNECTIONS=100- AWS ElastiCache: Redis cluster mode
- Google Memorystore: Redis with HA
- Azure Cache: Redis premium tier
Already configured in docker-compose.yml:
prometheus:
image: prom/prometheus
ports:
- "9091:9090"
volumes:
- ./config/prometheus.yml:/etc/prometheus/prometheus.ymlAccess dashboards at http://localhost:3000:
Default credentials: admin/admin
Import provided dashboards:
- FIML API Metrics
- Cache Performance
- Provider Health
Add to .env.production:
SENTRY_DSN=your_sentry_dsn
SENTRY_ENVIRONMENT=production
SENTRY_TRACES_SAMPLE_RATE=0.1Scale API instances:
# Docker Compose
docker-compose up -d --scale api=4
# Kubernetes
kubectl scale deployment fiml-api --replicas=4 -n fimlAdjust resource limits:
# docker-compose.yml
services:
api:
deploy:
resources:
limits:
cpus: '4.0'
memory: 8G- Redis: Use Redis Cluster for large datasets
- PostgreSQL: Enable read replicas for L2 cache
# PostgreSQL backup
docker-compose exec postgres pg_dump -U fiml fiml > backup.sql
# Restore
docker-compose exec -T postgres psql -U fiml fiml < backup.sqlConfigure in cloud provider:
- AWS RDS: Automated snapshots
- Google Cloud SQL: Automated backups
- Azure: Automated backup policy
- Use strong passwords for all services
- Enable SSL/TLS for all connections
- Configure firewall rules
- Enable API authentication
- Set up rate limiting
- Enable audit logging
- Regular security updates
- Secrets management (Vault, AWS Secrets Manager)
- Network isolation
- Enable CORS properly
FIML provides comprehensive health check endpoints for monitoring system status.
Basic application health check:
curl http://localhost:8000/healthResponse:
{
"status": "healthy",
"version": "0.2.2",
"environment": "production"
}PostgreSQL/TimescaleDB health check:
curl http://localhost:8000/health/dbResponse:
{
"status": "healthy",
"service": "postgresql",
"host": "localhost",
"port": 5432,
"database": "fiml"
}Redis (L1 cache) health check:
curl http://localhost:8000/health/cacheResponse:
{
"status": "healthy",
"service": "redis",
"host": "localhost",
"port": 6379
}Health status of all data providers:
curl http://localhost:8000/health/providersResponse:
{
"status": "healthy",
"total_providers": 5,
"healthy_providers": 5,
"providers": {
"yahoo_finance": {
"is_healthy": true,
"uptime_percent": 99.9,
"avg_latency_ms": 150.5,
"success_rate": 0.98
}
}
}Health status of a specific provider:
curl http://localhost:8000/health/providers/yahoo_financePrometheus-compatible metrics endpoint:
curl http://localhost:8000/metricsAvailable metrics include:
fiml_requests_total- Total API requests by method, endpoint, statusfiml_request_duration_seconds- Request latency histogramfiml_provider_requests_total- Provider API requests by provider/operationfiml_provider_latency_seconds- Provider latency histogramfiml_active_requests- Current active requests gaugefiml_slow_queries_total- Count of slow queries (>1s)
# Docker Compose
docker-compose logs -f api
# Kubernetes
kubectl logs -f deployment/fiml-api -n fimlCheck connection string and credentials:
docker-compose exec api python -c "from fiml.db import test_connection; test_connection()"Monitor memory usage:
docker statsAdjust limits if needed in docker-compose.yml.
- Set up Monitoring
- Configure CI/CD Pipeline
- Review Security Best Practices