# harsha943vf/ai-blog-generator architecture

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

- Interactive diagram: https://gitdiagram.com/harsha943vf/ai-blog-generator
- Repository: https://github.com/harsha943vf/ai-blog-generator

## Overview

This repository generates blog posts through a Streamlit interface and two backend workflows: a LangGraph pipeline with optional research and images, and a separate structured five-step pipeline. The main path classifies a topic, gathers sources when needed, plans and writes sections, then assembles markdown. The graph also preserves the structured workflow and shared model/configuration layer. Relationships for the main pipeline are shown in its wiring; some unsampled implementation details are represented only where documented or supported by the source index.

Main entry points: [`backend/pipeline.py`](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/pipeline.py) (LangGraph pipeline), [`backend/config.py`](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/config.py) (LLM configuration), [`backend/nodes/research.py`](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/nodes/research.py) (Web research), [`app.py`](https://github.com/harsha943vf/ai-blog-generator/blob/main/app.py) (Streamlit interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_ui["Streamlit interface<br/>[app.py]"]
end

subgraph group_generation["Blog generation"]
  node_service["Generation service<br/>[service.py]"]
  node_pipeline["LangGraph pipeline<br/>[pipeline.py]"]
  node_router["Topic router<br/>[router.py]"]
  node_research["Web research<br/>[research.py]"]
  node_planner["Blog planner<br/>[orchestrator.py]"]
  node_worker["Section writer<br/>[worker.py]"]
  node_reducer["Markdown reducer<br/>[reducer.py]"]
  node_images["Image generation<br/>[images.py]"]
end

subgraph group_structured["Structured workflow"]
  node_structured_service["Structured service"]
  node_structured_pipeline["Structured stages"]
  node_structured_prompts["Structured prompts"]
end

subgraph group_shared["Shared services"]
  node_state["Pipeline state<br/>[models.py]"]
  node_tavily_utils["Search utilities<br/>[tavily_utils.py]"]
  node_config["LLM configuration<br/>[config.py]"]
  node_utils["Retry and cache<br/>[utils.py]"]
end

subgraph group_integrations["External services"]
  node_llm{{"Language model provider"}}
  node_tavily{{"Tavily Search"}}
  node_gemini{{"Google Gemini Imagen"}}
end

node_user(("Blog author"))

node_user -->|"submits topic"| node_ui
node_ui -->|"requests generation"| node_service
node_service -->|"invokes graph"| node_pipeline
node_pipeline -->|"routes to"| node_router
node_pipeline -->|"routes when needed"| node_research
node_pipeline -->|"routes to"| node_planner
node_pipeline -->|"routes to"| node_worker
node_pipeline -->|"routes to"| node_reducer
node_pipeline -->|"routes optionally"| node_images
node_research -->|"uses"| node_tavily_utils
node_research -.->|"searches"| node_tavily
node_worker -->|"provides sections"| node_reducer
node_images -.->|"generates images"| node_gemini
node_structured_service -->|"calls workflow stages"| node_structured_pipeline
node_structured_pipeline -->|"uses prompts"| node_structured_prompts
node_config -->|"creates client"| node_llm
node_router -->|"gets model"| node_config
node_planner -->|"gets model"| node_config
node_worker -->|"gets model"| node_config
node_research -->|"gets model"| node_config
node_pipeline -->|"uses graph state"| node_state
node_service -->|"uses cache"| node_utils
node_ui -.->|"offers demo workflow"| node_structured_service

click node_ui "https://github.com/harsha943vf/ai-blog-generator/blob/main/app.py"
click node_service "https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/service.py"
click node_pipeline "https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/pipeline.py"
click node_state "https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/models.py"
click node_router "https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/nodes/router.py"
click node_research "https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/nodes/research.py"
click node_tavily_utils "https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/tavily_utils.py"
click node_planner "https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/nodes/orchestrator.py"
click node_worker "https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/nodes/worker.py"
click node_reducer "https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/nodes/reducer.py"
click node_images "https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/nodes/images.py"
click node_structured_service "https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/structured_service.py"
click node_structured_pipeline "https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/structured_pipeline.py"
click node_structured_prompts "https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/structured_prompts.py"
click node_config "https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/config.py"
click node_utils "https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/utils.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_ui toneBlue
class node_service,node_pipeline,node_router,node_research,node_planner,node_worker,node_reducer,node_images toneAmber
class node_structured_service,node_structured_pipeline,node_structured_prompts toneMint
class node_state,node_tavily_utils,node_config,node_utils toneRose
class node_llm,node_tavily,node_gemini,node_user toneIndigo
```

## Components

### User interface

- [Streamlit interface](https://github.com/harsha943vf/ai-blog-generator/blob/main/app.py): `app.py`

### Blog generation

- [Generation service](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/service.py): `backend/service.py`
- [LangGraph pipeline](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/pipeline.py): `backend/pipeline.py`
- [Topic router](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/nodes/router.py): `backend/nodes/router.py`
- [Web research](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/nodes/research.py): `backend/nodes/research.py`
- [Blog planner](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/nodes/orchestrator.py): `backend/nodes/orchestrator.py`
- [Section writer](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/nodes/worker.py): `backend/nodes/worker.py`
- [Markdown reducer](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/nodes/reducer.py): `backend/nodes/reducer.py`
- [Image generation](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/nodes/images.py): `backend/nodes/images.py`

### Structured workflow

- [Structured service](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/structured_service.py): `backend/structured_service.py`
- [Structured stages](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/structured_pipeline.py): `backend/structured_pipeline.py`
- [Structured prompts](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/structured_prompts.py): `backend/structured_prompts.py`

### Shared services

- [Pipeline state](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/models.py): `backend/models.py`
- [Search utilities](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/tavily_utils.py): `backend/tavily_utils.py`
- [LLM configuration](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/config.py): `backend/config.py`
- [Retry and cache](https://github.com/harsha943vf/ai-blog-generator/blob/main/backend/utils.py): `backend/utils.py`

### External services

- **Language model provider**
- **Tavily Search**
- **Google Gemini Imagen**

### Other components

- **Blog author**

## Connections

- Blog author → Streamlit interface: submits topic (evidence: `README.md`)
- Streamlit interface → Generation service: requests generation (evidence: `app.py`)
- Generation service → LangGraph pipeline: invokes graph (evidence: `backend/service.py`)
- LangGraph pipeline → Topic router: routes to (evidence: `backend/pipeline.py`)
- LangGraph pipeline → Web research: routes when needed (evidence: `backend/pipeline.py`)
- LangGraph pipeline → Blog planner: routes to (evidence: `backend/pipeline.py`)
- LangGraph pipeline → Section writer: routes to (evidence: `backend/pipeline.py`)
- LangGraph pipeline → Markdown reducer: routes to (evidence: `backend/pipeline.py`)
- LangGraph pipeline → Image generation: routes optionally (evidence: `backend/pipeline.py`)
- Web research → Search utilities: uses (evidence: `backend/nodes/research.py`)
- Web research → Tavily Search: searches (evidence: `README.md`)
- Section writer → Markdown reducer: provides sections (evidence: `backend/pipeline.py`)
- Image generation → Google Gemini Imagen: generates images (evidence: `README.md`)
- Structured service → Structured stages: calls workflow stages (evidence: `backend/structured_service.py`)
- Structured stages → Structured prompts: uses prompts (evidence: `backend/structured_pipeline.py`)
- LLM configuration → Language model provider: creates client (evidence: `backend/config.py`)
- Topic router → LLM configuration: gets model (evidence: `backend/nodes/router.py`)
- Blog planner → LLM configuration: gets model (evidence: `backend/nodes/orchestrator.py`)
- Section writer → LLM configuration: gets model (evidence: `backend/nodes/worker.py`)
- Web research → LLM configuration: gets model (evidence: `backend/nodes/research.py`)
- LangGraph pipeline → Pipeline state: uses graph state (evidence: `backend/pipeline.py`)
- Generation service → Retry and cache: uses cache (evidence: `backend/service.py`)
- Streamlit interface → Structured service: offers demo workflow
