# mandal-suman/envelopex architecture

> Architecture diagram of the GitHub repository mandal-suman/envelopex, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mandal-suman/envelopex
- Repository: https://github.com/mandal-suman/envelopex

## Overview

##### Project type and purpose
- EnvelopeX is a full-stack, single-page Flask web application for email forensics.
- It ingests EML/TXT email files, parses and analyzes them (authentication, URLs, attachments, etc.), then renders results in an 8-tab dashboard.

##### File structure
- Top-level:
- app.py – Flask entry point
- requirements.txt – Python dependencies
- core/ – business-logic modules (parser.py, analyzer.py)
- templates/ – Jinja2 HTML templates (index.html, error pages)
- static/ – CSS and JavaScript assets
- No database directory: it uses in-memory data structures and browser localStorage for history.
- Dependencies in requirements.txt include Flask, dkimpy, dnspython, BeautifulSoup4, etc.

##### Extract additional architectural insights from the README
- Backend: Flask 3.0.0, Flask-CORS
- Core analytics: SPF, DKIM, DMARC checks, URL/IP threat detection, MIME structure parsing
- Frontend: Vanilla JS, Chart.js, Font Awesome, HTML sanitization, drag-and-drop upload
- External services: DNS lookups (SPF, DKIM, DMARC), optional IP reputation or WHOIS queries

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client-side"
        direction TB
        BrowserUI["Browser UI (Drag & Drop, Dashboard)"]:::client
        MainJS["main.js"]:::client
        Renderer["results-renderer-new.js"]:::client
        LocalStorage["LocalStorage"]:::storage
    end

    subgraph "Server-side"
        direction TB
        FlaskApp["Flask App"]:::server
        subgraph "Core Modules"
            direction TB
            CoreInit["__init__.py"]:::server
            Parser["Parser Module"]:::server
            Analyzer["Analyzer Module"]:::server
            InMem["In-Memory Data Store"]:::storage
        end
        subgraph "Templates"
            direction TB
            Index["index.html"]:::server
            Base["base.html"]:::server
            NotFound["404.html"]:::server
            ServerError["500.html"]:::server
        end
    end

    subgraph "External Services"
        direction TB
        DNS["DNS Resolver"]:::external
        ThreatAPI["Threat API"]:::external
    end

    BrowserUI -->|"HTTP POST /analyze"| FlaskApp
    FlaskApp -->|"parser.parse_email()"| Parser
    Parser -->|"analyzer.run_all_checks()"| Analyzer
    Analyzer -->|"DNS Queries (SPF/DKIM/DMARC)"| DNS
    Analyzer -->|"URL/IP risk query"| ThreatAPI
    Analyzer -->|"return Email object"| FlaskApp
    FlaskApp -->|"JSON result"| BrowserUI
    BrowserUI -->|"save summary"| LocalStorage

    click FlaskApp "https://github.com/mandal-suman/envelopex/blob/main/app.py"
    click Parser "https://github.com/mandal-suman/envelopex/blob/main/core/parser.py"
    click Analyzer "https://github.com/mandal-suman/envelopex/blob/main/core/analyzer.py"
    click CoreInit "https://github.com/mandal-suman/envelopex/blob/main/core/__init__.py"
    click Index "https://github.com/mandal-suman/envelopex/blob/main/templates/index.html"
    click Base "https://github.com/mandal-suman/envelopex/blob/main/templates/base.html"
    click NotFound "https://github.com/mandal-suman/envelopex/blob/main/templates/404.html"
    click ServerError "https://github.com/mandal-suman/envelopex/blob/main/templates/500.html"
    click MainJS "https://github.com/mandal-suman/envelopex/blob/main/static/js/main.js"
    click Renderer "https://github.com/mandal-suman/envelopex/blob/main/static/js/results-renderer-new.js"
    click LocalStorage "https://github.com/mandal-suman/envelopex/blob/main/static/js/results-renderer-new.js"
    click CSS "https://github.com/mandal-suman/envelopex/blob/main/static/css/style.css"
    click ImgDir "https://github.com/mandal-suman/envelopex/tree/main/static/img"
    click Req "https://github.com/mandal-suman/envelopex/blob/main/requirements.txt"
    click Readme "https://github.com/mandal-suman/envelopex/blob/main/README.md"
    click Gitignore "https://github.com/mandal-suman/envelopex/blob/main/.gitignore"
    click License "https://github.com/mandal-suman/envelopex/tree/main/LICENSE"

    classDef client fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef server fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef external fill:#FFD580,stroke:#000,stroke-width:1px;
    classDef storage fill:#FFFACD,stroke:#000,stroke-width:1px;
```
