# kumardhananjaya/agentlens architecture

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

- Interactive diagram: https://gitdiagram.com/kumardhananjaya/agentlens
- Repository: https://github.com/kumardhananjaya/agentlens

## Overview

AgentLens is a LangGraph visualizer SDK: an application developer attaches it to a FastAPI or Flask app, and the UI retrieves a graph schema and renders it as an interactive flowchart. Its callback handler can broadcast execution events over WebSockets for live node highlighting. The graph preserves the documented integration and the sampled runtime/UI layers; some cross-process HTTP and WebSocket links are shown as unverified because no single excerpt establishes both ends.

Main entry points: [`web/src/components/GraphFlow.tsx`](https://github.com/kumardhananjaya/agentlens/blob/main/web/src/components/GraphFlow.tsx) (Interactive Graph View), [`sdk/python/agentlens/server.py`](https://github.com/kumardhananjaya/agentlens/blob/main/sdk/python/agentlens/server.py) (Route and Socket Server), [`sdk/python/agentlens/__init__.py`](https://github.com/kumardhananjaya/agentlens/blob/main/sdk/python/agentlens/__init__.py) (Visualizer API), [`sdk/python/agentlens/callback.py`](https://github.com/kumardhananjaya/agentlens/blob/main/sdk/python/agentlens/callback.py) (Execution Callback)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["SDK Integration"]
  node_visualizer["Visualizer API<br/>[__init__.py]"]
  node_callback["Execution Callback<br/>[callback.py]"]
end

subgraph group_runtime["Backend Runtime"]
  node_server["Route and Socket Server<br/>[server.py]"]
  node_parser["Graph Schema Parser<br/>[parser.py]"]
end

subgraph group_webapp["Web Visualizer"]
  node_app["UI App<br/>[App.tsx]"]
  node_graphflow["Interactive Graph View<br/>[GraphFlow.tsx]"]
  node_entry["UI Entry Point<br/>[main.tsx]"]
end

subgraph group_rendering["Graph Rendering"]
  node_layout["Graph Layout<br/>[layout.ts]"]
  node_customnode["Custom Graph Node<br/>[CustomNode.tsx]"]
end

node_developer(("Application Developer"))
node_hostapp["Host App"]
node_langgraph["LangGraph"]
node_browser(("Browser"))

node_developer -->|"attaches visualizer"| node_visualizer
node_visualizer -->|"delegates attachment"| node_server
node_developer -->|"provides app"| node_hostapp
node_hostapp -->|"receives routes"| node_server
node_server -->|"parses schema"| node_parser
node_visualizer -->|"returns schema"| node_parser
node_langgraph -.->|"supplies graph"| node_parser
node_developer -.->|"registers callback"| node_callback
node_callback -->|"broadcasts events"| node_server
node_browser -->|"loads UI"| node_entry
node_entry -->|"renders"| node_app
node_app -->|"renders view"| node_graphflow
node_graphflow -.->|"fetches schema and opens socket"| node_server
node_graphflow -->|"computes positions"| node_layout
node_graphflow -->|"renders nodes"| node_customnode
node_callback -.->|"streams execution events"| node_graphflow

click node_visualizer "https://github.com/kumardhananjaya/agentlens/blob/main/sdk/python/agentlens/__init__.py"
click node_callback "https://github.com/kumardhananjaya/agentlens/blob/main/sdk/python/agentlens/callback.py"
click node_server "https://github.com/kumardhananjaya/agentlens/blob/main/sdk/python/agentlens/server.py"
click node_parser "https://github.com/kumardhananjaya/agentlens/blob/main/sdk/python/agentlens/parser.py"
click node_app "https://github.com/kumardhananjaya/agentlens/blob/main/web/src/App.tsx"
click node_graphflow "https://github.com/kumardhananjaya/agentlens/blob/main/web/src/components/GraphFlow.tsx"
click node_layout "https://github.com/kumardhananjaya/agentlens/blob/main/web/src/utils/layout.ts"
click node_customnode "https://github.com/kumardhananjaya/agentlens/blob/main/web/src/components/CustomNode.tsx"
click node_entry "https://github.com/kumardhananjaya/agentlens/blob/main/web/src/main.tsx"

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_visualizer,node_callback,node_browser toneBlue
class node_server,node_parser toneAmber
class node_app,node_graphflow,node_entry toneMint
class node_layout,node_customnode toneRose
class node_developer,node_hostapp,node_langgraph toneIndigo
```

## Components

### SDK Integration

- [Visualizer API](https://github.com/kumardhananjaya/agentlens/blob/main/sdk/python/agentlens/__init__.py): `sdk/python/agentlens/__init__.py`
- [Execution Callback](https://github.com/kumardhananjaya/agentlens/blob/main/sdk/python/agentlens/callback.py): `sdk/python/agentlens/callback.py`

### Backend Runtime

- [Route and Socket Server](https://github.com/kumardhananjaya/agentlens/blob/main/sdk/python/agentlens/server.py): `sdk/python/agentlens/server.py`
- [Graph Schema Parser](https://github.com/kumardhananjaya/agentlens/blob/main/sdk/python/agentlens/parser.py): `sdk/python/agentlens/parser.py`

### Web Visualizer

- [UI App](https://github.com/kumardhananjaya/agentlens/blob/main/web/src/App.tsx): `web/src/App.tsx`
- [Interactive Graph View](https://github.com/kumardhananjaya/agentlens/blob/main/web/src/components/GraphFlow.tsx): `web/src/components/GraphFlow.tsx`
- [UI Entry Point](https://github.com/kumardhananjaya/agentlens/blob/main/web/src/main.tsx): `web/src/main.tsx`

### Graph Rendering

- [Graph Layout](https://github.com/kumardhananjaya/agentlens/blob/main/web/src/utils/layout.ts): `web/src/utils/layout.ts`
- [Custom Graph Node](https://github.com/kumardhananjaya/agentlens/blob/main/web/src/components/CustomNode.tsx): `web/src/components/CustomNode.tsx`

### Other components

- **Application Developer**
- **Host App**
- **LangGraph**
- **Browser**

## Connections

- Application Developer → Visualizer API: attaches visualizer (evidence: `README.md`)
- Visualizer API → Route and Socket Server: delegates attachment (evidence: `sdk/python/agentlens/__init__.py`)
- Application Developer → Host App: provides app (evidence: `README.md`)
- Host App → Route and Socket Server: receives routes (evidence: `sdk/python/agentlens/server.py`)
- Route and Socket Server → Graph Schema Parser: parses schema (evidence: `sdk/python/agentlens/server.py`)
- Visualizer API → Graph Schema Parser: returns schema (evidence: `sdk/python/agentlens/__init__.py`)
- LangGraph → Graph Schema Parser: supplies graph
- Application Developer → Execution Callback: registers callback
- Execution Callback → Route and Socket Server: broadcasts events (evidence: `sdk/python/agentlens/callback.py`)
- Browser → UI Entry Point: loads UI (evidence: `web/src/main.tsx`)
- UI Entry Point → UI App: renders (evidence: `web/src/main.tsx`)
- UI App → Interactive Graph View: renders view (evidence: `web/src/App.tsx`)
- Interactive Graph View → Route and Socket Server: fetches schema and opens socket
- Interactive Graph View → Graph Layout: computes positions (evidence: `web/src/components/GraphFlow.tsx`)
- Interactive Graph View → Custom Graph Node: renders nodes (evidence: `web/src/components/GraphFlow.tsx`)
- Execution Callback → Interactive Graph View: streams execution events
