# campusx-official/blog-writing-agent architecture

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

- Interactive diagram: https://gitdiagram.com/campusx-official/blog-writing-agent
- Repository: https://github.com/campusx-official/blog-writing-agent

## Overview

This is a Streamlit technical-blog generation app. A user enters a topic and date, the frontend invokes the LangGraph backend, and the result is presented as a plan, research evidence, Markdown preview, and images, with download options. The backend excerpt shows routing, structured planning, section writing, image generation, and Markdown output; the frontend excerpt shows progress streaming and loading previously saved blogs. Internal graph wiring and research-provider calls are not visible in the excerpts, so those relationships are omitted rather than inferred.

Main entry points: [`bwa_frontend.py`](https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_frontend.py) (Streamlit interface), [`bwa_backend.py`](https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_backend.py) (LangGraph app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_frontend["Streamlit interface<br/>[bwa_frontend.py]"]
  node_past_blogs["Past blog loader<br/>[bwa_frontend.py]"]
  node_downloads["Download bundles<br/>[bwa_frontend.py]"]
end

subgraph group_writing["Blog generation"]
  node_backend["LangGraph app<br/>[bwa_backend.py]"]
  node_router["Research router<br/>[bwa_backend.py]"]
  node_evidence["Evidence extraction<br/>[bwa_backend.py]"]
  node_planner["Blog planner<br/>[bwa_backend.py]"]
  node_section_worker["Section writer<br/>[bwa_backend.py]"]
end

subgraph group_media["Image generation"]
  node_image_planner["Image planner<br/>[bwa_backend.py]"]
  node_image_generator["Image generator<br/>[bwa_backend.py]"]
end

subgraph group_artifacts["Saved outputs"]
  node_markdown_files["Markdown files"]
  node_image_files["Generated images"]
end

node_user(("Blog author"))
node_openai["OpenAI model"]
node_gemini["Gemini image model"]

node_user -->|"enters topic"| node_frontend
node_frontend -->|"invokes app"| node_backend
node_router -->|"asks model"| node_openai
node_planner -->|"plans with"| node_openai
node_section_worker -->|"writes with"| node_openai
node_image_planner -->|"plans with"| node_openai
node_image_generator -->|"generates with"| node_gemini
node_backend -->|"writes Markdown"| node_markdown_files
node_backend -->|"writes images"| node_image_files
node_frontend -->|"loads saved blogs"| node_past_blogs
node_past_blogs -->|"reads files"| node_markdown_files
node_frontend -->|"offers downloads"| node_downloads
node_downloads -->|"bundles Markdown"| node_markdown_files
node_downloads -->|"bundles images"| node_image_files

click node_frontend "https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_frontend.py"
click node_backend "https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_backend.py"
click node_router "https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_backend.py"
click node_evidence "https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_backend.py"
click node_planner "https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_backend.py"
click node_section_worker "https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_backend.py"
click node_image_planner "https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_backend.py"
click node_image_generator "https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_backend.py"
click node_past_blogs "https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_frontend.py"
click node_downloads "https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_frontend.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_past_blogs,node_downloads toneBlue
class node_backend,node_router,node_evidence,node_planner,node_section_worker toneAmber
class node_image_planner,node_image_generator toneMint
class node_markdown_files,node_image_files toneRose
class node_user,node_openai,node_gemini toneIndigo
```

## Components

### User interface

- [Streamlit interface](https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_frontend.py): `bwa_frontend.py`
- [Past blog loader](https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_frontend.py): `bwa_frontend.py`
- [Download bundles](https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_frontend.py): `bwa_frontend.py`

### Blog generation

- [LangGraph app](https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_backend.py): `bwa_backend.py`
- [Research router](https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_backend.py): `bwa_backend.py`
- [Evidence extraction](https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_backend.py): `bwa_backend.py`
- [Blog planner](https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_backend.py): `bwa_backend.py`
- [Section writer](https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_backend.py): `bwa_backend.py`

### Image generation

- [Image planner](https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_backend.py): `bwa_backend.py`
- [Image generator](https://github.com/campusx-official/blog-writing-agent/blob/main/bwa_backend.py): `bwa_backend.py`

### Saved outputs

- **Markdown files**
- **Generated images**

### Other components

- **Blog author**
- **OpenAI model**
- **Gemini image model**

## Connections

- Blog author → Streamlit interface: enters topic (evidence: `bwa_frontend.py`)
- Streamlit interface → LangGraph app: invokes app (evidence: `bwa_frontend.py`)
- Research router → OpenAI model: asks model (evidence: `bwa_backend.py`)
- Blog planner → OpenAI model: plans with (evidence: `bwa_backend.py`)
- Section writer → OpenAI model: writes with (evidence: `bwa_backend.py`)
- Image planner → OpenAI model: plans with (evidence: `bwa_backend.py`)
- Image generator → Gemini image model: generates with (evidence: `bwa_backend.py`)
- LangGraph app → Markdown files: writes Markdown (evidence: `bwa_backend.py`)
- LangGraph app → Generated images: writes images (evidence: `bwa_backend.py`)
- Streamlit interface → Past blog loader: loads saved blogs (evidence: `bwa_frontend.py`)
- Past blog loader → Markdown files: reads files (evidence: `bwa_frontend.py`)
- Streamlit interface → Download bundles: offers downloads (evidence: `bwa_frontend.py`)
- Download bundles → Markdown files: bundles Markdown (evidence: `bwa_frontend.py`)
- Download bundles → Generated images: bundles images (evidence: `bwa_frontend.py`)
