# codeultr0n/swiggy-builders-club---ai-agent- architecture

> Architecture diagram of the GitHub repository codeultr0n/swiggy-builders-club---ai-agent-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codeultr0n/swiggy-builders-club---ai-agent-
- Repository: https://github.com/codeultr0n/swiggy-builders-club---ai-agent-

## Overview

#### Purpose and entry points
MCP Orchestrator is a Python 3.11+ coordination layer for Swiggy Food, Instamart, and Dineout MCP services. It turns natural-language requests plus user context into a prioritized, routed server action. Primary CLI entry point: `orchestrator/__main__.py`; HTTP/OAuth-facing entry point: `server.py`. Startup wiring is centralized in `orchestrator/init_orchestrator.py`.

#### Orchestrator composition
The core application object is assembled from client connectivity, memory, LLM reasoning, prioritization, routing, and registered plugins. `orchestrator/__init__.py` exposes the package surface, while `orchestrator/init_orchestrator.py` establishes the runtime dependency graph. Configuration separates service endpoints, app behavior, and scoring weights in `config/servers.yaml`, `config/settings.yaml`, and `config/weights.yaml`.

#### MCP client boundary
`orchestrator/client.py` is the protocol/service boundary for connections to external MCP servers. It should isolate MCP transport, credentials, tool discovery/invocation, and server failures from orchestration policy. The external service domain is Swiggy’s Food, Instamart, and Dineout MCP platform rather than direct commerce APIs.

#### Context, memory, and LLM reasoning
`orchestrator/memory.py` owns persistent cross-session user state such as preferences, history, and learned behavior; the stated storage runtime is SQLite or JSON. `orchestrator/llm.py` handles natural-language interpretation and reasoning through a pluggable OpenAI, Anthropic, or local-model provider. This creates a key boundary: durable state remains in memory rather than being repeatedly embedded in LLM prompts.

#### Prioritization and routing pipeline
Requests flow from LLM interpretation and stored/current context into `orchestrator/prioritizer.py`, which scores candidate tasks using signals including time, location, behavior, active goals, and urgency. `orchestrator/router.py` maps the selected task or intent to the appropriate plugin/MCP server. The resulting action is invoked through the MCP client, with outcomes available to update memory for later turns.

#### Plugin and domain adapters
The plugin layer makes server-specific capabilities extensible without changing central routing or prioritization. Domain registrations live in `orchestrator/plugins/food.py`, `orchestrator/plugins/instamart.py`, and `orchestrator/plugins/dineout.py`. Execution/translation handlers provide domain boundaries for the underlying service actions: `orchestrator/plugins/handlers/food_handler.py`, `orchestrator/plugins/handlers/instamart_handler.py`, and `orchestrator/plugins/handlers/dineout_handler.py`.

#### Authentication and server runtime
`orchestrator/oauth.py` contains OAuth callback/authentication integration, with `server.py` providing the surrounding server/API runtime. Credentials and MCP server definitions belong in `config/servers.yaml`, keeping authentication and remote endpoint details outside core task-selection logic.

Main entry points: [`orchestrator/init_orchestrator.py`](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/init_orchestrator.py) (Runtime assembly), [`orchestrator/client.py`](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/client.py) (MCP client), [`orchestrator/router.py`](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/router.py) (Action router), [`orchestrator/prioritizer.py`](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/prioritizer.py) (Task prioritizer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry &amp; Runtime"]
  node_cli["CLI entry point<br/>Python CLI<br/>[__main__.py]"]
  node_server["HTTP/OAuth server<br/>Python server<br/>[server.py]"]
  node_oauth["OAuth integration<br/>authentication<br/>[oauth.py]"]
end

subgraph group_core["Orchestration Core"]
  node_bootstrap["Runtime assembly<br/>composition root"]
  node_package["Package surface<br/>package API<br/>[__init__.py]"]
  node_llm["LLM reasoning<br/>model provider adapter<br/>[llm.py]"]
  node_memory[("User memory<br/>persistent state<br/>[memory.py]")]
  node_prioritizer["Task prioritizer<br/>scoring engine<br/>[prioritizer.py]"]
  node_router["Action router<br/>routing policy<br/>[router.py]"]
  node_mcp_client{{"MCP client<br/>MCP boundary<br/>[client.py]"}}
end

subgraph group_plugins["Domain Plugins"]
  node_food_plugin["Food plugin<br/>domain registration<br/>[food.py]"]
  node_instamart_plugin["Instamart plugin<br/>domain registration<br/>[instamart.py]"]
  node_dineout_plugin["Dineout plugin<br/>domain registration<br/>[dineout.py]"]
  node_food_handler["Food handler<br/>domain action adapter<br/>[food_handler.py]"]
  node_instamart_handler["Instamart handler<br/>domain action adapter"]
  node_dineout_handler["Dineout handler<br/>domain action adapter<br/>[dineout_handler.py]"]
end

subgraph group_external["External Services"]
  node_server_config["Server credentials &amp; endpoints<br/>configuration<br/>[servers.yaml]"]
  node_app_config["Behavior &amp; scoring config<br/>configuration<br/>[settings.yaml]"]
  node_weights_config["Prioritization weights<br/>configuration<br/>[weights.yaml]"]
  node_mcp_platform{{"Swiggy MCP platform<br/>external MCP services"}}
end

node_cli -->|"starts"| node_bootstrap
node_server -->|"hosts"| node_oauth
node_server -->|"initializes"| node_bootstrap
node_package -.->|"exposes"| node_bootstrap
node_bootstrap -->|"wires"| node_llm
node_bootstrap -->|"wires"| node_memory
node_bootstrap -->|"wires"| node_prioritizer
node_bootstrap -->|"wires"| node_router
node_bootstrap -->|"wires"| node_mcp_client
node_llm -->|"interpreted intent"| node_prioritizer
node_memory -->|"user context"| node_prioritizer
node_prioritizer -->|"selected task"| node_router
node_router -->|"routes food"| node_food_plugin
node_router -->|"routes groceries"| node_instamart_plugin
node_router -->|"routes dining"| node_dineout_plugin
node_food_plugin -->|"uses"| node_food_handler
node_instamart_plugin -->|"uses"| node_instamart_handler
node_dineout_plugin -->|"uses"| node_dineout_handler
node_food_handler -->|"invokes via"| node_mcp_client
node_instamart_handler -->|"invokes via"| node_mcp_client
node_dineout_handler -->|"invokes via"| node_mcp_client
node_mcp_client -->|"MCP transport"| node_mcp_platform
node_mcp_client -.->|"outcomes update"| node_memory
node_server_config -.->|"configures"| node_mcp_client
node_app_config -.->|"configures"| node_bootstrap
node_weights_config -.->|"configures"| node_prioritizer
node_server_config -.->|"credentials"| node_oauth

click node_cli "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/__main__.py"
click node_server "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/server.py"
click node_oauth "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/oauth.py"
click node_bootstrap "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/init_orchestrator.py"
click node_package "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/__init__.py"
click node_llm "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/llm.py"
click node_memory "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/memory.py"
click node_prioritizer "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/prioritizer.py"
click node_router "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/router.py"
click node_mcp_client "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/client.py"
click node_food_plugin "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/plugins/food.py"
click node_instamart_plugin "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/plugins/instamart.py"
click node_dineout_plugin "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/plugins/dineout.py"
click node_food_handler "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/plugins/handlers/food_handler.py"
click node_instamart_handler "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/plugins/handlers/instamart_handler.py"
click node_dineout_handler "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/plugins/handlers/dineout_handler.py"
click node_server_config "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/config/servers.yaml"
click node_app_config "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/config/settings.yaml"
click node_weights_config "https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/config/weights.yaml"

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_cli,node_server,node_oauth toneBlue
class node_bootstrap,node_package,node_llm,node_memory,node_prioritizer,node_router,node_mcp_client toneAmber
class node_food_plugin,node_instamart_plugin,node_dineout_plugin,node_food_handler,node_instamart_handler,node_dineout_handler toneMint
class node_server_config,node_app_config,node_weights_config,node_mcp_platform toneRose
```

## Components

### Entry & Runtime

- [CLI entry point](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/__main__.py): Python CLI · `orchestrator/__main__.py`
- [HTTP/OAuth server](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/server.py): Python server · `server.py`
- [OAuth integration](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/oauth.py): authentication · `orchestrator/oauth.py`

### Orchestration Core

- [Runtime assembly](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/init_orchestrator.py): composition root · Builds the orchestrator dependency graph. · `orchestrator/init_orchestrator.py`
- [Package surface](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/__init__.py): package API · `orchestrator/__init__.py`
- [LLM reasoning](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/llm.py): model provider adapter · Interprets requests through OpenAI, Anthropic, or local models. · `orchestrator/llm.py`
- [User memory](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/memory.py): persistent state · Cross-session preferences, history, and learned behavior. · `orchestrator/memory.py`
- [Task prioritizer](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/prioritizer.py): scoring engine · Ranks tasks using context, behavior, goals, and urgency. · `orchestrator/prioritizer.py`
- [Action router](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/router.py): routing policy · `orchestrator/router.py`
- [MCP client](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/client.py): MCP boundary · Isolates transport, discovery, invocation, credentials, and failures. · `orchestrator/client.py`

### Domain Plugins

- [Food plugin](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/plugins/food.py): domain registration · `orchestrator/plugins/food.py`
- [Instamart plugin](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/plugins/instamart.py): domain registration · `orchestrator/plugins/instamart.py`
- [Dineout plugin](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/plugins/dineout.py): domain registration · `orchestrator/plugins/dineout.py`
- [Food handler](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/plugins/handlers/food_handler.py): domain action adapter · `orchestrator/plugins/handlers/food_handler.py`
- [Instamart handler](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/plugins/handlers/instamart_handler.py): domain action adapter · `orchestrator/plugins/handlers/instamart_handler.py`
- [Dineout handler](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/orchestrator/plugins/handlers/dineout_handler.py): domain action adapter · `orchestrator/plugins/handlers/dineout_handler.py`

### External Services

- [Server credentials & endpoints](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/config/servers.yaml): configuration · `config/servers.yaml`
- [Behavior & scoring config](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/config/settings.yaml): configuration · `config/settings.yaml`
- [Prioritization weights](https://github.com/codeultr0n/swiggy-builders-club---ai-agent-/blob/main/config/weights.yaml): configuration · `config/weights.yaml`
- **Swiggy MCP platform**: external MCP services · Food, Instamart, and Dineout server capabilities.

## Connections

- CLI entry point → Runtime assembly: starts
- HTTP/OAuth server → OAuth integration: hosts
- HTTP/OAuth server → Runtime assembly: initializes
- Package surface → Runtime assembly: exposes
- Runtime assembly → LLM reasoning: wires
- Runtime assembly → User memory: wires
- Runtime assembly → Task prioritizer: wires
- Runtime assembly → Action router: wires
- Runtime assembly → MCP client: wires
- LLM reasoning → Task prioritizer: interpreted intent
- User memory → Task prioritizer: user context
- Task prioritizer → Action router: selected task
- Action router → Food plugin: routes food
- Action router → Instamart plugin: routes groceries
- Action router → Dineout plugin: routes dining
- Food plugin → Food handler: uses
- Instamart plugin → Instamart handler: uses
- Dineout plugin → Dineout handler: uses
- Food handler → MCP client: invokes via
- Instamart handler → MCP client: invokes via
- Dineout handler → MCP client: invokes via
- MCP client → Swiggy MCP platform: MCP transport
- MCP client → User memory: outcomes update
- Server credentials & endpoints → MCP client: configures
- Behavior & scoring config → Runtime assembly: configures
- Prioritization weights → Task prioritizer: configures
- Server credentials & endpoints → OAuth integration: credentials
