# sidddha2004/multi-agent architecture

> Architecture diagram of the GitHub repository sidddha2004/multi-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sidddha2004/multi-agent
- Repository: https://github.com/sidddha2004/multi-agent

## Overview

#### 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: [`api-gateway/main.py`](https://github.com/sidddha2004/multi-agent/blob/master/api-gateway/main.py) (API Gateway), [`research-agent/agent_with_memory.py`](https://github.com/sidddha2004/multi-agent/blob/master/research-agent/agent_with_memory.py) (Research Worker), [`docker-compose.yml`](https://github.com/sidddha2004/multi-agent/blob/master/docker-compose.yml) (Docker Compose), [`browser-agent/agent.py`](https://github.com/sidddha2004/multi-agent/blob/master/browser-agent/agent.py) (Browser Worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Client & Control Plane"]
  node_frontend["React Dashboard<br/>React client<br/>[App.js]"]
  node_gateway["API Gateway<br/>FastAPI control plane<br/>[main.py]"]
end

subgraph group_orchestration["Workflow Orchestration"]
  node_planner["Workflow Planner<br/>LangGraph planner<br/>[main.py]"]
  node_workflow_engine["Workflow Engine<br/>planning engine<br/>[workflow_engine.py]"]
  node_scheduler["Dynamic Scheduler<br/>Kafka scheduler<br/>[main.py]"]
  node_aggregator["Result Aggregator<br/>result consumer<br/>[aggregator.py]"]
  node_dlq["DLQ & Retry Handler<br/>retry service<br/>[handler.py]"]
end

subgraph group_workers["Worker Services"]
  node_research_worker["Research Worker<br/>Kafka worker"]
  node_browser_worker["Browser Worker<br/>Kafka worker<br/>[agent.py]"]
  node_sql_worker["SQL Worker<br/>Kafka worker<br/>[agent.py]"]
  node_email_worker["Email Worker<br/>Kafka worker<br/>[agent.py]"]
end

subgraph group_state["State & Integrations"]
  node_memory["Memory Manager<br/>FastAPI memory service<br/>[main.py]"]
  node_mcp["MCP Integration<br/>external tool service<br/>[main.py]"]
  node_kafka["Kafka<br/>event bus"]
  node_postgres[("PostgreSQL<br/>system database")]
  node_redis[("Redis<br/>pub/sub cache")]
  node_qdrant[("Qdrant<br/>vector database")]
  node_openai["OpenAI APIs<br/>LLM and embeddings"]
end

node_compose{{"Docker Compose<br/>deployment<br/>[docker-compose.yml]"}}

node_compose -->|"deploys"| node_frontend
node_compose -->|"deploys"| node_gateway
node_compose -->|"deploys"| node_planner
node_compose -->|"deploys"| node_scheduler
node_frontend -->|"authenticated API and WebSocket"| node_gateway
node_gateway -->|"submits prompt"| node_planner
node_planner -->|"builds workflow"| node_workflow_engine
node_workflow_engine -->|"planned tasks"| node_scheduler
node_planner -->|"workflow analysis"| node_openai
node_gateway -->|"creates jobs and traces"| node_postgres
node_scheduler -->|"reads agent registry"| node_postgres
node_scheduler -->|"publishes selected task topic"| node_kafka
node_kafka -->|"research tasks"| node_research_worker
node_kafka -->|"browser tasks"| node_browser_worker
node_kafka -->|"SQL tasks"| node_sql_worker
node_kafka -->|"email tasks"| node_email_worker
node_research_worker -->|"semantic context"| node_memory
node_research_worker -->|"agent inference"| node_openai
node_browser_worker -.->|"external tools"| node_mcp
node_research_worker -->|"persists outcome"| node_postgres
node_browser_worker -->|"persists outcome"| node_postgres
node_sql_worker -->|"persists outcome"| node_postgres
node_email_worker -->|"persists outcome"| node_postgres
node_research_worker -->|"result event"| node_kafka
node_browser_worker -->|"result event"| node_kafka
node_sql_worker -->|"result event"| node_kafka
node_email_worker -->|"result event"| node_kafka
node_kafka -->|"consumes results"| node_aggregator
node_aggregator -->|"publishes status"| node_redis
node_redis -->|"event fan-out"| node_gateway
node_gateway -->|"live updates"| node_frontend
node_kafka -.->|"failed messages"| node_dlq
node_memory -->|"stores vectors"| node_qdrant
node_memory -->|"creates embeddings"| node_openai

click node_compose "https://github.com/sidddha2004/multi-agent/blob/master/docker-compose.yml"
click node_frontend "https://github.com/sidddha2004/multi-agent/blob/master/frontend/src/App.js"
click node_gateway "https://github.com/sidddha2004/multi-agent/blob/master/api-gateway/main.py"
click node_planner "https://github.com/sidddha2004/multi-agent/blob/master/planner/main.py"
click node_workflow_engine "https://github.com/sidddha2004/multi-agent/blob/master/planner/workflow_engine.py"
click node_scheduler "https://github.com/sidddha2004/multi-agent/blob/master/scheduler/main.py"
click node_research_worker "https://github.com/sidddha2004/multi-agent/blob/master/research-agent/agent_with_memory.py"
click node_browser_worker "https://github.com/sidddha2004/multi-agent/blob/master/browser-agent/agent.py"
click node_sql_worker "https://github.com/sidddha2004/multi-agent/blob/master/sql-agent/agent.py"
click node_email_worker "https://github.com/sidddha2004/multi-agent/blob/master/email-agent/agent.py"
click node_aggregator "https://github.com/sidddha2004/multi-agent/blob/master/result-aggregator/aggregator.py"
click node_dlq "https://github.com/sidddha2004/multi-agent/blob/master/dlq-handler/handler.py"
click node_memory "https://github.com/sidddha2004/multi-agent/blob/master/memory-manager/main.py"
click node_mcp "https://github.com/sidddha2004/multi-agent/blob/master/mcp-integration/main.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend,node_gateway toneBlue
class node_planner,node_workflow_engine,node_scheduler,node_aggregator,node_dlq toneAmber
class node_research_worker,node_browser_worker,node_sql_worker,node_email_worker toneMint
class node_memory,node_mcp,node_kafka,node_postgres,node_redis,node_qdrant,node_openai toneRose
class node_compose toneNeutral
```

## Components

### Client & Control Plane

- [React Dashboard](https://github.com/sidddha2004/multi-agent/blob/master/frontend/src/App.js): React client · `frontend/src/App.js`
- [API Gateway](https://github.com/sidddha2004/multi-agent/blob/master/api-gateway/main.py): FastAPI control plane · Authenticates requests and streams task status. · `api-gateway/main.py`

### Workflow Orchestration

- [Workflow Planner](https://github.com/sidddha2004/multi-agent/blob/master/planner/main.py): LangGraph planner · Selects execution strategy and creates task breakdowns. · `planner/main.py`
- [Workflow Engine](https://github.com/sidddha2004/multi-agent/blob/master/planner/workflow_engine.py): planning engine · `planner/workflow_engine.py`
- [Dynamic Scheduler](https://github.com/sidddha2004/multi-agent/blob/master/scheduler/main.py): Kafka scheduler · Routes planned tasks through registry-selected worker topics. · `scheduler/main.py`
- [Result Aggregator](https://github.com/sidddha2004/multi-agent/blob/master/result-aggregator/aggregator.py): result consumer · Collects multi-agent task outputs. · `result-aggregator/aggregator.py`
- [DLQ & Retry Handler](https://github.com/sidddha2004/multi-agent/blob/master/dlq-handler/handler.py): retry service · Applies backoff to failed message processing. · `dlq-handler/handler.py`

### Worker Services

- [Research Worker](https://github.com/sidddha2004/multi-agent/blob/master/research-agent/agent_with_memory.py): Kafka worker · Runs research tasks, including memory-enabled execution. · `research-agent/agent_with_memory.py`
- [Browser Worker](https://github.com/sidddha2004/multi-agent/blob/master/browser-agent/agent.py): Kafka worker · `browser-agent/agent.py`
- [SQL Worker](https://github.com/sidddha2004/multi-agent/blob/master/sql-agent/agent.py): Kafka worker · `sql-agent/agent.py`
- [Email Worker](https://github.com/sidddha2004/multi-agent/blob/master/email-agent/agent.py): Kafka worker · `email-agent/agent.py`

### State & Integrations

- [Memory Manager](https://github.com/sidddha2004/multi-agent/blob/master/memory-manager/main.py): FastAPI memory service · Provides shared semantic memory operations. · `memory-manager/main.py`
- [MCP Integration](https://github.com/sidddha2004/multi-agent/blob/master/mcp-integration/main.py): external tool service · Boundary for Model Context Protocol tools. · `mcp-integration/main.py`
- **Kafka**: event bus · Carries task and result topics.
- **PostgreSQL**: system database · Stores jobs, tasks, workflows, users, and agent registry.
- **Redis**: pub/sub cache · Supports real-time fan-out and health signals.
- **Qdrant**: vector database
- **OpenAI APIs**: LLM and embeddings

### Other components

- [Docker Compose](https://github.com/sidddha2004/multi-agent/blob/master/docker-compose.yml): deployment · Coordinates the containerized platform. · `docker-compose.yml`

## Connections

- 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
