# shreyao3/task_manager architecture

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

- Interactive diagram: https://gitdiagram.com/shreyao3/task_manager
- Repository: https://github.com/shreyao3/task_manager

## Overview

##### Project Type and Purpose
- TaskNexus is a full-stack web application for advanced task management.
- Built on Python/Flask following an MVC pattern.
- Key features: task CRUD, ML-based prioritization, email notifications, analytics, responsive UI, authentication.

##### File Structure
- Top-level:
- app.py / run.py: Flask app initialization and route handlers (Controllers).
- models/: ORM models for Users, Tasks, plus ML model wrapper.
- ml/: Offline ML artifacts (pickled encoders, model, scaler) and training script.
- static/: Frontend assets (CSS, JS) served by Flask static route.
- templates/: Jinja2 views (HTML) rendered by controllers.
- Configuration: requirements.txt, database connection in app.py, email creds via environment/config.

##### README Insights
- MVC layers explicitly described.
- SQL Server DB with tables for users, tasks, categories, types, reminders.
- ML component for auto-prioritization.
- Email/SMTP for notifications.
- Client-side and server-side validation, OTP auth, session management.

a. Main Components
- Client Browser (UI)
- Flask Web Server (app.py, run.py) – Controllers
- Templates + Static Assets – Views
- Data Layer – SQL Server Database
- ML Service – ml_model component loaded at runtime
- Email Service – external SMTP (Gmail)
- Offline Training Pipeline – train_model.py (optional to show)
b. Relationships and Interactions
1. User interacts via Browser → HTTP(s) requests → Flask Web Server
2. Flask routes call Controllers → query/update Database via models/task_model & user_model
3. For new/edit task, Controller invokes ML Model component to predict priority
4. Controllers render HTML via Templates + inject data; static assets served separately
5. For notifications: Controllers send emails via SMTP service
6. Session/auth flows: Controllers validate inputs, query user_model, manage sessions
7. Analytics: Controllers aggregate data from DB, pass to statistics template
c. Architectural Patterns & Principles
- MVC separation: clear division of Models / Views / Controllers
- Single Flask app monolith but layered for maintainability
- ML component affixed to business logic layer (wrapper model)
- External dependencies segregated (DB, SMTP)
d. Key Technologies & Libraries
- Flask (Werkzeug, Jinja2)
- SQLAlchemy or raw driver for SQL Server
- Pandas / scikit-learn for ML
- SMTP library for email
- HTML5, CSS3, JavaScript for front end

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Client["Client Browser"]:::ui
        subgraph "Static Assets"
            direction TB
            StyleCSS["style.css"]:::ui
            ScriptJS["script.js"]:::ui
            ThemeJS["theme.js"]:::ui
        end
        subgraph "Templates"
            direction TB
            Landing["landing.html"]:::ui
            SignIn["signin.html"]:::ui
            Index["index.html"]:::ui
            AddTask["add_task.html"]:::ui
            EditTask["edit_task.html"]:::ui
            ViewTask["view_task.html"]:::ui
            TaskList["task_list_partial.html"]:::ui
            Statistics["statistics.html"]:::ui
        end
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        AppPy["app.py"]:::app
        RunPy["run.py"]:::app
        MLWrapper["ML Model Wrapper"]:::app
        UserModel["user_model.py"]:::app
        TaskModel["task_model.py"]:::app
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Database[(SQL Server Database)]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        SMTP["SMTP Service (Gmail)"]:::external
    end

    %% Offline ML Component
    subgraph "Offline ML Pipeline"
        direction TB
        TrainScript["train_model.py"]:::offline
        Dataset["task-management-dataset.csv"]:::offline
        EncCat["label_enc_category.pkl"]:::offline
        EncType["label_enc_type.pkl"]:::offline
        ModelFile["random_forest_task_priority.pkl"]:::offline
        Scaler["scaler.pkl"]:::offline
    end

    %% Interactions
    Client -->|"HTTP Requests"| AppPy
    Client -->|"Loads"| StyleCSS
    Client -->|"Loads"| ScriptJS
    Client -->|"Loads"| ThemeJS
    AppPy -->|"Renders"| Landing
    AppPy -->|"Renders"| SignIn
    AppPy -->|"Renders"| Index
    AppPy -->|"Renders"| AddTask
    AppPy -->|"Renders"| EditTask
    AppPy -->|"Renders"| ViewTask
    AppPy -->|"Renders"| TaskList
    AppPy -->|"Renders"| Statistics
    AppPy -->|"Queries/Inserts"| Database
    AppPy -->|"Uses"| MLWrapper
    MLWrapper -->|"Predict Priority"| Database
    AppPy -->|"Sends Email"| SMTP
    TrainScript -->|"Reads"| Dataset
    TrainScript -->|"Outputs"| EncCat
    TrainScript -->|"Outputs"| EncType
    TrainScript -->|"Outputs"| ModelFile
    TrainScript -->|"Outputs"| Scaler

    %% Click Events
    click StyleCSS "https://github.com/shreyao3/task_manager/blob/main/static/css/style.css"
    click ScriptJS "https://github.com/shreyao3/task_manager/blob/main/static/js/script.js"
    click ThemeJS "https://github.com/shreyao3/task_manager/blob/main/static/js/theme.js"
    click Landing "https://github.com/shreyao3/task_manager/blob/main/templates/landing.html"
    click SignIn "https://github.com/shreyao3/task_manager/blob/main/templates/signin.html"
    click Index "https://github.com/shreyao3/task_manager/blob/main/templates/index.html"
    click AddTask "https://github.com/shreyao3/task_manager/blob/main/templates/add_task.html"
    click EditTask "https://github.com/shreyao3/task_manager/blob/main/templates/edit_task.html"
    click ViewTask "https://github.com/shreyao3/task_manager/blob/main/templates/view_task.html"
    click TaskList "https://github.com/shreyao3/task_manager/blob/main/templates/task_list_partial.html"
    click Statistics "https://github.com/shreyao3/task_manager/blob/main/templates/statistics.html"
    click AppPy "https://github.com/shreyao3/task_manager/blob/main/app.py"
    click RunPy "https://github.com/shreyao3/task_manager/blob/main/run.py"
    click UserModel "https://github.com/shreyao3/task_manager/blob/main/models/user_model.py"
    click TaskModel "https://github.com/shreyao3/task_manager/blob/main/models/task_model.py"
    click MLWrapper "https://github.com/shreyao3/task_manager/blob/main/models/ml_model.py"
    click TrainScript "https://github.com/shreyao3/task_manager/blob/main/ml/train_model.py"
    click EncCat "https://github.com/shreyao3/task_manager/blob/main/ml/label_enc_category.pkl"
    click EncType "https://github.com/shreyao3/task_manager/blob/main/ml/label_enc_type.pkl"
    click ModelFile "https://github.com/shreyao3/task_manager/blob/main/ml/random_forest_task_priority.pkl"
    click Scaler "https://github.com/shreyao3/task_manager/blob/main/ml/scaler.pkl"
    click Dataset "https://github.com/shreyao3/task_manager/blob/main/ml/task-management-dataset.csv"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#0288D1,stroke-width:1px
    classDef app fill:#D0FFD6,stroke:#2E7D32,stroke-width:1px
    classDef data fill:#FFE0B2,stroke:#EF6C00,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#616161,stroke-width:1px
    classDef offline fill:#F3E5F5,stroke:#6A1B9A,stroke-width:1px
```
