# pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph architecture

> Architecture diagram of the GitHub repository pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph
- Repository: https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph

## Overview

This is a web-backed, multi-agent CTR experimentation system: users provide a dataset and training options, agents inspect and model the data, then produce evaluation results and a saved champion model for single-record prediction. The graph follows the documented supervisor-led stages and the source-indexed calls; implementation details for the frontend and several workflow internals were not excerpted, so their connections are omitted where unverified.

Main entry points: [`backend/agents/graph.py`](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/graph.py) (Workflow graph), [`backend/agents/supervisor.py`](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/supervisor.py) (Supervisor), [`backend/main.py`](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/main.py) (FastAPI service), [`backend/agents/data_agent.py`](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/data_agent.py) (Data analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Web interface"]
  node_frontend["Web client<br/>[app.js]"]
end

subgraph group_api["API and runs"]
  node_api_server["FastAPI service<br/>[main.py]"]
  node_run_state[("Run status<br/>[main.py]")]
  node_sample_data["Sample data generator<br/>[sample_data.py]"]
end

subgraph group_workflow["Agent workflow"]
  node_graph["Workflow graph<br/>[graph.py]"]
  node_supervisor["Supervisor<br/>[supervisor.py]"]
  node_agent_state["Shared agent state<br/>[state.py]"]
  node_data_agent["Data analysis<br/>[data_agent.py]"]
  node_model_agent["Model training<br/>[model_agent.py]"]
  node_evaluator["Evaluation report<br/>[evaluator_agent.py]"]
  node_llm_helper["LLM helper<br/>[llm_helper.py]"]
end

subgraph group_ml["CTR modeling"]
  node_pipeline["CTR pipeline<br/>[pipeline.py]"]
  node_artifacts[("Model artifacts<br/>[main.py]")]
end

node_user(("User"))
node_gemini["Gemini LLM"]

node_user -.->|"provides request"| node_frontend
node_user -->|"submits dataset"| node_api_server
node_api_server -->|"generates sample"| node_sample_data
node_api_server -->|"tracks run"| node_run_state
node_api_server -->|"invokes workflow"| node_graph
node_graph -->|"routes to"| node_supervisor
node_supervisor -->|"selects next node"| node_graph
node_graph -->|"dispatches"| node_data_agent
node_graph -->|"dispatches"| node_model_agent
node_graph -->|"dispatches"| node_evaluator
node_data_agent -->|"returns to"| node_supervisor
node_model_agent -->|"returns to"| node_supervisor
node_evaluator -->|"returns to"| node_supervisor
node_graph -->|"uses state"| node_agent_state
node_supervisor -->|"reads and updates"| node_agent_state
node_data_agent -->|"reads and updates"| node_agent_state
node_model_agent -->|"reads and updates"| node_agent_state
node_evaluator -->|"reads and updates"| node_agent_state
node_data_agent -->|"analyzes dataset"| node_pipeline
node_model_agent -->|"trains and saves"| node_pipeline
node_api_server -->|"loads for prediction"| node_pipeline
node_pipeline -->|"saves model"| node_artifacts
node_api_server -->|"copies artifacts"| node_artifacts
node_supervisor -->|"requests LLM"| node_llm_helper
node_data_agent -->|"requests LLM"| node_llm_helper
node_model_agent -->|"requests LLM"| node_llm_helper
node_evaluator -->|"requests LLM"| node_llm_helper
node_llm_helper -->|"initializes client"| node_gemini

click node_frontend "https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/frontend/app.js"
click node_api_server "https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/main.py"
click node_run_state "https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/main.py"
click node_sample_data "https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/utils/sample_data.py"
click node_graph "https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/graph.py"
click node_supervisor "https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/supervisor.py"
click node_agent_state "https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/state.py"
click node_data_agent "https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/data_agent.py"
click node_model_agent "https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/model_agent.py"
click node_evaluator "https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/evaluator_agent.py"
click node_llm_helper "https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/llm_helper.py"
click node_pipeline "https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/ml/pipeline.py"
click node_artifacts "https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/main.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_user toneBlue
class node_api_server,node_run_state,node_sample_data toneAmber
class node_graph,node_supervisor,node_agent_state,node_data_agent,node_model_agent,node_evaluator,node_llm_helper toneMint
class node_pipeline,node_artifacts toneRose
class node_gemini toneIndigo
```

## Components

### Web interface

- [Web client](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/frontend/app.js): `frontend/app.js`

### API and runs

- [FastAPI service](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/main.py): `backend/main.py`
- [Run status](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/main.py): `backend/main.py`
- [Sample data generator](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/utils/sample_data.py): `backend/utils/sample_data.py`

### Agent workflow

- [Workflow graph](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/graph.py): `backend/agents/graph.py`
- [Supervisor](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/supervisor.py): `backend/agents/supervisor.py`
- [Shared agent state](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/state.py): `backend/agents/state.py`
- [Data analysis](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/data_agent.py): `backend/agents/data_agent.py`
- [Model training](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/model_agent.py): `backend/agents/model_agent.py`
- [Evaluation report](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/evaluator_agent.py): `backend/agents/evaluator_agent.py`
- [LLM helper](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/agents/llm_helper.py): `backend/agents/llm_helper.py`

### CTR modeling

- [CTR pipeline](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/ml/pipeline.py): `backend/ml/pipeline.py`
- [Model artifacts](https://github.com/pranav1237/build-a-multi-agent-ctr-prediction-system-with-langgraph/blob/main/backend/main.py): `backend/main.py`

### Other components

- **User**
- **Gemini LLM**

## Connections

- User → Web client: provides request
- User → FastAPI service: submits dataset (evidence: `backend/main.py`)
- FastAPI service → Sample data generator: generates sample (evidence: `backend/main.py`)
- FastAPI service → Run status: tracks run (evidence: `backend/main.py`)
- FastAPI service → Workflow graph: invokes workflow (evidence: `backend/main.py`)
- Workflow graph → Supervisor: routes to (evidence: `backend/agents/graph.py`)
- Supervisor → Workflow graph: selects next node (evidence: `backend/agents/graph.py`)
- Workflow graph → Data analysis: dispatches (evidence: `backend/agents/graph.py`)
- Workflow graph → Model training: dispatches (evidence: `backend/agents/graph.py`)
- Workflow graph → Evaluation report: dispatches (evidence: `backend/agents/graph.py`)
- Data analysis → Supervisor: returns to (evidence: `backend/agents/graph.py`)
- Model training → Supervisor: returns to (evidence: `backend/agents/graph.py`)
- Evaluation report → Supervisor: returns to (evidence: `backend/agents/graph.py`)
- Workflow graph → Shared agent state: uses state (evidence: `backend/agents/graph.py`)
- Supervisor → Shared agent state: reads and updates (evidence: `backend/agents/supervisor.py`)
- Data analysis → Shared agent state: reads and updates (evidence: `backend/agents/data_agent.py`)
- Model training → Shared agent state: reads and updates (evidence: `backend/agents/model_agent.py`)
- Evaluation report → Shared agent state: reads and updates (evidence: `backend/agents/evaluator_agent.py`)
- Data analysis → CTR pipeline: analyzes dataset (evidence: `backend/agents/data_agent.py`)
- Model training → CTR pipeline: trains and saves (evidence: `backend/agents/model_agent.py`)
- FastAPI service → CTR pipeline: loads for prediction (evidence: `backend/main.py`)
- CTR pipeline → Model artifacts: saves model (evidence: `backend/ml/pipeline.py`)
- FastAPI service → Model artifacts: copies artifacts (evidence: `backend/main.py`)
- Supervisor → LLM helper: requests LLM (evidence: `backend/agents/supervisor.py`)
- Data analysis → LLM helper: requests LLM (evidence: `backend/agents/data_agent.py`)
- Model training → LLM helper: requests LLM (evidence: `backend/agents/model_agent.py`)
- Evaluation report → LLM helper: requests LLM (evidence: `backend/agents/evaluator_agent.py`)
- LLM helper → Gemini LLM: initializes client (evidence: `backend/agents/llm_helper.py`)
