# jigarjani-dev/sutradhaar architecture

> Architecture diagram of the GitHub repository jigarjani-dev/sutradhaar, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jigarjani-dev/sutradhaar
- Repository: https://github.com/jigarjani-dev/sutradhaar

## Overview

#### Purpose and entry points
Workshop Agent Gateway is a Docker-deployed learning platform for creating persona-driven agents, connecting them through A2A handoffs, equipping them with MCP tools, and observing activity in a live UI. The backend entry point is `app.py`; container orchestration is `docker-compose.yml` and `Dockerfile`. The primary user entry point is the dashboard at port 8192.

#### Backend gateway and API surface
The `gateway/` package is the application core. It loads agent definitions, exposes agent interactions, streams live events, and coordinates integrations:
- `gateway/agent_chat.py`
- `gateway/ws.py`
- `gateway/config.py`

The gateway is a boundary between browser/Telegram clients and the agent runtime rather than a standalone agent implementation.

#### Agent definition, discovery, and execution
Agents are filesystem-defined from a persona (`SOUL.md`) and manifest (`agent.yaml`). Templates provide reusable starting roles; the loader and registry turn those files into available runtime agents:
- `gateway/loader.py`
- `gateway/registry.py`
- `templates/orchestrator/agent.yaml`

Role templates include orchestrator, business-analysis, development, QA, and finance agents. Workshop-specific agent instances are under `workshop/software-engineering-agents/`.

#### Multi-agent routing and A2A
A2A communication is implemented as a first-class handoff layer. An orchestrator or active agent can delegate work to peers; handoffs and their resulting messages/events are separate from local model invocation:
- `gateway/a2a.py`
- `gateway/handoff.py`
- `gateway/event_log.py`

This separation supports the dashboard’s real-time visualization of inter-agent activity and provides a natural control boundary for delegation policy and tracing.

#### LLM, providers, memory, and persistence
The runtime centralizes model access and provider selection in provider/LLM modules, while preserving agent context and operational state through memory and database layers:
- `gateway/llm.py`
- `gateway/providers.py`
- `gateway/memory.py`
- `gateway/db.py`

Provider configuration is therefore isolated from agent personas and orchestration. Persistence/event storage is also distinct from the WebSocket delivery path.

#### Skills, tools, and MCP integrations
Agents gain capabilities through skill definitions and tool/MCP dispatch rather than direct coupling to external APIs:
- `gateway/skills.py`
- `gateway/tools.py`
- `gateway/mcp.py`
- `data/mcp.json`

Skills combine instructions with executable scripts, e.g. Gmail search and Google Sheets read/write operations in `data/skills/`. MCP server adapters cover browser, filesystem, Gmail, and Sheets; Google OAuth and credential handling remain inside `gateway/mcp_servers/`.

#### Channels and UI
The React/Vite frontend is the visual control and observability plane, rooted at:
- `frontend/src/main.tsx`
- `frontend/src/App.tsx`
- `frontend/src/components/SoftLabDashboard.tsx`

It includes an agent editor, pipeline canvas, skills panel, and workshop progression UI. Telegram is an alternate inbound/outbound channel backed by `gateway/telegram_channel.py` and `gateway/telegram_store.py`. External services include Telegram Bot APIs, Google Gmail/Sheets APIs via OAuth, configured LLM providers, and optional SearXNG (`searxng/settings.yml`).

Main entry points: [`gateway/agent_chat.py`](https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/agent_chat.py) (Gateway API), [`gateway/mcp.py`](https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/mcp.py) (MCP Integration), [`frontend/src/App.tsx`](https://github.com/jigarjani-dev/sutradhaar/blob/main/frontend/src/App.tsx) (Dashboard UI), [`gateway/ws.py`](https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/ws.py) (Live Event Stream)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Gateway Runtime"]
  node_gateway["Gateway API<br/>application boundary<br/>[agent_chat.py]"]
  node_websocket["Live Event Stream<br/>WebSocket delivery<br/>[ws.py]"]
end

subgraph group_agents["Agent System"]
  node_agent_loader["Agent Loader &amp; Registry<br/>agent discovery<br/>[loader.py]"]
  node_agent_template["Agent Personas<br/>template and instances<br/>[agent.yaml]"]
  node_a2a["A2A Routing<br/>delegation protocol<br/>[a2a.py]"]
  node_handoff["Handoff Control<br/>delegation policy<br/>[handoff.py]"]
  node_event_log[("Event Log<br/>activity tracing<br/>[event_log.py]")]
end

subgraph group_capabilities["Capabilities &amp; State"]
  node_llm["LLM Runtime<br/>model access<br/>[llm.py]"]
  node_providers["Provider Selection<br/>provider adapter<br/>[providers.py]"]
  node_memory[("Agent Memory<br/>context store<br/>[memory.py]")]
  node_database[("Operational Database<br/>persistence<br/>[db.py]")]
  node_skills_tools["Skills &amp; Tool Dispatch<br/>capability layer<br/>[tools.py]"]
  node_mcp["MCP Integration<br/>MCP dispatcher<br/>[mcp.py]"]
  node_mcp_config["MCP Servers<br/>integration configuration<br/>[mcp.json]"]
end

subgraph group_clients["Clients &amp; Deployment"]
  node_compose{{"Docker Compose<br/>orchestration<br/>[docker-compose.yml]"}}
  node_backend_entry["Backend Entry<br/>application entry<br/>[app.py]"]
  node_frontend["Dashboard UI<br/>React/Vite frontend<br/>[App.tsx]"]
  node_dashboard["Live Dashboard<br/>UI component"]
  node_telegram["Telegram Channel<br/>alternate client channel"]
end

node_external(("External Services<br/>LLM, Telegram, Google APIs<br/>[settings.yml]"))

node_compose -->|"deploys"| node_backend_entry
node_backend_entry -->|"starts"| node_gateway
node_frontend -->|"renders"| node_dashboard
node_frontend -->|"agent requests"| node_gateway
node_gateway -->|"publishes live activity"| node_websocket
node_websocket -->|"streams events"| node_frontend
node_gateway -->|"resolves agents"| node_agent_loader
node_agent_loader -->|"loads definitions"| node_agent_template
node_gateway -->|"delegates work"| node_a2a
node_a2a -->|"controls handoffs"| node_handoff
node_handoff -->|"records activity"| node_event_log
node_event_log -->|"feeds visualization"| node_websocket
node_gateway -->|"invokes models"| node_llm
node_llm -->|"selects provider"| node_providers
node_providers -->|"calls LLM providers"| node_external
node_gateway -->|"maintains context"| node_memory
node_memory -->|"persists state"| node_database
node_gateway -->|"executes capabilities"| node_skills_tools
node_skills_tools -->|"dispatches MCP tools"| node_mcp
node_mcp -->|"loads server config"| node_mcp_config
node_mcp -->|"uses Google and other APIs"| node_external
node_telegram -->|"messages"| node_gateway
node_telegram -->|"Bot API"| node_external

click node_compose "https://github.com/jigarjani-dev/sutradhaar/blob/main/docker-compose.yml"
click node_backend_entry "https://github.com/jigarjani-dev/sutradhaar/blob/main/app.py"
click node_frontend "https://github.com/jigarjani-dev/sutradhaar/blob/main/frontend/src/App.tsx"
click node_dashboard "https://github.com/jigarjani-dev/sutradhaar/blob/main/frontend/src/components/SoftLabDashboard.tsx"
click node_gateway "https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/agent_chat.py"
click node_websocket "https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/ws.py"
click node_agent_loader "https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/loader.py"
click node_agent_template "https://github.com/jigarjani-dev/sutradhaar/blob/main/templates/orchestrator/agent.yaml"
click node_a2a "https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/a2a.py"
click node_handoff "https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/handoff.py"
click node_event_log "https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/event_log.py"
click node_llm "https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/llm.py"
click node_providers "https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/providers.py"
click node_memory "https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/memory.py"
click node_database "https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/db.py"
click node_skills_tools "https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/tools.py"
click node_mcp "https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/mcp.py"
click node_mcp_config "https://github.com/jigarjani-dev/sutradhaar/blob/main/data/mcp.json"
click node_telegram "https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/telegram_channel.py"
click node_external "https://github.com/jigarjani-dev/sutradhaar/blob/main/searxng/settings.yml"

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_gateway,node_websocket toneBlue
class node_agent_loader,node_agent_template,node_a2a,node_handoff,node_event_log toneAmber
class node_llm,node_providers,node_memory,node_database,node_skills_tools,node_mcp,node_mcp_config toneMint
class node_compose,node_backend_entry,node_frontend,node_dashboard,node_telegram toneRose
class node_external toneNeutral
```

## Components

### Gateway Runtime

Backend control plane and agent execution boundary.

- [Gateway API](https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/agent_chat.py): application boundary · Serves client interactions and coordinates the runtime. · `gateway/agent_chat.py`
- [Live Event Stream](https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/ws.py): WebSocket delivery · `gateway/ws.py`

### Agent System

Filesystem-defined personas and multi-agent delegation.

- [Agent Loader & Registry](https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/loader.py): agent discovery · Builds available runtime agents from filesystem definitions. · `gateway/loader.py`
- [Agent Personas](https://github.com/jigarjani-dev/sutradhaar/blob/main/templates/orchestrator/agent.yaml): template and instances · SOUL.md and manifests define reusable roles and workshop agents. · `templates/orchestrator/agent.yaml`
- [A2A Routing](https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/a2a.py): delegation protocol · Separates peer handoffs from local model invocation. · `gateway/a2a.py`
- [Handoff Control](https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/handoff.py): delegation policy · `gateway/handoff.py`
- [Event Log](https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/event_log.py): activity tracing · `gateway/event_log.py`

### Capabilities & State

Tools, integrations, model access, and durable context.

- [LLM Runtime](https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/llm.py): model access · `gateway/llm.py`
- [Provider Selection](https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/providers.py): provider adapter · `gateway/providers.py`
- [Agent Memory](https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/memory.py): context store · `gateway/memory.py`
- [Operational Database](https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/db.py): persistence · `gateway/db.py`
- [Skills & Tool Dispatch](https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/tools.py): capability layer · Maps skill instructions and scripts to tool execution. · `gateway/tools.py`
- [MCP Integration](https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/mcp.py): MCP dispatcher · Connects browser, filesystem, Gmail, and Sheets adapters. · `gateway/mcp.py`
- [MCP Servers](https://github.com/jigarjani-dev/sutradhaar/blob/main/data/mcp.json): integration configuration · `data/mcp.json`

### Clients & Deployment

Interactive clients and container entry points.

- [Docker Compose](https://github.com/jigarjani-dev/sutradhaar/blob/main/docker-compose.yml): orchestration · `docker-compose.yml`
- [Backend Entry](https://github.com/jigarjani-dev/sutradhaar/blob/main/app.py): application entry · `app.py`
- [Dashboard UI](https://github.com/jigarjani-dev/sutradhaar/blob/main/frontend/src/App.tsx): React/Vite frontend · Visual control and observability plane on port 8192. · `frontend/src/App.tsx`
- [Live Dashboard](https://github.com/jigarjani-dev/sutradhaar/blob/main/frontend/src/components/SoftLabDashboard.tsx): UI component · Agent editor, pipeline canvas, skills, and workshop progression. · `frontend/src/components/SoftLabDashboard.tsx`
- [Telegram Channel](https://github.com/jigarjani-dev/sutradhaar/blob/main/gateway/telegram_channel.py): alternate client channel · `gateway/telegram_channel.py`

### Other components

- [External Services](https://github.com/jigarjani-dev/sutradhaar/blob/main/searxng/settings.yml): LLM, Telegram, Google APIs · Includes OAuth-backed Gmail/Sheets and optional SearXNG. · `searxng/settings.yml`

## Connections

- Docker Compose → Backend Entry: deploys
- Backend Entry → Gateway API: starts
- Dashboard UI → Live Dashboard: renders
- Dashboard UI → Gateway API: agent requests
- Gateway API → Live Event Stream: publishes live activity
- Live Event Stream → Dashboard UI: streams events
- Gateway API → Agent Loader & Registry: resolves agents
- Agent Loader & Registry → Agent Personas: loads definitions
- Gateway API → A2A Routing: delegates work
- A2A Routing → Handoff Control: controls handoffs
- Handoff Control → Event Log: records activity
- Event Log → Live Event Stream: feeds visualization
- Gateway API → LLM Runtime: invokes models
- LLM Runtime → Provider Selection: selects provider
- Provider Selection → External Services: calls LLM providers
- Gateway API → Agent Memory: maintains context
- Agent Memory → Operational Database: persists state
- Gateway API → Skills & Tool Dispatch: executes capabilities
- Skills & Tool Dispatch → MCP Integration: dispatches MCP tools
- MCP Integration → MCP Servers: loads server config
- MCP Integration → External Services: uses Google and other APIs
- Telegram Channel → Gateway API: messages
- Telegram Channel → External Services: Bot API
