# ponnapatichandubhargav-cyber/med architecture

> Architecture diagram of the GitHub repository ponnapatichandubhargav-cyber/med, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ponnapatichandubhargav-cyber/med
- Repository: https://github.com/ponnapatichandubhargav-cyber/med

## Overview

MedFlow AI is a clinical workflow system: users submit PDF reports, Excel lab results, or clinical notes, and receive a structured risk assessment and physician-review report. The documented workflow runs through planning, medical-data extraction and lab analysis, risk detection, and report generation. The README describes the five MCP agents and A2A orchestration; sampled source confirms the UI/process-manager entry, DAG execution, shared extraction tools, and registry. Several server implementations were not excerpted, so their documented capabilities are shown without inferring internal details.

Main entry points: [`a2a/orchestrator.py`](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/a2a/orchestrator.py) (DAG Orchestrator), [`main.py`](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/main.py) (Process Manager), [`mcp_servers/llm_factory.py`](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/mcp_servers/llm_factory.py) (LLM Selector), [`app.py`](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/app.py) (Streamlit UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["User Workflow"]
  node_ui["Streamlit UI<br/>[app.py]"]
  node_manager["Process Manager<br/>[main.py]"]
end

subgraph group_agents["Clinical Agents"]
  node_planner["Task Planner<br/>[planner_server.py]"]
  node_reader["Medical Reader"]
  node_lab["Lab Analyzer"]
  node_risk["Risk Detector"]
  node_report["Report Generator"]
  node_extract["Document &amp; Lab Tools<br/>[shared_tools.py]"]
end

subgraph group_coordination["Coordination"]
  node_orchestrator["DAG Orchestrator<br/>[orchestrator.py]"]
  node_dag["Task DAG<br/>[task_dag.py]"]
  node_bus["A2A Message Bus<br/>[message_bus.py]"]
  node_registry[("Agent Registry<br/>[agent_registry.py]")]
  node_supervisor["Agent Supervisor<br/>[supervisor.py]"]
end

subgraph group_runtime["Runtime Support"]
  node_llm["LLM Selector<br/>[llm_factory.py]"]
  node_graph["LangGraph Workflow<br/>[graph.py]"]
  node_nodes["Clinical Nodes<br/>[nodes.py]"]
  node_agenttools["Agent Tools<br/>[tools.py]"]
  node_state["Clinical State<br/>[state.py]"]
  node_prompts["Clinical Prompts<br/>[prompts.py]"]
  node_audit[("Audit Log<br/>[audit_log.py]")]
  node_breaker["Circuit Breaker<br/>[circuit_breaker.py]"]
  node_dlq["Dead Letter Queue"]
  node_validator["MCP Validator<br/>[mcp_validator.py]"]
  node_security["Security Controls<br/>[security.py]"]
  node_tracing["Tracing<br/>[tracing.py]"]
  node_idempotency[("Idempotency<br/>[idempotency.py]")]
end

node_user(("Clinician"))

node_user -->|"submits files"| node_ui
node_ui -->|"starts analysis"| node_manager
node_manager -->|"requests plan"| node_planner
node_planner -->|"builds DAG"| node_dag
node_manager -->|"runs DAG"| node_orchestrator
node_orchestrator -->|"resolves capabilities"| node_registry
node_orchestrator -->|"dispatches extraction"| node_reader
node_orchestrator -->|"dispatches analysis"| node_lab
node_orchestrator -->|"dispatches detection"| node_risk
node_orchestrator -->|"dispatches reporting"| node_report
node_reader -->|"extracts PDF text"| node_extract
node_lab -->|"analyzes workbook"| node_extract
node_reader -->|"uses model"| node_llm
node_planner -->|"uses model"| node_llm
node_risk -->|"uses model"| node_llm
node_report -->|"uses model"| node_llm
node_orchestrator -->|"publishes messages"| node_bus
node_manager -->|"starts agents"| node_supervisor
node_supervisor -->|"broadcasts recovery"| node_bus
node_graph -->|"runs nodes"| node_nodes
node_nodes -->|"uses prompts"| node_prompts
node_nodes -->|"calls tools"| node_agenttools
node_graph -->|"reads and writes"| node_state
node_orchestrator -->|"uses resilience"| node_breaker
node_orchestrator -->|"uses queue"| node_dlq
node_orchestrator -->|"validates calls"| node_validator
node_orchestrator -->|"uses controls"| node_security
node_orchestrator -->|"records traces"| node_tracing
node_manager -->|"uses keys"| node_idempotency
node_ui -->|"shows report"| node_user
node_orchestrator -.->|"records audit"| node_audit

click node_ui "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/app.py"
click node_manager "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/main.py"
click node_planner "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/mcp_servers/planner_server.py"
click node_reader "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/mcp_servers/medical_reader_server.py"
click node_lab "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/mcp_servers/lab_analyzer_server.py"
click node_risk "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/mcp_servers/risk_detector_server.py"
click node_report "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/mcp_servers/report_generator_server.py"
click node_extract "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/mcp_servers/shared_tools.py"
click node_orchestrator "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/a2a/orchestrator.py"
click node_dag "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/task_dag.py"
click node_bus "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/a2a/message_bus.py"
click node_registry "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/registry/agent_registry.py"
click node_supervisor "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/supervisor.py"
click node_llm "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/mcp_servers/llm_factory.py"
click node_graph "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/graph.py"
click node_nodes "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/agents/nodes.py"
click node_agenttools "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/agents/tools.py"
click node_state "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/state.py"
click node_prompts "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/prompts.py"
click node_audit "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/audit_log.py"
click node_breaker "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/circuit_breaker.py"
click node_dlq "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/dead_letter_queue.py"
click node_validator "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/mcp_validator.py"
click node_security "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/security.py"
click node_tracing "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/tracing.py"
click node_idempotency "https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/idempotency.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_ui,node_manager toneBlue
class node_planner,node_reader,node_lab,node_risk,node_report,node_extract toneAmber
class node_orchestrator,node_dag,node_bus,node_registry,node_supervisor toneMint
class node_llm,node_graph,node_nodes,node_agenttools,node_state,node_prompts,node_audit,node_breaker,node_dlq,node_validator,node_security,node_tracing,node_idempotency toneRose
class node_user toneIndigo
```

## Components

### User Workflow

- [Streamlit UI](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/app.py): `app.py`
- [Process Manager](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/main.py): `main.py`

### Clinical Agents

- [Task Planner](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/mcp_servers/planner_server.py): `mcp_servers/planner_server.py`
- [Medical Reader](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/mcp_servers/medical_reader_server.py): `mcp_servers/medical_reader_server.py`
- [Lab Analyzer](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/mcp_servers/lab_analyzer_server.py): `mcp_servers/lab_analyzer_server.py`
- [Risk Detector](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/mcp_servers/risk_detector_server.py): `mcp_servers/risk_detector_server.py`
- [Report Generator](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/mcp_servers/report_generator_server.py): `mcp_servers/report_generator_server.py`
- [Document & Lab Tools](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/mcp_servers/shared_tools.py): `mcp_servers/shared_tools.py`

### Coordination

- [DAG Orchestrator](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/a2a/orchestrator.py): `a2a/orchestrator.py`
- [Task DAG](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/task_dag.py): `core/task_dag.py`
- [A2A Message Bus](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/a2a/message_bus.py): `a2a/message_bus.py`
- [Agent Registry](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/registry/agent_registry.py): `registry/agent_registry.py`
- [Agent Supervisor](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/supervisor.py): `core/supervisor.py`

### Runtime Support

- [LLM Selector](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/mcp_servers/llm_factory.py): `mcp_servers/llm_factory.py`
- [LangGraph Workflow](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/graph.py): `core/graph.py`
- [Clinical Nodes](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/agents/nodes.py): `agents/nodes.py`
- [Agent Tools](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/agents/tools.py): `agents/tools.py`
- [Clinical State](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/state.py): `core/state.py`
- [Clinical Prompts](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/prompts.py): `core/prompts.py`
- [Audit Log](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/audit_log.py): `core/audit_log.py`
- [Circuit Breaker](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/circuit_breaker.py): `core/circuit_breaker.py`
- [Dead Letter Queue](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/dead_letter_queue.py): `core/dead_letter_queue.py`
- [MCP Validator](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/mcp_validator.py): `core/mcp_validator.py`
- [Security Controls](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/security.py): `core/security.py`
- [Tracing](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/tracing.py): `core/tracing.py`
- [Idempotency](https://github.com/ponnapatichandubhargav-cyber/med/blob/main/core/idempotency.py): `core/idempotency.py`

### Other components

- **Clinician**

## Connections

- Clinician → Streamlit UI: submits files (evidence: `README.md`)
- Streamlit UI → Process Manager: starts analysis (evidence: `app.py`)
- Process Manager → Task Planner: requests plan (evidence: `main.py`)
- Task Planner → Task DAG: builds DAG (evidence: `mcp_servers/planner_server.py`)
- Process Manager → DAG Orchestrator: runs DAG (evidence: `main.py`)
- DAG Orchestrator → Agent Registry: resolves capabilities (evidence: `a2a/orchestrator.py`)
- DAG Orchestrator → Medical Reader: dispatches extraction (evidence: `README.md`)
- DAG Orchestrator → Lab Analyzer: dispatches analysis (evidence: `README.md`)
- DAG Orchestrator → Risk Detector: dispatches detection (evidence: `README.md`)
- DAG Orchestrator → Report Generator: dispatches reporting (evidence: `README.md`)
- Medical Reader → Document & Lab Tools: extracts PDF text (evidence: `mcp_servers/medical_reader_server.py`)
- Lab Analyzer → Document & Lab Tools: analyzes workbook (evidence: `mcp_servers/lab_analyzer_server.py`)
- Medical Reader → LLM Selector: uses model (evidence: `mcp_servers/medical_reader_server.py`)
- Task Planner → LLM Selector: uses model (evidence: `mcp_servers/planner_server.py`)
- Risk Detector → LLM Selector: uses model (evidence: `mcp_servers/risk_detector_server.py`)
- Report Generator → LLM Selector: uses model (evidence: `mcp_servers/report_generator_server.py`)
- DAG Orchestrator → A2A Message Bus: publishes messages (evidence: `a2a/orchestrator.py`)
- Process Manager → Agent Supervisor: starts agents (evidence: `main.py`)
- Agent Supervisor → A2A Message Bus: broadcasts recovery (evidence: `core/supervisor.py`)
- LangGraph Workflow → Clinical Nodes: runs nodes (evidence: `core/graph.py`)
- Clinical Nodes → Clinical Prompts: uses prompts (evidence: `agents/nodes.py`)
- Clinical Nodes → Agent Tools: calls tools (evidence: `agents/nodes.py`)
- LangGraph Workflow → Clinical State: reads and writes (evidence: `core/graph.py`)
- DAG Orchestrator → Circuit Breaker: uses resilience (evidence: `a2a/orchestrator.py`)
- DAG Orchestrator → Dead Letter Queue: uses queue (evidence: `a2a/orchestrator.py`)
- DAG Orchestrator → MCP Validator: validates calls (evidence: `a2a/orchestrator.py`)
- DAG Orchestrator → Security Controls: uses controls (evidence: `a2a/orchestrator.py`)
- DAG Orchestrator → Tracing: records traces (evidence: `a2a/orchestrator.py`)
- Process Manager → Idempotency: uses keys (evidence: `main.py`)
- Streamlit UI → Clinician: shows report (evidence: `README.md`)
- DAG Orchestrator → Audit Log: records audit (evidence: `a2a/orchestrator.py`)
