# pratheek-achar/84teamwanderers architecture

> Architecture diagram of the GitHub repository pratheek-achar/84teamwanderers, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pratheek-achar/84teamwanderers
- Repository: https://github.com/pratheek-achar/84teamwanderers

## Overview

##### Project Type & Purpose
- The project is a full-stack application with a primary focus on backend email processing (using Flask in Python) and a web-based dashboard (HTML templates) for monitoring and managing emails.
- It incorporates AI-based processing via Google Gemini API for textual analysis and communicates with an email server via IMAP/SMTP.
- Data persistence is provided by MongoDB to store incoming email data and related analytics.

##### Key Components
a. Email Ingestion & Processing:
- Email Polling Component: Illustrate how the system periodically polls an inbox using IMAP to fetch unread emails.
- Email Analyzer: Highlight the processing unit that categorizes emails (Technical, Billing, Complaint, General Inquiry), measures sentiment, assigns priority scores, and identifies language.

b. Email Forwarding & Response Generation:
- Auto-Response System: Show the component responsible for generating and sending personalized responses via SMTP.
- Department Forwarding: Represent how the system forwards emails to the appropriate department (Technical, Billing, etc.) based on classification.

c. Data Storage:
- MongoDB Database: Emphasize MongoDB as the central repository for storing emails, user interactions, and analytics data.

d. Web Interface / Dashboard:
- Flask Backend: Include the main application file (app.py) that acts as the server, hosting API endpoints and rendering HTML templates.
- Frontend UI Components: Illustrate the dashboard, analytics, and email details pages (using HTML templates under the “templates” folder) that provide the point-and-click management of emails.
- API Endpoints: Mark endpoints such as /api/weekly-report, /api/response-stats, and /api/email-details/<email_id>—these link the backend processing and the dashboard interface.

##### Relationships & Data Flow
1. Emails are fetched from the external IMAP server.
2. They are processed through the AI-driven analysis component.
3. Processed emails are stored in MongoDB.
4. Based on analysis, emails are either auto-responded to or forwarded to department-specific email addresses via SMTP.
5. The Flask web server retrieves the data from MongoDB to render the dashboard and analytics pages.
- Dependencies such as the connection between the application and external services (e.g., IMAP/SMTP for email, Google Gemini API for AI analysis, MongoDB for persistence).

##### Architectural Patterns & Technologies
- That the system uses a service-oriented design where distinct responsibilities (email ingestion, AI processing, database interactions, and web serving) are segregated.
- Annotations for key technologies: Python (core language), Flask (web framework), MongoDB (database), Google Gemini AI (third-party API for analysis), and standard web technologies (HTML/CSS with Tailwind/Bootstrap for UI).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "External Services"
        ENS["Email Server (IMAP/SMTP)"]:::external
    end

    subgraph "Email Processing Layer"
        EP["Email Poller (IMAP Fetcher)"]:::service
        EA["Email Analyzer"]:::service
        AI["AI Module (Google Gemini API)"]:::service
        AR["Auto-Response System (SMTP Sender)"]:::service
        DF["Department Forwarding"]:::service
    end

    subgraph "Data Persistence Layer"
        DB["MongoDB"]:::database
    end

    subgraph "Web Interface Layer"
        FB["Flask Backend (app.py)"]:::backend
        DS["Dashboard (HTML)"]:::frontend
        AN["Analytics Page (HTML)"]:::frontend
        ED["Email Details Page (HTML)"]:::frontend
    end

    ENS -->|"fetchEmails"| EP
    EP -->|"sendToAnalyzer"| EA
    EA -->|"invoke"| AI
    AI -->|"analyze"| EA
    EA -->|"storeEmail"| DB
    EA -->|"autoResponse"| AR
    EA -->|"forwardEmail"| DF
    AR -->|"sendResponse"| ENS
    DF -->|"sendForward"| ENS
    DB -->|"queryData"| FB
    FB -->|"renderDashboard"| DS
    FB -->|"renderAnalytics"| AN
    FB -->|"renderEmailDetails"| ED

    click FB "https://github.com/pratheek-achar/84teamwanderers/blob/main/app.py"
    click DS "https://github.com/pratheek-achar/84teamwanderers/blob/main/templates/dashboard.html"
    click AN "https://github.com/pratheek-achar/84teamwanderers/blob/main/templates/analytics.html"
    click ED "https://github.com/pratheek-achar/84teamwanderers/blob/main/templates/email_details.html"

    classDef service fill:#FFF59D,stroke:#FBC02D,stroke-width:2px;
    classDef external fill:#FFCDD2,stroke:#E53935,stroke-width:2px;
    classDef database fill:#C8E6C9,stroke:#43A047,stroke-width:2px;
    classDef backend fill:#D1C4E9,stroke:#7E57C2,stroke-width:2px;
    classDef frontend fill:#BBDEFB,stroke:#1E88E5,stroke-width:2px;
```
