How sidddha2004/multi-agent works
Purpose and Entry Points
This is a Docker Compose–deployed distributed AI-agent orchestration platform. A React client submits authenticated work to a FastAPI gateway; the backend plans, schedules, executes, persists, and streams task progress/results. Primary entry points are frontend/src/index.js, api-gateway/main.py, and docker-compose.yml.
Edge/API and User Session Boundary
The API gateway is the public control plane: it handles JWT-backed authentication, task submission/query APIs, rate limiting, and WebSocket delivery. It creates jobs and trace identifiers, invokes planning, and bridges backend result events to connected clients. The frontend provides the dashboard and real-time task display.
Paths: api-gateway/main.py, frontend/src/App.js, frontend/src/App.css.
Workflow Planning
The planner turns an incoming prompt into an executable task breakdown and tracks workflow-oriented metadata. Its LangGraph workflow engine supports selecting sequential, parallel, conditional, or hybrid execution strategies, including LLM-based workflow analysis and confidence. This is the planning boundary: it decides work structure but does not execute agent work or consume results.
Paths: planner/main.py, planner/workflow_engine.py.
Scheduling and Dynamic Agent Routing
The scheduler receives planned tasks, resolves an active capable worker via the database-backed agent registry, and publishes work to the selected Kafka topic rather than relying on fixed worker routing. This decouples task generation from worker deployment and enables added agent types through registry records.
Paths: scheduler/main.py, api-gateway/main.py.
Worker Execution Layer
Specialized Kafka-consuming workers perform domain work—research, browser automation, SQL, and email—and produce results. Research has both baseline and memory-integrated implementations. Workers are isolated deployable services, keeping OpenAI/tool execution outside the gateway, planner, and scheduler.
Paths: research-agent/agent.py, research-agent/agent_with_memory.py, browser-agent/agent.py, sql-agent/agent.py, email-agent/agent.py.
Result, Retry, and Real-Time Flow
Workers persist task outcomes to PostgreSQL and publish result events. The result aggregator collects multi-agent outputs; the gateway distributes status updates over WebSockets, with Redis pub/sub providing scalable event fan-out. Failed message processing is handled by a dedicated DLQ/retry service with backoff behavior.
Paths: result-aggregator/aggregator.py, dlq-handler/handler.py, api-gateway/main.py.
Long-Term Memory and External Tool Integration
The memory manager is a separate FastAPI service for shared semantic memory operations, backed by Qdrant and OpenAI embeddings. Agents can store and retrieve contextual knowledge across executions. A separate MCP integration service is the boundary for Model Context Protocol–based external tools.
Paths: memory-manager/main.py, memory-manager/app.py, memory-manager/integration.py, mcp-integration/main.py, mcp-integration/app.py.
Runtime and Infrastructure
Python/FastAPI services and the React frontend run in individual containers, coordinated by Docker Compose. Kafka carries task/result topics; PostgreSQL stores users, jobs, tasks, workflow execution state, and agent registry data; Redis supports health/heartbeat and real-time pub/sub; Qdrant stores vectors. OpenAI GPT-4 and embedding APIs supply planning, agent intelligence, and semantic retrieval.
Paths: docker-compose.yml, .env.example, api-gateway/Dockerfile, memory-manager/Dockerfile.
Main entry points: main.py API Gateway · agent_with_memory.py Research Worker · docker-compose.yml Docker Compose · agent.py Browser Worker
Components 19
Client & Control Plane
- React Dashboard
frontend/src/App.js - API Gateway · Authenticates requests and streams task status.
api-gateway/main.py
Workflow Orchestration
- Workflow Planner · Selects execution strategy and creates task breakdowns.
planner/main.py - Workflow Engine
planner/workflow_engine.py - Dynamic Scheduler · Routes planned tasks through registry-selected worker topics.
scheduler/main.py - Result Aggregator · Collects multi-agent task outputs.
result-aggregator/aggregator.py - DLQ & Retry Handler · Applies backoff to failed message processing.
dlq-handler/handler.py
Worker Services
- Research Worker · Runs research tasks, including memory-enabled execution.
research-agent/agent_with_memory.py - Browser Worker
browser-agent/agent.py - SQL Worker
sql-agent/agent.py - Email Worker
email-agent/agent.py
State & Integrations
- Memory Manager · Provides shared semantic memory operations.
memory-manager/main.py - MCP Integration · Boundary for Model Context Protocol tools.
mcp-integration/main.py - Kafka · Carries task and result topics.
- PostgreSQL · Stores jobs, tasks, workflows, users, and agent registry.
- Redis · Supports real-time fan-out and health signals.
- Qdrant
- OpenAI APIs
Other components
- Docker Compose · Coordinates the containerized platform.
docker-compose.yml
Connections 34
- Docker Compose → React Dashboard: deploys
- Docker Compose → API Gateway: deploys
- Docker Compose → Workflow Planner: deploys
- Docker Compose → Dynamic Scheduler: deploys
- React Dashboard → API Gateway: authenticated API and WebSocket
- API Gateway → Workflow Planner: submits prompt
- Workflow Planner → Workflow Engine: builds workflow
- Workflow Engine → Dynamic Scheduler: planned tasks
- Workflow Planner → OpenAI APIs: workflow analysis
- API Gateway → PostgreSQL: creates jobs and traces
- Dynamic Scheduler → PostgreSQL: reads agent registry
- Dynamic Scheduler → Kafka: publishes selected task topic
- Kafka → Research Worker: research tasks
- Kafka → Browser Worker: browser tasks
- Kafka → SQL Worker: SQL tasks
- Kafka → Email Worker: email tasks
- Research Worker → Memory Manager: semantic context
- Research Worker → OpenAI APIs: agent inference
- Browser Worker → MCP Integration: external tools
- Research Worker → PostgreSQL: persists outcome
- Browser Worker → PostgreSQL: persists outcome
- SQL Worker → PostgreSQL: persists outcome
- Email Worker → PostgreSQL: persists outcome
- Research Worker → Kafka: result event
- Browser Worker → Kafka: result event
- SQL Worker → Kafka: result event
- Email Worker → Kafka: result event
- Kafka → Result Aggregator: consumes results
- Result Aggregator → Redis: publishes status
- Redis → API Gateway: event fan-out
- API Gateway → React Dashboard: live updates
- Kafka → DLQ & Retry Handler: failed messages
- Memory Manager → Qdrant: stores vectors
- Memory Manager → OpenAI APIs: creates embeddings