# kartavyaverma/blogpilotai architecture

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

- Interactive diagram: https://gitdiagram.com/kartavyaverma/blogpilotai
- Repository: https://github.com/kartavyaverma/blogpilotai

## Overview

BlogPilot AI turns a user topic into a research-backed technical article, optionally adding generated diagrams, and streams progress to its web UI. The principal workflow runs through FastAPI, graph execution, routing, research, planning, parallel writing, and editorial reduction; users can download the Markdown result. The graph preserves the documented SSE, checkpointing, model-provider, and diagram capabilities. Relationships for unsampled routes and UI behavior rely on README statements and the source index; no unsampled implementation details are assumed.

Main entry points: [`src/core/llm.py`](https://github.com/kartavyaverma/blogpilotai/blob/main/src/core/llm.py) (LLM provider factory), [`src/agents/reducer.py`](https://github.com/kartavyaverma/blogpilotai/blob/main/src/agents/reducer.py) (Diagram generator), [`src/graph/builder.py`](https://github.com/kartavyaverma/blogpilotai/blob/main/src/graph/builder.py) (Graph builder), [`src/graph/streaming.py`](https://github.com/kartavyaverma/blogpilotai/blob/main/src/graph/streaming.py) (SSE workflow runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Web Interface"]
  node_app["FastAPI app<br/>[app.py]"]
  node_pages["Web pages<br/>[pages.py]"]
  node_run_api["Run and download API<br/>[runs.py]"]
  node_health["Health endpoint<br/>[health.py]"]
  node_browser["Interactive browser UI<br/>[app.js]"]
end

subgraph group_workflow["Workflow Orchestration"]
  node_stream["SSE workflow runner<br/>[streaming.py]"]
  node_graph["Graph builder<br/>[builder.py]"]
end

subgraph group_writing["Editorial Agents"]
  node_router["Topic router<br/>[router.py]"]
  node_research["Evidence research<br/>[research.py]"]
  node_planner["Article planner<br/>[orchestrator.py]"]
  node_worker["Section writer<br/>[worker.py]"]
  node_merge["Content merger<br/>[reducer.py]"]
  node_image_plan["Diagram planner<br/>[reducer.py]"]
  node_diagram["Diagram generator<br/>[reducer.py]"]
end

subgraph group_services["Models and Services"]
  node_config["Runtime configuration<br/>[config.py]"]
  node_llm["LLM provider factory<br/>[llm.py]"]
  node_llm_service["Groq or Moonshot"]
  node_tavily["Tavily search"]
  node_kroki["Kroki renderer"]
end

subgraph group_state["State and Output"]
  node_schemas["Workflow data models<br/>[models.py]"]
  node_checkpoint[("PostgreSQL checkpoint")]
  node_markdown["Generated Markdown"]
  node_images[("Generated diagrams")]
end

node_writer(("Blog author"))

node_writer -->|"submits topic"| node_browser
node_browser -->|"starts run"| node_run_api
node_app -->|"mounts route"| node_pages
node_app -->|"mounts route"| node_health
node_app -->|"mounts route"| node_run_api
node_pages -->|"serves interface"| node_browser
node_run_api -->|"starts stream"| node_stream
node_stream -->|"runs workflow"| node_graph
node_graph -->|"dispatches first"| node_router
node_router -->|"routes when needed"| node_research
node_router -->|"routes otherwise"| node_planner
node_research -->|"passes evidence"| node_planner
node_planner -->|"fans out sections"| node_worker
node_worker -->|"sends sections"| node_merge
node_merge -->|"prepares outline"| node_image_plan
node_image_plan -->|"plans visuals"| node_diagram
node_diagram -->|"assembles article"| node_markdown
node_diagram -->|"writes image files"| node_images
node_diagram -->|"renders Mermaid"| node_kroki
node_research -->|"searches queries"| node_tavily
node_router -->|"classifies topic"| node_llm
node_research -->|"extracts evidence"| node_llm
node_planner -->|"creates plan"| node_llm
node_worker -->|"writes sections"| node_llm
node_image_plan -->|"plans diagrams"| node_llm
node_diagram -->|"creates Mermaid"| node_llm
node_llm -->|"selects provider"| node_llm_service
node_config -->|"configures models"| node_llm
node_graph -->|"persists graph state"| node_checkpoint
node_stream -->|"saves final file"| node_markdown
node_run_api -->|"serves download"| node_markdown
node_stream -->|"streams progress"| node_browser
node_schemas -->|"defines graph state"| node_graph
node_config -->|"configures checkpoint"| node_graph

click node_app "https://github.com/kartavyaverma/blogpilotai/blob/main/src/app.py"
click node_pages "https://github.com/kartavyaverma/blogpilotai/blob/main/src/api/routes/pages.py"
click node_run_api "https://github.com/kartavyaverma/blogpilotai/blob/main/src/api/routes/runs.py"
click node_health "https://github.com/kartavyaverma/blogpilotai/blob/main/src/api/routes/health.py"
click node_browser "https://github.com/kartavyaverma/blogpilotai/blob/main/src/static/js/app.js"
click node_stream "https://github.com/kartavyaverma/blogpilotai/blob/main/src/graph/streaming.py"
click node_graph "https://github.com/kartavyaverma/blogpilotai/blob/main/src/graph/builder.py"
click node_router "https://github.com/kartavyaverma/blogpilotai/blob/main/src/agents/router.py"
click node_research "https://github.com/kartavyaverma/blogpilotai/blob/main/src/agents/research.py"
click node_planner "https://github.com/kartavyaverma/blogpilotai/blob/main/src/agents/orchestrator.py"
click node_worker "https://github.com/kartavyaverma/blogpilotai/blob/main/src/agents/worker.py"
click node_merge "https://github.com/kartavyaverma/blogpilotai/blob/main/src/agents/reducer.py"
click node_image_plan "https://github.com/kartavyaverma/blogpilotai/blob/main/src/agents/reducer.py"
click node_diagram "https://github.com/kartavyaverma/blogpilotai/blob/main/src/agents/reducer.py"
click node_schemas "https://github.com/kartavyaverma/blogpilotai/blob/main/src/schemas/models.py"
click node_config "https://github.com/kartavyaverma/blogpilotai/blob/main/src/core/config.py"
click node_llm "https://github.com/kartavyaverma/blogpilotai/blob/main/src/core/llm.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_app,node_pages,node_run_api,node_health,node_browser toneBlue
class node_stream,node_graph toneAmber
class node_router,node_research,node_planner,node_worker,node_merge,node_image_plan,node_diagram toneMint
class node_config,node_llm,node_llm_service,node_tavily,node_kroki toneRose
class node_schemas,node_checkpoint,node_markdown,node_images,node_writer toneIndigo
```

## Components

### Web Interface

- [FastAPI app](https://github.com/kartavyaverma/blogpilotai/blob/main/src/app.py): `src/app.py`
- [Web pages](https://github.com/kartavyaverma/blogpilotai/blob/main/src/api/routes/pages.py): `src/api/routes/pages.py`
- [Run and download API](https://github.com/kartavyaverma/blogpilotai/blob/main/src/api/routes/runs.py): `src/api/routes/runs.py`
- [Health endpoint](https://github.com/kartavyaverma/blogpilotai/blob/main/src/api/routes/health.py): `src/api/routes/health.py`
- [Interactive browser UI](https://github.com/kartavyaverma/blogpilotai/blob/main/src/static/js/app.js): `src/static/js/app.js`

### Workflow Orchestration

- [SSE workflow runner](https://github.com/kartavyaverma/blogpilotai/blob/main/src/graph/streaming.py): `src/graph/streaming.py`
- [Graph builder](https://github.com/kartavyaverma/blogpilotai/blob/main/src/graph/builder.py): `src/graph/builder.py`

### Editorial Agents

- [Topic router](https://github.com/kartavyaverma/blogpilotai/blob/main/src/agents/router.py): `src/agents/router.py`
- [Evidence research](https://github.com/kartavyaverma/blogpilotai/blob/main/src/agents/research.py): `src/agents/research.py`
- [Article planner](https://github.com/kartavyaverma/blogpilotai/blob/main/src/agents/orchestrator.py): `src/agents/orchestrator.py`
- [Section writer](https://github.com/kartavyaverma/blogpilotai/blob/main/src/agents/worker.py): `src/agents/worker.py`
- [Content merger](https://github.com/kartavyaverma/blogpilotai/blob/main/src/agents/reducer.py): `src/agents/reducer.py`
- [Diagram planner](https://github.com/kartavyaverma/blogpilotai/blob/main/src/agents/reducer.py): `src/agents/reducer.py`
- [Diagram generator](https://github.com/kartavyaverma/blogpilotai/blob/main/src/agents/reducer.py): `src/agents/reducer.py`

### Models and Services

- [Runtime configuration](https://github.com/kartavyaverma/blogpilotai/blob/main/src/core/config.py): `src/core/config.py`
- [LLM provider factory](https://github.com/kartavyaverma/blogpilotai/blob/main/src/core/llm.py): `src/core/llm.py`
- **Groq or Moonshot**
- **Tavily search**
- **Kroki renderer**

### State and Output

- [Workflow data models](https://github.com/kartavyaverma/blogpilotai/blob/main/src/schemas/models.py): `src/schemas/models.py`
- **PostgreSQL checkpoint**
- **Generated Markdown**
- **Generated diagrams**

### Other components

- **Blog author**

## Connections

- Blog author → Interactive browser UI: submits topic (evidence: `README.md`)
- Interactive browser UI → Run and download API: starts run (evidence: `README.md`)
- FastAPI app → Web pages: mounts route (evidence: `src/app.py`)
- FastAPI app → Health endpoint: mounts route (evidence: `src/app.py`)
- FastAPI app → Run and download API: mounts route (evidence: `src/app.py`)
- Web pages → Interactive browser UI: serves interface (evidence: `README.md`)
- Run and download API → SSE workflow runner: starts stream (evidence: `src/api/routes/runs.py`)
- SSE workflow runner → Graph builder: runs workflow (evidence: `src/graph/streaming.py`)
- Graph builder → Topic router: dispatches first (evidence: `src/graph/builder.py`)
- Topic router → Evidence research: routes when needed (evidence: `src/agents/router.py`)
- Topic router → Article planner: routes otherwise (evidence: `src/agents/router.py`)
- Evidence research → Article planner: passes evidence (evidence: `src/graph/builder.py`)
- Article planner → Section writer: fans out sections (evidence: `src/agents/orchestrator.py`)
- Section writer → Content merger: sends sections (evidence: `src/graph/builder.py`)
- Content merger → Diagram planner: prepares outline (evidence: `README.md`)
- Diagram planner → Diagram generator: plans visuals (evidence: `src/agents/reducer.py`)
- Diagram generator → Generated Markdown: assembles article (evidence: `src/agents/reducer.py`)
- Diagram generator → Generated diagrams: writes image files (evidence: `src/agents/reducer.py`)
- Diagram generator → Kroki renderer: renders Mermaid (evidence: `src/agents/reducer.py`)
- Evidence research → Tavily search: searches queries (evidence: `src/agents/research.py`)
- Topic router → LLM provider factory: classifies topic (evidence: `src/agents/router.py`)
- Evidence research → LLM provider factory: extracts evidence (evidence: `src/agents/research.py`)
- Article planner → LLM provider factory: creates plan (evidence: `src/agents/orchestrator.py`)
- Section writer → LLM provider factory: writes sections (evidence: `src/agents/worker.py`)
- Diagram planner → LLM provider factory: plans diagrams (evidence: `README.md`)
- Diagram generator → LLM provider factory: creates Mermaid (evidence: `src/agents/reducer.py`)
- LLM provider factory → Groq or Moonshot: selects provider (evidence: `src/core/llm.py`)
- Runtime configuration → LLM provider factory: configures models (evidence: `src/core/llm.py`)
- Graph builder → PostgreSQL checkpoint: persists graph state (evidence: `README.md`)
- SSE workflow runner → Generated Markdown: saves final file (evidence: `src/graph/streaming.py`)
- Run and download API → Generated Markdown: serves download (evidence: `src/api/routes/runs.py`)
- SSE workflow runner → Interactive browser UI: streams progress (evidence: `README.md`)
- Workflow data models → Graph builder: defines graph state (evidence: `src/graph/builder.py`)
- Runtime configuration → Graph builder: configures checkpoint (evidence: `src/graph/builder.py`)
