# hazzillrodriguez/tickette architecture

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

- Interactive diagram: https://gitdiagram.com/hazzillrodriguez/tickette
- Repository: https://github.com/hazzillrodriguez/tickette

## Overview

##### Project type and purpose
- Tickette is a monolithic full-stack web application written in Python using the Flask framework.
- It implements a multi‐role support ticketing system (Administrator, Agent, Customer) that handles ticket creation, categorization, prioritization, assignment, commenting, and email notifications.

##### File structure
- Top-level: run.py (app entry point), config.py, requirements.txt, demo, tests.
- app/: contains the Flask application package.
- app/auth, app/admin, app/agent, app/customer – four blueprint modules, each with their own views.py and forms.py, implementing authentication and the three user roles.
- app/models.py – SQLAlchemy ORM models (User, Ticket, Category, Priority, Status, Comment, Notification, etc.).
- app/exts.py – Flask extensions initialization (db, mail, login_manager).
- app/utils/ – helper functions (role decorators, password reset, redirection).
- app/static/ & app/templates/ – frontend assets (CSS, JS, images) and Jinja2 templates organized by role and shared layouts/includes/macros.
- config.py – environment configuration including SQLALCHEMY_DATABASE_URI, MAIL_SERVER.
- tests/ – pytest test suite covering auth, admin flows, etc.

##### README for additional insights
- Confirms Flask, SQLAlchemy, SMTP for emailing, database setup (Postgres or SQL Server or MySQL).
- Describes user flows (login/signup, ticket CRUD, email reset).

##### Detail
- Endpoints (e.g., POST /auth/login, GET /admin/dashboard, POST /customer/ticket).
- Essential helpers (ex: token generation in reset_password utility).
- Don’t hesitate to break down the Flask App into smaller components—auth blueprint, admin blueprint, shared extensions—to give a complete view of how data flows and where responsibilities lie.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["Web Browser"]:::presentation
        Static["Static Assets"]:::presentation
        Templates["Jinja2 Templates"]:::presentation
        EmailTemplates["Email Templates"]:::presentation
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Run["run.py (Entry Point)"]:::application
        Config["config.py"]:::application
        Exts["app/exts.py"]:::application

        subgraph "Blueprints"
            direction TB
            subgraph "Auth Module"
                direction TB
                AuthForms["forms.py"]:::application
                AuthViews["views.py"]:::application
            end
            subgraph "Admin Module"
                direction TB
                AdminForms["forms.py"]:::application
                AdminViews["views.py"]:::application
            end
            subgraph "Agent Module"
                direction TB
                AgentForms["forms.py"]:::application
                AgentViews["views.py"]:::application
            end
            subgraph "Customer Module"
                direction TB
                CustomerForms["forms.py"]:::application
                CustomerViews["views.py"]:::application
            end
        end

        subgraph "Utilities"
            direction TB
            RoleDec["authorized_role.py"]:::application
            GenDigits["generate_digits.py"]:::application
            RedirectHelper["redirect_url_endpoint.py"]:::application
            ResetPwd["reset_password.py"]:::application
        end

        Models["app/models.py"]:::application
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Database["Relational Database\n(Postgres/MySQL)"]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        SMTP["SMTP Mail Server"]:::external
    end

    %% Other Components
    subgraph "Other"
        direction TB
        Tests["tests/"]:::application
        Demo["demo/"]:::application
        Req["requirements.txt"]:::application
    end

    %% Connections
    Browser -->|"HTTP(S) GET/POST"| Run
    Run -->|"load config"| Config
    Run -->|"init extensions"| Exts
    Run -->|"register blueprints"| AuthForms
    Run -->|"register blueprints"| AuthViews
    Run -->|"register blueprints"| AdminForms
    Run -->|"register blueprints"| AdminViews
    Run -->|"register blueprints"| AgentForms
    Run -->|"register blueprints"| AgentViews
    Run -->|"register blueprints"| CustomerForms
    Run -->|"register blueprints"| CustomerViews

    AuthForms -->|"uses ORM"| Models
    AuthViews -->|"renders"| Templates
    AuthViews -->|"serves static"| Static
    AuthViews -->|"sends email"| SMTP

    AdminForms -->|"uses ORM"| Models
    AdminViews -->|"renders"| Templates
    AdminViews -->|"serves static"| Static
    AdminViews -->|"sends email"| SMTP

    AgentForms -->|"uses ORM"| Models
    AgentViews -->|"renders"| Templates
    AgentViews -->|"serves static"| Static
    AgentViews -->|"sends email"| SMTP

    CustomerForms -->|"uses ORM"| Models
    CustomerViews -->|"renders"| Templates
    CustomerViews -->|"serves static"| Static
    CustomerViews -->|"sends email"| SMTP

    Models -->|"SQL Queries"| Database
    Exts -->|"provides db/mail/login"| AuthForms
    Exts -->|"provides db/mail/login"| AdminForms
    Exts -->|"provides db/mail/login"| AgentForms
    Exts -->|"provides db/mail/login"| CustomerForms

    AuthViews -->|"uses utils"| RoleDec
    AdminViews -->|"uses utils"| RoleDec
    AgentViews -->|"uses utils"| RoleDec
    CustomerViews -->|"uses utils"| RoleDec

    ResetPwd -->|"sends reset link"| SMTP
    ResetPwd -->|"uses templates"| EmailTemplates

    Tests -->|"covers modules"| AuthViews
    Tests -->|"covers modules"| AdminViews
    Tests -->|"covers modules"| AgentViews
    Tests -->|"covers modules"| CustomerViews

    %% Click Events
    click Static "https://github.com/hazzillrodriguez/tickette/tree/main/app/static/"
    click Templates "https://github.com/hazzillrodriguez/tickette/tree/main/app/templates/"
    click EmailTemplates "https://github.com/hazzillrodriguez/tickette/tree/main/app/templates/email/"
    click Run "https://github.com/hazzillrodriguez/tickette/blob/main/run.py"
    click Config "https://github.com/hazzillrodriguez/tickette/blob/main/config.py"
    click Models "https://github.com/hazzillrodriguez/tickette/blob/main/app/models.py"
    click Exts "https://github.com/hazzillrodriguez/tickette/blob/main/app/exts.py"

    click AuthForms "https://github.com/hazzillrodriguez/tickette/blob/main/app/auth/forms.py"
    click AuthViews "https://github.com/hazzillrodriguez/tickette/blob/main/app/auth/views.py"
    click AdminForms "https://github.com/hazzillrodriguez/tickette/blob/main/app/admin/forms.py"
    click AdminViews "https://github.com/hazzillrodriguez/tickette/blob/main/app/admin/views.py"
    click AgentForms "https://github.com/hazzillrodriguez/tickette/blob/main/app/agent/forms.py"
    click AgentViews "https://github.com/hazzillrodriguez/tickette/blob/main/app/agent/views.py"
    click CustomerForms "https://github.com/hazzillrodriguez/tickette/blob/main/app/customer/forms.py"
    click CustomerViews "https://github.com/hazzillrodriguez/tickette/blob/main/app/customer/views.py"

    click RoleDec "https://github.com/hazzillrodriguez/tickette/blob/main/app/utils/authorized_role.py"
    click GenDigits "https://github.com/hazzillrodriguez/tickette/blob/main/app/utils/generate_digits.py"
    click RedirectHelper "https://github.com/hazzillrodriguez/tickette/blob/main/app/utils/redirect_url_endpoint.py"
    click ResetPwd "https://github.com/hazzillrodriguez/tickette/blob/main/app/utils/reset_password.py"

    click Tests "https://github.com/hazzillrodriguez/tickette/tree/main/tests/"
    click Demo "https://github.com/hazzillrodriguez/tickette/tree/main/demo/"
    click Req "https://github.com/hazzillrodriguez/tickette/blob/main/requirements.txt"

    %% Styles
    classDef presentation fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef application fill:#90EE90,stroke:#333,stroke-width:1px
    classDef data fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#DDA0DD,stroke:#333,stroke-width:1px
```
