# codebasics/project-genai-post-generator architecture

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

- Interactive diagram: https://gitdiagram.com/codebasics/project-genai-post-generator
- Repository: https://github.com/codebasics/project-genai-post-generator

## Overview

##### Main Components

a) Data Layer:
- Raw Data Storage (raw_posts.json)
- Processed Data Storage (processed_posts.json)
- As database symbols or storage components

b) Processing Pipeline:
- Preprocessing Module (preprocess.py)
- Post Generation Module (post_generator.py)
- Few-Shot Learning Component (few_shot.py)
- LLM Helper Module (llm_helper.py)

c) External Services:
- Groq LLM API
- Streamlit (for UI)

##### Input Processing Flow
**Raw Posts → Preprocessing Module → Processed Posts Storage**

##### Generation Flow
**User Input → Few-Shot Learning → LLM Helper → Groq API → Post Generator → Generated Post**

##### UI Layer
**Streamlit Interface ↔ Main Application Logic**

##### Important Elements to Highlight

a) Two-Stage Architecture:
- Stage 1: Post Collection & Analysis
- Stage 2: Post Generation

b) Key Integration Points:
- Groq API connection
- Data flow between modules
- User interaction points

##### Specific Implementation Details

- main.py and all other components (as it's the orchestrator)
- few_shot.py and processed_posts.json (for training data access)
- llm_helper.py and the Groq API

**User Interface**
**↓**
**Application Logic**
**↓**
**Processing Modules**
**↓**
**Data Storage/External Services**

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef storage fill:#3498db,stroke:#2980b9,color:white
    classDef processing fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef ui fill:#e67e22,stroke:#d35400,color:white
    classDef api fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Data Layer
    subgraph DataLayer
        RawData[(Raw Posts)]
        ProcessedData[(Processed Posts)]
    end
    
    %% Processing Pipeline
    subgraph ProcessingPipeline
        Preprocess[Preprocessing]
        FewShot[Few-Shot Learning]
        PostGen[Post Generator]
        LLMHelper[LLM Helper]
    end

    %% External Services
    subgraph ExternalServices
        GroqAPI["Groq LLM API"]
        UI["Streamlit UI"]
    end

    %% Connections
    RawData --> Preprocess
    Preprocess --> ProcessedData
    ProcessedData --> FewShot
    FewShot --> PostGen
    PostGen --> UI
    GroqAPI --> LLMHelper
    LLMHelper --> PostGen

    %% Component Classifications
    class RawData,ProcessedData storage
    class Preprocess,FewShot,PostGen,LLMHelper processing
    class GroqAPI external
    class UI ui

    %% Click Events
    click RawData "https://github.com/codebasics/project-genai-post-generator/blob/main/data/raw_posts.json"
    click ProcessedData "https://github.com/codebasics/project-genai-post-generator/blob/main/data/processed_posts.json"
    click Preprocess "https://github.com/codebasics/project-genai-post-generator/blob/main/preprocess.py"
    click PostGen "https://github.com/codebasics/project-genai-post-generator/blob/main/post_generator.py"
    click FewShot "https://github.com/codebasics/project-genai-post-generator/blob/main/few_shot.py"
    click LLMHelper "https://github.com/codebasics/project-genai-post-generator/blob/main/llm_helper.py"

    %% Legend
    subgraph Legend
        L1[(Storage)]:::storage
        L2[Processing]:::processing
        L3[External Service]:::external
        L4[User Interface]:::ui
    end
```
