# ramnayudu/sahayak-ai architecture

> Architecture diagram of the GitHub repository ramnayudu/sahayak-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ramnayudu/sahayak-ai
- Repository: https://github.com/ramnayudu/sahayak-ai

## Overview

Project Sahayak is an AI classroom assistant; the sampled backend centers on teacher requests handled by an API, with agent-based educational content and visual-aid generation. The repository also includes Streamlit apps, but their runtime connections are not shown in the available evidence. README capabilities such as progress tracking, resource management, and offline-first PWA behavior are not represented by implementation files in this tree. Several backend agents and prompts are indexed, but the excerpts do not establish every runtime dispatch; unsupported links are omitted.

Main entry points: [`agentic-backend/sahayakai/agent.py`](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/agent.py) (Root agent), [`agentic-backend/sahayakai/sub_agents/orchestrator_agent/agent.py`](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/orchestrator_agent/agent.py) (Task orchestrator), [`agentic-backend/sahayakai/tools.py`](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/tools.py) (Agent tools), [`agentic-backend/sahayakai/config.py`](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/config.py) (Model configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Teacher interface and API"]
  node_streamlit["Streamlit apps<br/>[streamlit_app.py]"]
  node_streamlit_fixed["Streamlit fixed app"]
  node_api["FastAPI server<br/>[server.py]"]
end

subgraph group_agents["Agent workflow"]
  node_root_agent["Root agent<br/>[agent.py]"]
  node_tools["Agent tools<br/>[tools.py]"]
  node_orchestrator["Task orchestrator<br/>[agent.py]"]
  node_merger["Lesson merger<br/>[agent.py]"]
  node_main_prompt["Assistant prompt<br/>[prompt.py]"]
  node_orchestrator_prompt["Routing prompt<br/>[prompt.py]"]
  node_merger_prompt["Merger prompt<br/>[prompt.py]"]
end

subgraph group_content["Educational content"]
  node_content_gen["Content generator<br/>[agent.py]"]
  node_story["Story specialist<br/>[agent.py]"]
  node_worksheet["Worksheet specialist<br/>[agent.py]"]
  node_visual_agent["Visual-aid agent<br/>[agent.py]"]
  node_image_tool["Image generation"]
  node_content_prompt["Content prompt<br/>[prompt.py]"]
  node_story_prompt["Story prompt<br/>[prompt.py]"]
  node_worksheet_prompt["Worksheet prompt<br/>[prompt.py]"]
end

subgraph group_models["Model configuration"]
  node_config["Model configuration<br/>[config.py]"]
  node_local_client["Local model client"]
end

node_teacher(("Teacher"))
node_transformer_lab["Transformer Lab"]
node_vertex["Vertex AI"]

node_teacher -->|"sends request"| node_api
node_api -->|"imports agent"| node_root_agent
node_root_agent -->|"registers tools"| node_tools
node_root_agent -->|"uses instructions"| node_main_prompt
node_root_agent -->|"selects model"| node_config
node_tools -->|"calls agent"| node_content_gen
node_tools -->|"calls agent"| node_visual_agent
node_orchestrator -->|"registers specialist"| node_story
node_orchestrator -->|"registers specialist"| node_worksheet
node_orchestrator -->|"uses instructions"| node_orchestrator_prompt
node_content_gen -->|"uses instructions"| node_content_prompt
node_story -->|"uses instructions"| node_story_prompt
node_worksheet -->|"uses instructions"| node_worksheet_prompt
node_merger -->|"uses instructions"| node_merger_prompt
node_visual_agent -->|"registers tool"| node_image_tool
node_image_tool -->|"checks mode"| node_config
node_local_client -->|"reads settings"| node_config
node_local_client -->|"sends requests"| node_transformer_lab
node_root_agent -.->|"uses cloud model"| node_vertex

click node_streamlit "https://github.com/ramnayudu/sahayak-ai/blob/main/streamlit_app.py"
click node_streamlit_fixed "https://github.com/ramnayudu/sahayak-ai/blob/main/streamlit_app_fixed.py"
click node_api "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/server.py"
click node_root_agent "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/agent.py"
click node_tools "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/tools.py"
click node_orchestrator "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/orchestrator_agent/agent.py"
click node_merger "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/merger_agent/agent.py"
click node_content_gen "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/content_gen_agent/agent.py"
click node_story "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/story_agent/agent.py"
click node_worksheet "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/worksheet_agent/agent.py"
click node_visual_agent "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/visual_aid_agent/agent.py"
click node_image_tool "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/visual_aid_agent/tools/image_generation_tool.py"
click node_main_prompt "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/prompt.py"
click node_content_prompt "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/content_gen_agent/prompt.py"
click node_orchestrator_prompt "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/orchestrator_agent/prompt.py"
click node_story_prompt "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/story_agent/prompt.py"
click node_worksheet_prompt "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/worksheet_agent/prompt.py"
click node_merger_prompt "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/merger_agent/prompt.py"
click node_config "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/config.py"
click node_local_client "https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/local_model_client.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_streamlit,node_streamlit_fixed,node_api toneBlue
class node_root_agent,node_tools,node_orchestrator,node_merger,node_main_prompt,node_orchestrator_prompt,node_merger_prompt toneAmber
class node_content_gen,node_story,node_worksheet,node_visual_agent,node_image_tool,node_content_prompt,node_story_prompt,node_worksheet_prompt toneMint
class node_config,node_local_client toneRose
class node_teacher,node_transformer_lab,node_vertex toneIndigo
```

## Components

### Teacher interface and API

- [Streamlit apps](https://github.com/ramnayudu/sahayak-ai/blob/main/streamlit_app.py): `streamlit_app.py`
- [Streamlit fixed app](https://github.com/ramnayudu/sahayak-ai/blob/main/streamlit_app_fixed.py): `streamlit_app_fixed.py`
- [FastAPI server](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/server.py): `agentic-backend/server.py`

### Agent workflow

- [Root agent](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/agent.py): `agentic-backend/sahayakai/agent.py`
- [Agent tools](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/tools.py): `agentic-backend/sahayakai/tools.py`
- [Task orchestrator](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/orchestrator_agent/agent.py): `agentic-backend/sahayakai/sub_agents/orchestrator_agent/agent.py`
- [Lesson merger](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/merger_agent/agent.py): `agentic-backend/sahayakai/sub_agents/merger_agent/agent.py`
- [Assistant prompt](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/prompt.py): `agentic-backend/sahayakai/prompt.py`
- [Routing prompt](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/orchestrator_agent/prompt.py): `agentic-backend/sahayakai/sub_agents/orchestrator_agent/prompt.py`
- [Merger prompt](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/merger_agent/prompt.py): `agentic-backend/sahayakai/sub_agents/merger_agent/prompt.py`

### Educational content

- [Content generator](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/content_gen_agent/agent.py): `agentic-backend/sahayakai/sub_agents/content_gen_agent/agent.py`
- [Story specialist](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/story_agent/agent.py): `agentic-backend/sahayakai/sub_agents/story_agent/agent.py`
- [Worksheet specialist](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/worksheet_agent/agent.py): `agentic-backend/sahayakai/sub_agents/worksheet_agent/agent.py`
- [Visual-aid agent](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/visual_aid_agent/agent.py): `agentic-backend/sahayakai/sub_agents/visual_aid_agent/agent.py`
- [Image generation](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/visual_aid_agent/tools/image_generation_tool.py): `agentic-backend/sahayakai/sub_agents/visual_aid_agent/tools/image_generation_tool.py`
- [Content prompt](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/content_gen_agent/prompt.py): `agentic-backend/sahayakai/sub_agents/content_gen_agent/prompt.py`
- [Story prompt](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/story_agent/prompt.py): `agentic-backend/sahayakai/sub_agents/story_agent/prompt.py`
- [Worksheet prompt](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/sub_agents/worksheet_agent/prompt.py): `agentic-backend/sahayakai/sub_agents/worksheet_agent/prompt.py`

### Model configuration

- [Model configuration](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/config.py): `agentic-backend/sahayakai/config.py`
- [Local model client](https://github.com/ramnayudu/sahayak-ai/blob/main/agentic-backend/sahayakai/local_model_client.py): `agentic-backend/sahayakai/local_model_client.py`

### Other components

- **Teacher**
- **Transformer Lab**
- **Vertex AI**

## Connections

- Teacher → FastAPI server: sends request (evidence: `agentic-backend/server.py`)
- FastAPI server → Root agent: imports agent (evidence: `agentic-backend/server.py`)
- Root agent → Agent tools: registers tools (evidence: `agentic-backend/sahayakai/agent.py`)
- Root agent → Assistant prompt: uses instructions (evidence: `agentic-backend/sahayakai/agent.py`)
- Root agent → Model configuration: selects model (evidence: `agentic-backend/sahayakai/agent.py`)
- Agent tools → Content generator: calls agent (evidence: `agentic-backend/sahayakai/tools.py`)
- Agent tools → Visual-aid agent: calls agent (evidence: `agentic-backend/sahayakai/tools.py`)
- Task orchestrator → Story specialist: registers specialist (evidence: `agentic-backend/sahayakai/sub_agents/orchestrator_agent/agent.py`)
- Task orchestrator → Worksheet specialist: registers specialist (evidence: `agentic-backend/sahayakai/sub_agents/orchestrator_agent/agent.py`)
- Task orchestrator → Routing prompt: uses instructions (evidence: `agentic-backend/sahayakai/sub_agents/orchestrator_agent/agent.py`)
- Content generator → Content prompt: uses instructions (evidence: `agentic-backend/sahayakai/sub_agents/content_gen_agent/agent.py`)
- Story specialist → Story prompt: uses instructions (evidence: `agentic-backend/sahayakai/sub_agents/story_agent/agent.py`)
- Worksheet specialist → Worksheet prompt: uses instructions (evidence: `agentic-backend/sahayakai/sub_agents/worksheet_agent/agent.py`)
- Lesson merger → Merger prompt: uses instructions (evidence: `agentic-backend/sahayakai/sub_agents/merger_agent/agent.py`)
- Visual-aid agent → Image generation: registers tool (evidence: `agentic-backend/sahayakai/sub_agents/visual_aid_agent/agent.py`)
- Image generation → Model configuration: checks mode (evidence: `agentic-backend/sahayakai/sub_agents/visual_aid_agent/tools/image_generation_tool.py`)
- Local model client → Model configuration: reads settings (evidence: `agentic-backend/sahayakai/local_model_client.py`)
- Local model client → Transformer Lab: sends requests (evidence: `agentic-backend/sahayakai/local_model_client.py`)
- Root agent → Vertex AI: uses cloud model (evidence: `README.md`)
