# arnnv/email-tracking-system-langgraph architecture

> Architecture diagram of the GitHub repository arnnv/email-tracking-system-langgraph, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arnnv/email-tracking-system-langgraph
- Repository: https://github.com/arnnv/email-tracking-system-langgraph

## Overview

##### Project Type & Purpose
- The project is a full-fledged email processing and tracking system.
- It automatically downloads emails, categorizes them (e.g., spam, job, urgent, general), uses agents to perform summarization and classification, extracts job details, sends notifications, and provides a Streamlit dashboard for interactive management.
- The README clarifies that it employs LangGraph workflows and has an agent-based modular design.

##### File Structure
- Key directories:
- agents/ – Contains specialized agents (e.g., classification_agent and summarization_agent) that encapsulate distinct responsibilities.
- core/ – Provides the essential services like email downloading (email_downloader.py), fetching (email_fetcher.py), database initialization, and utilities.
- processing/ – Contains modules for handling different categories of emails (general, job, spam, urgent) and the module to fetch emails.
- models/ – Data models defining email structures and state.
- workflows/ – Defines processing workflows with LangGraph, with modules like graph_builder.py.
- jobs/ – Manages job application details with applications, tracking, and viewing capabilities.
- prompts/ – Houses language model prompt templates used for classification, summarization, and job detail extraction.
- Top-level scripts:
- app.py – Launches the Streamlit web dashboard.
- main.py – CLI entry point.
- apply_for_job.py and view_applications.py – Additional job application handling scripts.
- Other important files include configuration (config.py), dependency list (requirements.txt), and deployment/configuration files in the .streamlit folder.

##### Elements
- External integrations (IMAP server, Ollama for LLMs).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Source
    EServer("IMAP Email Server"):::external

    %% Email Ingestion Layer
    subgraph "Email Ingestion"
        direction TB
        Fetcher("Email Fetcher"):::ingestion
        Downloader("Email Downloader"):::ingestion
    end

    %% Email Processing Layer
    subgraph "Email Processing"
        direction TB
        ProcessAll("Process All"):::processing
        ProcessGeneral("Process General"):::processing
        ProcessJobs("Process Job Emails"):::processing
        ProcessSpam("Process Spam Emails"):::processing
        ProcessUrgent("Process Urgent Emails"):::processing
    end

    %% Agent Layer
    subgraph "Agents"
        direction TB
        ClassAgent("Classification Agent"):::agent
        SumAgent("Summarization Agent"):::agent
    end

    %% Workflow Layer
    subgraph "Workflow Orchestration"
        direction TB
        LangGraph("LangGraph Workflow"):::workflow
    end

    %% Data Storage Layer
    subgraph "Data Storage"
        direction TB
        DBManager("DB Manager (SQLite)"):::database
    end

    %% Job Application Management Layer
    subgraph "Job Application Management"
        direction TB
        JobApps("Job Applications"):::job
        JobTracker("Job Tracker"):::job
        JobViewer("Job Viewer"):::job
        JobParser("Job Parser"):::job
        JobProcessor("Job Processor"):::job
    end

    %% Prompt Templates
    subgraph "Prompt Templates"
        direction TB
        ClassPrompt("Classification Prompt"):::prompt
        SumPrompt("Summarization Prompt"):::prompt
        JobPrompt("Job Extraction Prompt"):::prompt
    end

    %% User Interface Layer
    subgraph "User Interface"
        direction TB
        Dashboard("Streamlit Dashboard"):::ui
        CLI("CLI Interface"):::ui
    end

    %% Data Flow
    EServer -->|"sends"| Fetcher
    EServer -->|"sends"| Downloader

    Fetcher -->|"fetches"| ProcessAll
    Downloader -->|"downloads"| ProcessAll

    ProcessAll -->|"routes"| ProcessGeneral
    ProcessAll -->|"routes"| ProcessJobs
    ProcessAll -->|"routes"| ProcessSpam
    ProcessAll -->|"routes"| ProcessUrgent

    ProcessGeneral -->|"processes"| ClassAgent
    ProcessJobs -->|"processes"| ClassAgent
    ProcessSpam -->|"processes"| ClassAgent
    ProcessUrgent -->|"processes"| ClassAgent

    ProcessGeneral -->|"processes"| SumAgent
    ProcessJobs -->|"processes"| SumAgent
    ProcessSpam -->|"processes"| SumAgent
    ProcessUrgent -->|"processes"| SumAgent

    ClassAgent -->|"integrates"| LangGraph
    SumAgent -->|"integrates"| LangGraph

    LangGraph -->|"stores"| DBManager

    ProcessJobs -->|"feeds"| JobApps
    ProcessJobs -->|"feeds"| JobTracker
    ProcessJobs -->|"feeds"| JobViewer
    JobApps -->|"uses"| JobParser
    JobApps -->|"uses"| JobProcessor

    DBManager -->|"supplies"| Dashboard
    DBManager -->|"supplies"| CLI

    ClassAgent ---|"uses"| ClassPrompt
    SumAgent ---|"uses"| SumPrompt
    ProcessJobs ---|"uses"| JobPrompt

    %% Click Events
    click Fetcher "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/core/email_fetcher.py"
    click Downloader "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/core/email_downloader.py"
    click DBManager "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/core/initialize_db.py"
    click ClassAgent "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/agents/classification_agent.py"
    click SumAgent "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/agents/summarization_agent.py"
    click ProcessAll "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/processing/process_all.py"
    click ProcessGeneral "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/processing/process_general.py"
    click ProcessJobs "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/processing/process_jobs.py"
    click ProcessSpam "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/processing/process_spam.py"
    click ProcessUrgent "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/processing/process_urgent.py"
    click JobApps "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/jobs/applications.py"
    click JobTracker "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/jobs/tracker.py"
    click JobViewer "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/jobs/viewer.py"
    click JobParser "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/jobs/parser.py"
    click JobProcessor "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/jobs/processor.py"
    click LangGraph "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/workflows/graph_builder.py"
    click Dashboard "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/app.py"
    click CLI "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/main.py"
    click ClassPrompt "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/prompts/classification_prompt.py"
    click SumPrompt "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/prompts/summarization_prompt.py"
    click JobPrompt "https://github.com/arnnv/email-tracking-system-langgraph/blob/main/prompts/job_extraction.py"

    %% Styles
    classDef external fill:#fde2e2,stroke:#d45050,stroke-width:2px;
    classDef ingestion fill:#e0f7fa,stroke:#00796b,stroke-width:2px;
    classDef processing fill:#e8f5e9,stroke:#388e3c,stroke-width:2px;
    classDef agent fill:#f3e5f5,stroke:#8e24aa,stroke-width:2px;
    classDef workflow fill:#fff3e0,stroke:#f57c00,stroke-width:2px;
    classDef database fill:#fffde7,stroke:#f9a825,stroke-width:2px;
    classDef job fill:#fbe9e7,stroke:#d84315,stroke-width:2px;
    classDef prompt fill:#ede7f6,stroke:#5e35b1,stroke-width:2px;
    classDef ui fill:#e3f2fd,stroke:#1565c0,stroke-width:2px;
```
