This guide will help you set up and run the entire project using Docker Compose.
- Docker Desktop or Docker Engine installed
- Docker Compose v3.8 or higher
- At least 4GB of available RAM
- API keys for Gemini and Pinecone (if using those services)
git clone <repository-url>
cd Multi-Tenant-Document-IntelligenceCreate a .env file in the project root. You can copy from env.example:
cp env.example .envEdit the .env file and fill in your API keys:
# Required API Keys
GEMINI_API_KEY=your_actual_gemini_api_key
PINECONE_API_KEY=your_actual_pinecone_api_key
PINECONE_INDEX_NAME=quickstart
# Optional: Customize other settings
SECRET_KEY=your_secure_random_string
DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/document_intelligenceBuild and start all containers:
docker-compose up -d --buildThis will start:
- PostgreSQL database (port 5432)
- Redis for rate limiting (port 6379)
- Kafka + Zookeeper for message queue (ports 9092, 9093)
- FastAPI application (port 8000)
- Kafka worker for processing documents (port 8001)
- Prometheus for metrics (port 9090)
- Grafana for visualization (port 3000)
docker-compose psView logs for all services:
docker-compose logs -fView logs for a specific service:
docker-compose logs -f app # FastAPI app
docker-compose logs -f worker # Kafka worker
docker-compose logs -f kafka # Kafka
docker-compose logs -f db # PostgreSQL| Service | Container | Port | Description |
|---|---|---|---|
| FastAPI App | app |
8000 | Main API server |
| Worker | worker |
8001 | Kafka consumer worker |
| Database | db |
5432 | PostgreSQL |
| Redis | redis |
6379 | Rate limiting cache |
| Kafka | kafka |
9092 | Message broker |
| Service | Container | Port | Description |
|---|---|---|---|
| Prometheus | prometheus |
9090 | Metrics collection |
| Grafana | grafana |
3000 | Metrics visualization |
Once running, you can access:
- API: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Grafana: http://localhost:3000 (admin/admin)
- Prometheus: http://localhost:9090
DATABASE_URL: PostgreSQL connection string (default for Docker:postgresql+asyncpg://postgres:postgres@db:5432/document_intelligence)
REDIS_URL: Redis connection stringREDIS_HOST: Redis hostname (default:redis)REDIS_PORT: Redis port (default:6379)
KAFKA_BROKER: Kafka broker address (default:kafka:29092)KAFKA_TOPIC: Kafka topic name (default:document_events)
GEMINI_API_KEY: Google Gemini API key for embeddingsPINECONE_API_KEY: Pinecone API key for vector storePINECONE_INDEX_NAME: Pinecone index name (default:quickstart)
SECRET_KEY: Secret key for JWT tokens (change in production!)
CHUNKING_STRATEGY: Chunking strategy (default:fixed_size)UPLOADS_PER_MINUTE: Rate limit for uploadsSEARCHES_PER_MINUTE: Rate limit for searches
docker-compose downdocker-compose down -vdocker-compose restart app
docker-compose restart workerdocker-compose up -d --builddocker-compose logs -f app worker# Run database migrations
docker-compose exec app alembic upgrade head
# Access database
docker-compose exec db psql -U postgres -d document_intelligence
# Access Redis
docker-compose exec redis redis-cliPrometheus is configured to scrape metrics from:
- FastAPI app:
app:8000/metrics - Worker:
worker:8001/metrics
Access Prometheus UI: http://localhost:9090
Grafana is pre-configured with:
- Prometheus data source
- Pre-built dashboards in
grafana/dashboards/
Access Grafana: http://localhost:3000
- Username:
admin - Password:
admin
Run migrations after starting the services:
docker-compose exec app alembic upgrade headOr manually:
docker-compose exec app bash
alembic upgrade head
exitFor development, you can override the docker-compose configuration:
Create docker-compose.override.yml:
version: '3.8'
services:
app:
volumes:
- .:/app
- /app/venv # Exclude venv
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reloadThe app supports hot reload when you mount the source code. Update docker-compose.yml to add:
app:
volumes:
- .:/appThen restart:
docker-compose restart appCheck logs:
docker-compose logsCheck if ports are already in use:
lsof -i :8000 # Check if port is takenVerify database is healthy:
docker-compose ps db
docker-compose logs dbVerify Kafka is ready:
docker-compose logs kafka
docker-compose exec kafka kafka-topics --list --bootstrap-server localhost:9092Clear Docker cache and rebuild:
docker-compose build --no-cache
docker-compose up -dIf you encounter memory issues:
- Increase Docker Desktop memory allocation (4GB+)
- Or reduce the number of worker instances