# yazeedmshayekh2/lms architecture

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

- Interactive diagram: https://gitdiagram.com/yazeedmshayekh2/lms
- Repository: https://github.com/yazeedmshayekh2/lms

## Overview

1. **Overall shape**
   - This repository is a Python-based AI application with a clear split between a backend service, an agent-orchestration layer, and a separate frontend bundle.
   - The core architecture is centered on LLM-driven agent graphs rather than a traditional CRUD domain model.

2. **Runtime and entrypoints**
   - `main.py` and `src/app.py` are the top-level application entrypoints.
   - `src/api/server.py` is the backend API server boundary.
   - `run.sh` and `docker/docker-compose.yml` indicate the system is designed to run as coordinated services in containers.

3. **API layer**
   - `src/api/server.py` is the external interface for callers.
   - This layer likely receives requests, validates inputs, and delegates work into the agent subsystem rather than implementing business logic itself.
   - The API is the main boundary between the outside world and the internal graph-based workflows.

4. **Agent orchestration core**
   - `src/agents/graph.py` and `src/agents/state.py` define the primary execution model for the application.
   - `src/agents/common/supervisor/*` contains the orchestration logic that routes work between nodes and tools.
   - The presence of `nodes.py`, `edges.py`, `enums.py`, `prompts.py`, and `graph.py` suggests a graph/state-machine style agent pipeline with explicit transitions and prompt templates.

5. **Supervisor pattern**
   - The `supervisor` package is the coordination layer that likely decides which sub-agent or tool should handle the current task.
   - This is a key architectural boundary: the supervisor manages control flow, while specialized tool graphs do the actual task execution.
   - `checkpointer.py` suggests the supervisor workflow can persist or resume execution state across steps.

6. **Specialized tool workflows**
   - Under `src/agents/common/tools/`, there are three task-specific subsystems:
     - `assignment_maker`
     - `quiz_generator`
     - `summarizer`
   - Each tool has its own `graph.py`, `nodes.py`, and `prompts.py`, which implies each is a self-contained agent workflow with its own internal processing steps.
   - These tools are likely invoked by the supervisor depending on the user request or application context.

7. **LLM abstraction layer**
   - `src/ai/llms/config.py`, `enums.py`, and `factory.py` form a provider/model abstraction.
   - This layer isolates the rest of the app from a specific LLM vendor or model choice.
   - The orchestration code depends on this layer to create model instances consistently.

8. **Data flow through the system**
   - A request enters through the API server.
   - The request is translated into application state in `src/agents/state.py`.
   - The supervisor graph evaluates that state, selects a route, and hands off to one of the specialized tool graphs.
   - Tool graphs use prompts and LLM calls to produce outputs, then return results back through the supervisor to the API response path.

9. **Prompt-driven behavior**
   - Prompts are first-class artifacts in this repo, stored separately for the supervisor and each tool.
   - This means behavior is configured as much through prompt templates as through code.
   - For architecture diagrams, prompts should be shown as inputs to the agent nodes rather than as a separate runtime service.

10. **Frontend boundary**
   - The `frontend/` directory is packaged separately with its own `Dockerfile`.
   - This suggests a distinct presentation layer that consumes the backend API, rather than being embedded in the Python service.
   - The frontend is not where agent logic lives; it is a client of the backend.

11. **Containerization and deployment**
   - There are Dockerfiles for both `src/` and `frontend/`, plus a Compose file under `docker/`.
   - The repo is structured for multi-container deployment, likely with at least one backend container and one frontend container.
   - `.env.example` indicates runtime configuration is environment-driven, especially for model credentials or service settings.

12. **Documentation signals**
   - `docs/architecture.md`, `docs/api.md`, and `docs/agents.md` indicate the repo has already been conceptualized around architecture, API boundaries, and agent behavior.
   - For diagramming, the most important structural elements are:
     - external client
     - frontend
     - API server
     - supervisor agent graph
     - specialized tool graphs
     - LLM factory/provider layer
     - checkpoint/state persistence boundary

13. **What is most important to draw**
   - The central diagram should emphasize the orchestration flow: API → supervisor graph → tool graph → LLM → result.
   - The frontend should be shown as a separate consumer of the API.
   - Checkpointing/state should be shown as cross-cutting support inside the agent runtime, not as a standalone business subsystem.

Main entry points: [`src/agents/common/supervisor/graph.py`](https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/supervisor/graph.py) (Supervisor), [`src/ai/llms/factory.py`](https://github.com/yazeedmshayekh2/lms/blob/main/src/ai/llms/factory.py) (LLM Factory), [`src/agents/common/tools.py`](https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/tools.py) (Tools Facade), [`src/agents/graph.py`](https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/graph.py) (Agent Graph)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_frontend["Frontend<br/>client bundle"]
  node_main_py["Main<br/>entrypoint<br/>[main.py]"]
end

subgraph group_backend["Backend API"]
  node_app_py["App<br/>bootstrap<br/>[app.py]"]
  node_api_server["API Server<br/>http server<br/>[server.py]"]
end

subgraph group_agents["Agent Runtime"]
  node_agent_graph["Agent Graph<br/>orchestrator<br/>[graph.py]"]
  node_agent_state["Agent State<br/>state model<br/>[state.py]"]
  node_supervisor_graph["Supervisor<br/>routing graph<br/>[graph.py]"]
  node_supervisor_nodes["Sup Nodes<br/>node set<br/>[nodes.py]"]
  node_supervisor_edges["Sup Edges<br/>transition set<br/>[edges.py]"]
  node_supervisor_prompts["Sup Prompts<br/>prompt set<br/>[prompts.py]"]
  node_checkpointer[("Checkpoint<br/>persistence<br/>[checkpointer.py]")]
  node_assignment_tool["Assign Tool<br/>tool graph<br/>[graph.py]"]
  node_quiz_tool["Quiz Tool<br/>tool graph<br/>[graph.py]"]
  node_summarizer_tool["Summary Tool<br/>tool graph<br/>[graph.py]"]
  node_tools_facade["Tools Facade<br/>tool registry<br/>[tools.py]"]
end

subgraph group_llm["LLM Layer"]
  node_llm_factory["LLM Factory<br/>provider factory<br/>[factory.py]"]
  node_llm_config["LLM Config<br/>provider config<br/>[config.py]"]
  node_llm_enums["LLM Enums<br/>provider enums<br/>[enums.py]"]
end

node_frontend -->|"calls"| node_api_server
node_main_py -->|"starts"| node_app_py
node_app_py -->|"wires"| node_api_server
node_api_server -->|"delegates"| node_agent_graph
node_agent_graph -->|"uses"| node_agent_state
node_agent_graph -->|"routes"| node_supervisor_graph
node_supervisor_graph -->|"executes"| node_supervisor_nodes
node_supervisor_graph -->|"transitions"| node_supervisor_edges
node_supervisor_graph -->|"prompts"| node_supervisor_prompts
node_supervisor_graph -->|"persists"| node_checkpointer
node_supervisor_graph -->|"dispatches"| node_tools_facade
node_tools_facade -->|"includes"| node_assignment_tool
node_tools_facade -->|"includes"| node_quiz_tool
node_tools_facade -->|"includes"| node_summarizer_tool
node_assignment_tool -->|"uses"| node_llm_factory
node_quiz_tool -->|"uses"| node_llm_factory
node_summarizer_tool -->|"uses"| node_llm_factory
node_llm_factory -->|"reads"| node_llm_config
node_llm_factory -->|"selects"| node_llm_enums

click node_frontend "https://github.com/yazeedmshayekh2/lms/tree/main/frontend"
click node_main_py "https://github.com/yazeedmshayekh2/lms/blob/main/main.py"
click node_app_py "https://github.com/yazeedmshayekh2/lms/blob/main/src/app.py"
click node_api_server "https://github.com/yazeedmshayekh2/lms/blob/main/src/api/server.py"
click node_agent_graph "https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/graph.py"
click node_agent_state "https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/state.py"
click node_supervisor_graph "https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/supervisor/graph.py"
click node_supervisor_nodes "https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/supervisor/nodes.py"
click node_supervisor_edges "https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/supervisor/edges.py"
click node_supervisor_prompts "https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/supervisor/prompts.py"
click node_checkpointer "https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/checkpointer.py"
click node_assignment_tool "https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/tools/assignment_maker/graph.py"
click node_quiz_tool "https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/tools/quiz_generator/graph.py"
click node_summarizer_tool "https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/tools/summarizer/graph.py"
click node_tools_facade "https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/tools.py"
click node_llm_factory "https://github.com/yazeedmshayekh2/lms/blob/main/src/ai/llms/factory.py"
click node_llm_config "https://github.com/yazeedmshayekh2/lms/blob/main/src/ai/llms/config.py"
click node_llm_enums "https://github.com/yazeedmshayekh2/lms/blob/main/src/ai/llms/enums.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_main_py toneBlue
class node_app_py,node_api_server toneAmber
class node_agent_graph,node_agent_state,node_supervisor_graph,node_supervisor_nodes,node_supervisor_edges,node_supervisor_prompts,node_checkpointer,node_assignment_tool,node_quiz_tool,node_summarizer_tool,node_tools_facade toneMint
class node_llm_factory,node_llm_config,node_llm_enums toneRose
```

## Components

### Presentation

Frontend client and app entrypoints

- [Frontend](https://github.com/yazeedmshayekh2/lms/tree/main/frontend): client bundle · Separate presentation app that consumes the backend API · `frontend`
- [Main](https://github.com/yazeedmshayekh2/lms/blob/main/main.py): entrypoint · Top-level process entrypoint · `main.py`

### Backend API

HTTP boundary and application bootstrap

- [App](https://github.com/yazeedmshayekh2/lms/blob/main/src/app.py): bootstrap · Application bootstrap and wiring · `src/app.py`
- [API Server](https://github.com/yazeedmshayekh2/lms/blob/main/src/api/server.py): http server · External API boundary for requests into the system · `src/api/server.py`

### Agent Runtime

Graph-based orchestration and task workflows

- [Agent Graph](https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/graph.py): orchestrator · Top-level agent workflow coordinator · `src/agents/graph.py`
- [Agent State](https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/state.py): state model · Shared state passed through agent workflows · `src/agents/state.py`
- [Supervisor](https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/supervisor/graph.py): routing graph · Routes tasks between specialized agent tools · `src/agents/common/supervisor/graph.py`
- [Sup Nodes](https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/supervisor/nodes.py): node set · Supervisor step implementations · `src/agents/common/supervisor/nodes.py`
- [Sup Edges](https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/supervisor/edges.py): transition set · Supervisor routing transitions · `src/agents/common/supervisor/edges.py`
- [Sup Prompts](https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/supervisor/prompts.py): prompt set · Supervisor prompt templates · `src/agents/common/supervisor/prompts.py`
- [Checkpoint](https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/checkpointer.py): persistence · Persisted execution state for resuming workflows · `src/agents/common/checkpointer.py`
- [Assign Tool](https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/tools/assignment_maker/graph.py): tool graph · Assignment-making workflow · `src/agents/common/tools/assignment_maker/graph.py`
- [Quiz Tool](https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/tools/quiz_generator/graph.py): tool graph · Quiz-generation workflow · `src/agents/common/tools/quiz_generator/graph.py`
- [Summary Tool](https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/tools/summarizer/graph.py): tool graph · Summarization workflow · `src/agents/common/tools/summarizer/graph.py`
- [Tools Facade](https://github.com/yazeedmshayekh2/lms/blob/main/src/agents/common/tools.py): tool registry · Shared tool dispatch and organization layer · `src/agents/common/tools.py`

### LLM Layer

Model provider abstraction

- [LLM Factory](https://github.com/yazeedmshayekh2/lms/blob/main/src/ai/llms/factory.py): provider factory · Builds configured model clients · `src/ai/llms/factory.py`
- [LLM Config](https://github.com/yazeedmshayekh2/lms/blob/main/src/ai/llms/config.py): provider config · Model and provider configuration · `src/ai/llms/config.py`
- [LLM Enums](https://github.com/yazeedmshayekh2/lms/blob/main/src/ai/llms/enums.py): provider enums · Supported providers and model choices · `src/ai/llms/enums.py`

## Connections

- Frontend → API Server: calls · Frontend consumes backend endpoints
- Main → App: starts · Primary process boots the app
- App → API Server: wires · Application bootstrap creates the API boundary
- API Server → Agent Graph: delegates · Requests are handed into agent workflows
- Agent Graph → Agent State: uses · Workflow execution is driven by shared state
- Agent Graph → Supervisor: routes · Top-level agent graph hands control to the supervisor
- Supervisor → Sup Nodes: executes · Supervisor runs its step nodes
- Supervisor → Sup Edges: transitions · Supervisor uses explicit routing edges
- Supervisor → Sup Prompts: prompts · Supervisor behavior is prompt-driven
- Supervisor → Checkpoint: persists · Workflow state can be saved and resumed
- Supervisor → Tools Facade: dispatches · Supervisor selects among available tools
- Tools Facade → Assign Tool: includes · Assignment-making workflow is one available tool
- Tools Facade → Quiz Tool: includes · Quiz-generation workflow is one available tool
- Tools Facade → Summary Tool: includes · Summarization workflow is one available tool
- Assign Tool → LLM Factory: uses · Tool workflow builds model clients through the LLM layer
- Quiz Tool → LLM Factory: uses · Tool workflow builds model clients through the LLM layer
- Summary Tool → LLM Factory: uses · Tool workflow builds model clients through the LLM layer
- LLM Factory → LLM Config: reads · Factory is configured by provider settings
- LLM Factory → LLM Enums: selects · Factory uses supported provider/model choices
