# thakare-om03/cold-email-generator architecture

> Architecture diagram of the GitHub repository thakare-om03/cold-email-generator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thakare-om03/cold-email-generator
- Repository: https://github.com/thakare-om03/cold-email-generator

## Overview

##### Project Type & Purpose
- Type: A full‑stack (but Python‑centric) web application with a UI, business logic, local data store, and external AI service.
- Purpose: Scrape job listings, extract requirements via LLM, match to portfolio items, generate personalized cold‑email drafts, and optionally schedule automated runs.

##### File Structure
- Top‑level:
– .devcontainer: development container config
– app/: Python source (UI + business logic)
– my_portfolio.csv: user‑provided portfolio data
– vectorstore/: local Chroma vector DB files
– output/: generated images for documentation
– requirements.txt: dependencies
- Within app/:
– main.py: Streamlit app entrypoint (UI pages, navigation)
– chains.py: LangChain workflows (job analysis, email gen)
– job_automation.py & run_automation.py: scheduler components
– portfolio.py: CSV upload & vectorstore indexing
– utils.py: shared helpers

##### Extract Key Architecture Insights from README
- UI: Streamlit front‑end
- AI Service: GROQ API via LangChain
- Data Store: Chroma (vectorstore directory + SQLite)
- Scheduler: Cron‐like automated job runs
- Email Integration: Redirect to Gmail/Outlook

##### Main Components & Interactions
a. Components:
1. Client Browser
2. Streamlit Server (app/main.py)
3. Portfolio Manager (app/portfolio.py + my_portfolio.csv)
4. Vectorstore (ChromaDB in vectorstore/)
5. Job Scraper & Analyzer (app/chains.py, job_automation.py)
6. AI/Text Generation (GROQ API via LangChain)
7. Scheduler (app/run_automation.py)
8. Email Client (external)
b. Interactions / Data Flow:
- User → Streamlit UI (configure API key, upload portfolio)
- UI calls Portfolio Manager → indexes CSV → stores embeddings in Chroma
- User submits job URLs/keywords → Chains invoke scraper → extract text
- Chains send job text + portfolio embeddings to LangChain → invokes GROQ → returns requirements & email drafts
- Results displayed in UI → “Send Email” button → triggers mailto link or Gmail/Outlook redirect
- Scheduler triggers job scraping/email gen at configured intervals (using job_automation & run_automation)
c. Architectural Patterns & Design Principles:
- Modular Code: separation of UI (main.py), business logic (chains.py), data layer (portfolio.py)
- Layered Architecture: UI Layer → Service Layer (LangChain workflows) → Data Layer (Chroma vectorstore) → External Services (GROQ API, Email Client)
- Dependency Injection: API key via .env
- Event‑Driven / Cron Pattern for automation
d. Key Technologies/Frameworks:
- Python + Streamlit (UI)
- LangChain + GROQ API (LLM orchestration)
- ChromaDB (vector embeddings store)
- CSV for portfolio data storage
- Scheduled tasks (python scripts invoked by OS scheduler or Streamlit background threads)
- Optional email client protocols (mailto, Outlook APIs)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    CB["Client Browser"]:::frontend

    %% UI Layer
    subgraph "UI Layer"
        SB["Streamlit App"]:::frontend
    end

    %% Service Layer
    subgraph "Application / Service Layer"
        PM["Portfolio Manager"]:::service
        JS["Job Scraper & Analyzer"]:::service
        AI["AI/Text Generation"]:::service
        SC["Scheduler ⏰"]:::service
        UT["Shared Utilities"]:::service
    end

    %% Data Layer
    subgraph "Data Layer"
        VS["Chroma Vectorstore"]:::data
        CSV["Portfolio CSV"]:::data
    end

    %% External Services
    subgraph "External Services"
        API["GROQ API"]:::ext
        EC["Email Client"]:::ext
    end

    %% Connections
    CB -->|"UI actions / config"| SB
    SB -->|"upload CSV / index"| PM
    PM -->|"store embeddings"| VS
    PM -->|"reads portfolio"| CSV
    SB -->|"submit job URLs"| JS
    JS -->|"prepare prompt"| AI
    AI -->|"LLM call"| API
    API -->|"response"| AI
    AI -->|"return drafts & requirements"| JS
    JS -->|"return results"| SB
    SB -->|"mailto link / redirect"| EC
    SC -->|"scheduled run"| JS

    %% Utilities usage
    UT --> PM
    UT --> JS
    UT --> AI
    UT --> SC

    %% Click Events
    click SB "https://github.com/thakare-om03/cold-email-generator/blob/main/app/main.py"
    click PM "https://github.com/thakare-om03/cold-email-generator/blob/main/app/portfolio.py"
    click CSV "https://github.com/thakare-om03/cold-email-generator/blob/main/my_portfolio.csv"
    click VS "https://github.com/thakare-om03/cold-email-generator/tree/main/vectorstore/"
    click JS "https://github.com/thakare-om03/cold-email-generator/blob/main/app/chains.py"
    click JS "https://github.com/thakare-om03/cold-email-generator/blob/main/app/job_automation.py"
    click AI "https://github.com/thakare-om03/cold-email-generator/blob/main/app/chains.py"
    click SC "https://github.com/thakare-om03/cold-email-generator/blob/main/app/run_automation.py"
    click UT "https://github.com/thakare-om03/cold-email-generator/blob/main/app/utils.py"

    %% Styles
    classDef frontend fill:#D0E6FA,stroke:#0366D6,color:#0366D6;
    classDef service fill:#E6F4EA,stroke:#22863A,color:#22863A;
    classDef data fill:#FFF5B1,stroke:#D29922,color:#D29922;
    classDef ext fill:#F3E8FF,stroke:#6F42C1,color:#6F42C1;
```
