Docker Orchestration
The system is designed to run as a multi-container application using Docker Compose. This ensures that the database, analysis backend, trading agents, and web dashboard are pre-configured to communicate seamlessly in an isolated environment.
Environment Architecture
The orchestration setup manages four primary services:
- Database: A persistent storage layer for backtest results, trade logs, and agent reasoning.
- Analysis Backend: A FastAPI service that processes trading logic, interacts with the vector store (RAG), and serves the REST/WebSocket API.
- Dashboard Frontend: A Vite-powered React application for visualizing performance and real-time trade data.
- LLM Provider: Connection to either local inference (Ollama) or cloud-based providers (Groq/OpenAI).
Prerequisites
Before deploying the stack, ensure you have the following installed:
- Docker Desktop (includes Docker Compose)
- An API Key for your chosen LLM provider (e.g., Groq, OpenAI) if not using local Ollama.
Configuration
The orchestration relies on environment variables defined in a .env file at the project root. Copy the template and fill in your credentials:
# Example .env configuration
GROQ_API_KEY=your_groq_key_here
NEWSAPI_KEY=your_newsapi_key_here
DATABASE_URL=postgresql://user:password@db:5432/trading_db
BACKEND_URL=http://backend:8000
Quick Start
To build and start the entire trading ecosystem, run:
docker-compose up --build
Once the containers are healthy, the following endpoints will be available:
- Dashboard:
http://localhost:5173 - API Documentation (Swagger):
http://localhost:8000/docs - Database: Internal port
5432
Service Definitions
1. Analysis Backend (backend)
The core Python service. It handles the TradingOrchestrator logic and manages the RAG (Retrieval-Augmented Generation) pipeline using the local knowledge/ directory.
- Internal Port:
8000 - Volumes: Mounts the
./logsand./knowledgedirectories to ensure backtest reports and vector indexes persist across restarts.
2. Dashboard Frontend (frontend)
The React-based user interface. It communicates with the backend via REST for historical data and WebSockets for live trading updates.
- Internal Port:
5173 - Dependencies: Requires the
backendservice to be healthy.
3. Database (db)
A relational database (PostgreSQL) used to store structured data from the agents/schemas.py models.
- Persistence: Uses a Docker volume (e.g.,
postgres_data) to prevent data loss when containers are stopped.
Running Specific Workloads
You can use docker-compose run to execute specific tasks without starting the web dashboard:
Run a Backtest
docker-compose run backend python run_backtest.py --days 30 --strategy ensemble
Index Knowledge Base (RAG)
If you have added new research papers or markdown files to the knowledge/ folder, re-index the vector store:
docker-compose run backend python -m agents.rag.indexer
Logs and Monitoring
To monitor the interaction between agents and the supervisor during a live analysis or backtest, follow the backend logs:
docker-compose logs -f backend
This will output the individual agent recommendations (Technical, Sentiment, Fundamental, Risk) and the final decision reached by the orchestrator.
Troubleshooting
| Issue | Solution |
| :--- | :--- |
| Connection Refused (Backend) | Ensure the DATABASE_URL in .env uses the service name db instead of localhost. |
| Frontend shows "Offline" | Check if the WebSocket connection is blocked by a firewall or if the BACKEND_URL is incorrectly configured in the frontend build. |
| LLM Timeout | If using local Ollama, ensure the Ollama service is accessible from within the Docker network (usually via host.docker.internal). |