# shalinvachheta017/gen-ai-llama-3.1-based-cold-email-generator- architecture

> Architecture diagram of the GitHub repository shalinvachheta017/gen-ai-llama-3.1-based-cold-email-generator-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shalinvachheta017/gen-ai-llama-3.1-based-cold-email-generator-
- Repository: https://github.com/shalinvachheta017/gen-ai-llama-3.1-based-cold-email-generator-

## Overview

##### Project Type and Purpose
- This is a full-stack Python application (CLI/Notebook + Streamlit front end) whose sole purpose is to generate personalized cold emails using Meta’s LLaMA 3.1 via LangChain.
- It exposes a Streamlit UI, orchestrates calls to an LLM, and uses a local Chroma vector store for any retrieval-augmented prompts or portfolio data.

##### File Structure
- Top level:
- README.md, LICENSE, requirements.txt – project metadata and dependencies
- mail generator.ipynb – proof-of-concept notebook
- my_portfolio.csv – sample data for portfolio-based personalization
- app/ directory (the “service” layer):
- main.py (or app.py) – Streamlit entry point
- chains.py – LangChain orchestration (prompt templates + chain definitions)
- utils.py – helper functions (loading env vars, CSV, formatting)
- portfolio.py – logic to read and map your portfolio CSV to prompts
- resource/my_portfolio.csv – embedded sample data
- .env – environment variables (LLM API key, model settings)
- vectorstore/ directory (the “data” layer):
- chroma.sqlite3 – persistent vectorDB index
- [uuid]/… – raw binary shards for Chroma’s embedding store

##### Extract Key Architecture Points from the README
- Tech stack: Python + Transformers + LangChain + Streamlit + Chroma vector store.
- Flow: User inputs → dynamic prompt engineering → LLM inference → output email.
- Extensible pipeline ready for other message types and front-end.

a. Main Components
1. User Interface (Streamlit)
2. Application Layer (Python service modules)
– chains.py (Chain Manager)
– utils.py (Helpers)
– portfolio.py (Data Loader)
3. Data Layer
– Chroma Vector Store (vectorstore/)
– Local CSV resource (my_portfolio.csv)
4. LLM Service
– LLaMA 3.1 via Transformers/Hosted API
b. Relationships & Interactions
– UI → calls main.py event handlers → invokes Chain Manager
– Chain Manager
- fetches portfolio data via Data Loader
- builds prompts using Templates + Context
– Chain Manager → sends prompt to LLaMA API (through Transformers client)
– Chain Manager (optionally) queries Chroma vector store for embeddings or retrieval
– LLaMA response → post-processed by utils → returned to UI
c. Architectural Patterns & Principles
– Modular chain orchestration (LangChain) decouples prompt design from execution
– Separation of concerns: UI vs business logic vs data storage
d. Key Technologies & Libraries
– Streamlit (UI)
– LangChain (Chaining + prompt templates)
– Transformers (LLM client)
– Chroma (vector DB)
– Python modules: chains.py, utils.py, portfolio.py

##### Detailed Elements to Capture
- Streamlit “Run App” invocation → Main handler in main.py
- Chain invocation path: main.py → chains.py → (portfolio.py, utils.py)
- Data store access: Chroma SDK client reading from vectorstore/chroma.sqlite3
- LLM call: Transformers client → LLaMA 3.1 endpoint
- Post-processing and rendering back to Streamlit UI

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["Streamlit UI\n(main.py)"]:::ui
    end

    %% Application Layer
    subgraph "Application Layer"
        Chains["Chain Manager\n(chains.py)"]:::service
        Portfolio["Data Loader\n(portfolio.py)"]:::service
        Utils["Helper Functions\n(utils.py)"]:::service
        Env["Environment Variables\n(.env)"]:::service
        ResourceCSV["Embedded CSV\n(my_portfolio.csv)"]:::data
    end

    %% Data & Model Layer
    subgraph "Data & Model Layer"
        ChromaDB["Chroma Vector Store\n(chroma.sqlite3)"]:::db
        ChromaShards["Chroma Shards\n(UUID Binary)"]:::db
        CSV["Local CSV\n(my_portfolio.csv)"]:::db
        LLM["LLaMA 3.1 API"]:::external
    end

    %% Artifacts
    subgraph "Artifacts"
        Notebook["Proof-of-Concept Notebook\n(mail generator.ipynb)"]:::artifact
        TopCSV["Sample CSV\n(my_portfolio.csv)"]:::artifact
        Metadata["Project Metadata\n(README.md, requirements.txt, LICENSE)"]:::artifact
    end

    %% Connections
    UI -->|"onUserInput"| Chains
    Chains -->|"loadPortfolioData"| Portfolio
    Portfolio --> ResourceCSV
    Chains -->|"useHelpers"| Utils
    Chains -->|"loadEnv"| Env
    Chains -->|"queryVectorStore"| ChromaDB
    ChromaDB --> ChromaShards
    Chains -->|"callLLM"| LLM
    LLM -->|"response"| Chains
    Chains -->|"postProcess"| Utils
    Chains -->|"returnEmail"| UI

    %% Click Events
    click UI "https://github.com/shalinvachheta017/gen-ai-llama-3.1-based-cold-email-generator-/blob/main/app/main.py"
    click Chains "https://github.com/shalinvachheta017/gen-ai-llama-3.1-based-cold-email-generator-/blob/main/app/chains.py"
    click Portfolio "https://github.com/shalinvachheta017/gen-ai-llama-3.1-based-cold-email-generator-/blob/main/app/portfolio.py"
    click Utils "https://github.com/shalinvachheta017/gen-ai-llama-3.1-based-cold-email-generator-/blob/main/app/utils.py"
    click Env "https://github.com/shalinvachheta017/gen-ai-llama-3.1-based-cold-email-generator-/blob/main/app/.env"
    click ResourceCSV "https://github.com/shalinvachheta017/gen-ai-llama-3.1-based-cold-email-generator-/blob/main/app/resource/my_portfolio.csv"
    click ChromaDB "https://github.com/shalinvachheta017/gen-ai-llama-3.1-based-cold-email-generator-/blob/main/vectorstore/chroma.sqlite3"
    click ChromaShards "https://github.com/shalinvachheta017/gen-ai-llama-3.1-based-cold-email-generator-/tree/main/vectorstore/18cfcbcc-62b8-44df-bff4-5dd12e99263f"
    click Notebook "https://github.com/shalinvachheta017/gen-ai-llama-3.1-based-cold-email-generator-/blob/main/mail generator.ipynb"
    click TopCSV "https://github.com/shalinvachheta017/gen-ai-llama-3.1-based-cold-email-generator-/blob/main/my_portfolio.csv"
    click Metadata "https://github.com/shalinvachheta017/gen-ai-llama-3.1-based-cold-email-generator-/blob/main/README.md"

    %% Styles
    classDef ui fill:#cfe2f3,stroke:#036,stroke-width:1px;
    classDef service fill:#d9ead3,stroke:#090,stroke-width:1px;
    classDef data fill:#f9cb9c,stroke:#e69138,stroke-width:1px;
    classDef db fill:#f4cccc,stroke:#cc0000,stroke-width:1px;
    classDef external fill:#d0e0e3,stroke:#0a4f66,stroke-width:1px,stroke-dasharray:5 5;
    classDef artifact fill:#fff2cc,stroke:#bf9000,stroke-width:1px,stroke-dasharray:2 2;
```
