# ssdeb-rr/linkedin-post-generator architecture

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

- Interactive diagram: https://gitdiagram.com/ssdeb-rr/linkedin-post-generator
- Repository: https://github.com/ssdeb-rr/linkedin-post-generator

## Overview

##### Project type and purpose
- This is a full-stack AI tool (Python-based) with a lightweight Streamlit UI for generating LinkedIn posts.
- Purpose: Ingest raw post data, extract metadata (topic, tone, length), and generate new influencer-style posts via a fine-tuned LLM (LLama 3.3 on Groq).

##### File structure
Top-level elements:
- data/
└─ raw_posts.json, processed_posts.json (input/output datasets)
- few_shot.py (builds few-shot prompts)
- llm_helper.py (abstracts calls to Groq Console / Langchain)
- preprocess.py (parses raw_posts.json → metadata)
- post_generator.py (assembles prompt + calls LLM to generate new post)
- main.py (Streamlit front-end glue)
- requirements.txt, .gitignore (env & dependencies)

##### README for additional insights
- Two main stages at runtime:
Stage 1: Metadata extraction (preprocess.py)
Stage 2: AI post generation (post_generator.py + few_shot.py + llm_helper.py)
- UI: Streamlit (main.py)
- External dependency: Groq Console API, Langchain orchestration, LLama 3.3 model.

##### Detailed coverage
- Don’t omit the Chain-of-Thought prompt logic in few_shot.py—show it as a sub-block of the prompt builder
- Extension points: switching to a database, adding a caching layer, integrating new LLMs

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    StreamlitUI["Streamlit UI"]:::internal
    %% Metadata Extraction
    Preprocess["Preprocess Module"]:::internal
    RawData[(Raw Posts JSON)]:::storage
    ProcessedData[(Processed Posts JSON)]:::storage
    %% Prompt & Generation
    FewShot["Few‐Shot Prompt Builder"]:::internal
    LLMHelper["LLM Invocation Layer"]:::internal
    PostGen["Post Generation Service"]:::internal
    %% External Service
    Groq["Groq Console API"]:::external

    %% Data Flow
    StreamlitUI -->|"trigger metadata extraction"| Preprocess
    Preprocess -->|"reads raw_posts.json"| RawData
    RawData --> Preprocess
    Preprocess -->|"writes processed_posts.json"| ProcessedData

    StreamlitUI -->|"request post generation"| PostGen
    PostGen -->|"fetch processed data"| ProcessedData
    PostGen -->|"build prompt"| FewShot
    FewShot -->|"prompt"| LLMHelper
    LLMHelper -->|"POST prompt"| Groq
    Groq -->|"generated text"| LLMHelper
    LLMHelper -->|"returns text"| PostGen
    PostGen -->|"returns post"| StreamlitUI

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

    %% Styles
    classDef internal fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef storage fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px;
```
