# rizwankaka/langgraph-blog-generator architecture

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

- Interactive diagram: https://gitdiagram.com/rizwankaka/langgraph-blog-generator
- Repository: https://github.com/rizwankaka/langgraph-blog-generator

## Overview

##### Project type and purpose
- This is a lightweight full-stack “single-page” Python application built with Streamlit.
- Purpose: let end users enter a blog topic, generate AI-powered titles and full posts with adjustable tone, audience, and length, then export to Markdown/Text.

##### File structure
- Top-level files only:
- langgraphBlogPost.py – the entire Streamlit UI and business logic in one script
- requirements.txt – Python dependencies
- .env – environment variables (Groq API key)
- README.md, LICENSE – docs and licensing
- No separate frontend/backend directories – everything runs in the same Python process under Streamlit.
- External configuration: the Groq API key is injected via .env

##### README for additional insights
- Tech stack: Python 3.12, Streamlit for UI, LangGraph SDK to orchestrate prompts, Groq (external inference API) for LLM.
- Key flows described: user input → title generation → title selection → full post generation → export.

a. Main components
1. User Browser (Client)
2. Streamlit Application (UI Layer in langgraphBlogPost.py)
3. Business Logic Modules (inside the script):
– Input Handler (topic, tone, audience, length)
– Title Generator
– Blog Post Generator
– Exporter (Markdown/Text)
4. LangGraph SDK (Python library)
5. Groq Inference API (external service)
6. .env / Config Store (API key)

b. Relationships and interactions
- User → (HTTP/WebSocket) → Streamlit UI
- Streamlit UI → Input Handler → invokes Title Generator
- Title Generator → LangGraph SDK → Groq API call → returns candidate titles → back to UI
- User selects title → triggers Blog Post Generator → again via LangGraph → Groq → full draft
- Blog Post Generator → passes output to Exporter → writes to in-memory buffer or disk (Markdown/Text)
- UI offers download link

c. Architectural patterns / design principles
- Monolithic front-and-backend: UI and logic are collocated in one script
- Event-driven flow: UI callbacks invoke sequential pipeline stages
- Dependency injection for API keys via .env
- Modular functions for extensibility (e.g., you could split each stage into its own module)

d. Key technologies & libraries
- Python 3.12
- Streamlit (UI server + widget callbacks)
- LangGraph (prompt orchestration)
- Groq API (LLM inference)
- dotenv or similar for environment loading

##### Additional advice
- Keep the sequence: Input → Title → Selection → Full Post → Export so stakeholders see the user journey

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser["User Browser"]:::client
    end

    %% Application Layer
    subgraph "Application Layer"
        StreamlitUI["Streamlit Application UI"]:::ui
        subgraph "Internal Business Logic"
            InputHandler["Input Handler Module"]:::logic
            TitleGen["Title Generator Module"]:::logic
            PostGen["Blog Post Generator Module"]:::logic
            Exporter["Exporter (Markdown/Text)"]:::logic
        end
    end

    %% External Services
    subgraph "External Services"
        LangGraph["LangGraph SDK"]:::external
        GroqAPI["Groq Inference API"]:::external
    end

    %% Configuration and Documentation
    subgraph "Configuration & Docs"
        ConfigStore[".env (API Key)"]:::config
        Reqs["requirements.txt"]:::config
        Readme["README.md"]:::config
        License["LICENSE"]:::config
    end

    %% Data Flows
    Browser -->|"HTTP/WebSocket"| StreamlitUI
    StreamlitUI -->|"collect inputs"| InputHandler
    InputHandler -->|"invoke"| TitleGen
    TitleGen -->|"calls"| LangGraph
    LangGraph -->|"REST/JSON"| GroqAPI
    GroqAPI -->|"response"| LangGraph
    LangGraph -->|"titles"| TitleGen
    TitleGen -->|"display titles"| StreamlitUI
    StreamlitUI -->|"on selection"| PostGen
    PostGen -->|"calls"| LangGraph
    LangGraph -->|"REST/JSON"| GroqAPI
    GroqAPI -->|"response"| LangGraph
    LangGraph -->|"draft content"| PostGen
    PostGen -->|"to export"| Exporter
    Exporter -->|"download link"| StreamlitUI
    ConfigStore -->|"API key"| LangGraph
    Reqs -->|"deps"| StreamlitUI

    %% Click Events
    click StreamlitUI "https://github.com/rizwankaka/langgraph-blog-generator/blob/main/langgraphBlogPost.py"
    click InputHandler "https://github.com/rizwankaka/langgraph-blog-generator/blob/main/langgraphBlogPost.py"
    click TitleGen "https://github.com/rizwankaka/langgraph-blog-generator/blob/main/langgraphBlogPost.py"
    click PostGen "https://github.com/rizwankaka/langgraph-blog-generator/blob/main/langgraphBlogPost.py"
    click Exporter "https://github.com/rizwankaka/langgraph-blog-generator/blob/main/langgraphBlogPost.py"
    click ConfigStore "https://github.com/rizwankaka/langgraph-blog-generator/blob/main/.env"
    click Reqs "https://github.com/rizwankaka/langgraph-blog-generator/blob/main/requirements.txt"
    click Readme "https://github.com/rizwankaka/langgraph-blog-generator/blob/main/README.md"
    click License "https://github.com/rizwankaka/langgraph-blog-generator/tree/main/LICENSE"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef ui fill:#B3DFFC,stroke:#0064c8,color:#004085;
    classDef logic fill:#DFF5E1,stroke:#28A745,color:#155724;
    classDef external fill:#FFE5B4,stroke:#FF8C00,color:#663C00;
    classDef config fill:#F0F0F0,stroke:#6C757D,color:#343A40;
```
