# rohitdayal-jktech/blog-post-generator architecture

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

- Interactive diagram: https://gitdiagram.com/rohitdayal-jktech/blog-post-generator
- Repository: https://github.com/rohitdayal-jktech/blog-post-generator

## Overview

##### Project Type and Purpose
- This is a full-stack web application (“AI Blog Post Generator”) with a React/Next.js front end and a Python/FastAPI back end.
- Purpose: Let users enter blog parameters (topic, tone, length, audience, keywords) in a responsive UI, then generate a full blog post via a local LLM (Ollama) or remote APIs (OpenAI, Claude, Gemini).

##### File Structure Analysis
- Top-level:
- backend/ – Python FastAPI service with main.py and chatbot adapters (gemini_chatbot.py, ollama_chatbot.py), config.py, and conversation_history.json.
- src/app/ – Next.js “App Router” pages and components (BlogForm, BlogOutput, Navbar, Landing, etc.).
- src/app/contexts – ThemeContext for dark-mode toggle.
- src/app/utils/api.ts – front-end HTTP client to talk to the back end.
- public/ – static assets and screenshots.
- Configuration/build: package.json, next.config.ts, tsconfig.json, tailwind.config.js, backend/requirements.txt.

##### Architectural Patterns and Key Components
- Front-end (React/Next.js + Tailwind + ThemeContext)
- UI Components: Form (left pane), Output (right pane), Navbar, Footer, Landing.
- State & Context: Theme management, form state.
- API Client: src/app/utils/api.ts calls POST /generate on backend.
- API Layer (FastAPI)
- Endpoint POST /generate (main.py)
- Chatbot Adapters:
– Ollama adapter → local LLM server llama3.2:1b
– Gemini or other cloud adapters
- Persistence: conversation_history.json
- External/Infrastructure
- Local LLM Server (Ollama)
- Remote LLM APIs (OpenAI, Claude, Gemini)
- (Optional) Hosting platform for front end and back end

##### Relationships & Data Flow
1. User interacts with Next.js UI (blog parameters form)
2. Front-end calls FastAPI POST /generate via api.ts
3. FastAPI service selects adapter (Ollama or cloud)
4. Adapter sends prompt to local LLM server or remote API
5. Response flows back to FastAPI → appended to conversation_history.json → returned as structured JSON
6. Front-end receives JSON → BlogOutput component renders intro, body, conclusion

## Diagram (Mermaid)

```mermaid
flowchart LR
    subgraph "Frontend"
        direction TB
        NB["Navbar"]:::frontend
        LD["Landing"]:::frontend
        BF["BlogForm"]:::frontend
        BO["BlogOutput"]:::frontend
        FT["Footer"]:::frontend
        TC["ThemeContext"]:::frontend
        API["API Client (api.ts)"]:::frontend
    end

    subgraph "Backend"
        direction TB
        CONFIG["Configuration Module"]:::backend
        FASTAPI["FastAPI /generate Endpoint"]:::backend
        OLLAMA_ADP["Ollama Adapter"]:::backend
        GEMINI_ADP["Gemini Adapter"]:::backend
        HISTORY["Conversation History (JSON)"]:::backend
    end

    subgraph "External Services"
        direction TB
        OLLAMA_SRV["Local LLM Server (Ollama)"]:::external
        REMOTE_APIS["Remote LLM APIs\n(OpenAI, Claude, Gemini)"]:::external
    end

    NB -->|renders| LD
    LD --> BF
    BF -->|uses form data| API
    API -->|"HTTP POST /generate"| FASTAPI
    FASTAPI -->|"JSON response"| API
    API -->|passes response| BO
    BO --> FT
    TC --> NB
    TC --> LD
    TC --> BF
    TC --> BO

    CONFIG --> FASTAPI
    FASTAPI -->|selects adapter| OLLAMA_ADP
    FASTAPI -->|selects adapter| GEMINI_ADP
    FASTAPI -->|append response| HISTORY

    OLLAMA_ADP -->|prompt| OLLAMA_SRV
    GEMINI_ADP -->|prompt| REMOTE_APIS

    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px

    click NB "https://github.com/rohitdayal-jktech/blog-post-generator/blob/main/src/app/components/Navbar.tsx"
    click LD "https://github.com/rohitdayal-jktech/blog-post-generator/blob/main/src/app/components/Landing.tsx"
    click BF "https://github.com/rohitdayal-jktech/blog-post-generator/blob/main/src/app/components/BlogForm.tsx"
    click BO "https://github.com/rohitdayal-jktech/blog-post-generator/blob/main/src/app/components/BlogOutput.tsx"
    click FT "https://github.com/rohitdayal-jktech/blog-post-generator/blob/main/src/app/components/Footer.tsx"
    click API "https://github.com/rohitdayal-jktech/blog-post-generator/blob/main/src/app/utils/api.ts"
    click TC "https://github.com/rohitdayal-jktech/blog-post-generator/blob/main/src/app/contexts/ThemeContext.tsx"
    click FASTAPI "https://github.com/rohitdayal-jktech/blog-post-generator/blob/main/backend/app/main.py"
    click OLLAMA_ADP "https://github.com/rohitdayal-jktech/blog-post-generator/blob/main/backend/app/ollama_chatbot.py"
    click GEMINI_ADP "https://github.com/rohitdayal-jktech/blog-post-generator/blob/main/backend/app/gemini_chatbot.py"
    click CONFIG "https://github.com/rohitdayal-jktech/blog-post-generator/blob/main/backend/config.py"
    click HISTORY "https://github.com/rohitdayal-jktech/blog-post-generator/blob/main/backend/conversation_history.json"
```
