# szluk133/htttql architecture

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

- Interactive diagram: https://gitdiagram.com/szluk133/htttql
- Repository: https://github.com/szluk133/htttql

## Overview

##### Project type and purpose
- This is a monolithic full-stack web application built with Flask (Python) that manages business data (customers, employees, payroll, revenue, etc.).
- The SQLQuery10.sql file initializes an SQL Server database (BTL_HTTTQL) with the required schema and tables.
- The Python app (app.py) serves HTML templates (under /templates) and static assets (under /static) via Flask, provides forms via flask-wtf, and performs CRUD operations against SQL Server.

##### File structure
- Top-level files:
- README.md – project overview and setup instructions.
- SQLQuery10.sql – DDL and seed data for SQL Server.
- app.py – Flask application entrypoint, route definitions, business logic.
- venv/ – Python virtual environment.
- Directories:
- static/ – CSS, JavaScript, images (img/).
- templates/ – HTML templates. Subfolder “QuanLy” groups manager-views (QLKhachHang, QLNhanVien, etc.). Root templates include login.html, trangchu.html, nvbanhang.html, nvthukho.html, quanly.html.
- Architectural pattern: a simple MVC-style separation.
- Controllers: route functions in app.py
- Views: Jinja2 templates in templates/
- Model: SQL Server database accessed via Python DB-API or ORM (not explicitly in tree, but implied).

##### README for insights
- Dependencies: Flask, Flask-WTF, Python, SQL Server.
- No explicit microservices or external APIs—fully self-contained.
- Deployment considerations: needs connection string to SQL Server; static folder served by Flask or fronting web server.

##### Elements
- Clear labels: e.g., “Web Browser,” “Flask App (app.py),” “SQL Server (BTL_HTTTQL).”
- A third for the database
- Optional: annotate ports (e.g., 5000) or config (connection string).

##### Detailed breakdown
- That app.py imports and wires up these routes.
- That SQLQuery10.sql defines tables that correspond to entities managed by each view (customers, employees, payroll, revenue).
- If desired, show that Flask-WTF handles form objects and validation in controllers before calling SQL.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    Browser["Web Browser"]:::ui
    StaticServer["Static File Server"]:::ui
    
    %% Server Layer
    subgraph "Flask Application" 
        direction TB
        Controllers["Routing / Controllers\n(app.py)"]:::server
        FormValidation["Form Validation\n(Flask-WTF)"]:::server
        TemplateEngine["Template Engine\n(Jinja2)"]:::server
        Controllers -->|uses| FormValidation
        Controllers -->|renders| TemplateEngine
    end
    
    %% Templates Subgraph
    subgraph "HTML Templates" 
        direction TB
        Login["login.html"]:::ui
        TrangChu["trangchu.html"]:::ui
        NVBanHang["nvbanhang.html"]:::ui
        NVThuKho["nvthukho.html"]:::ui
        QuanLyRoot["quanly.html"]:::ui
        subgraph "Manager Views (templates/QuanLy)"
            direction TB
            QLKhachHang["QLKhachHang.html"]:::ui
            QLNhanVien["QLNhanVien.html"]:::ui
            QLLuong["QLLuong.html"]:::ui
            QLLLV["QLLLV.html"]:::ui
            QLTK["QLTK.html"]:::ui
            QLTaiChinh["QLTaiChinh.html"]:::ui
            TKDTNV["TKDTNV.html"]:::ui
            ChiTietDoanhThu["ChiTietDoanhThuNV.html"]:::ui
        end
    end
    
    %% Database Layer
    Database["SQL Server\n(BTL_HTTTQL)"]:::database
    SQLSchema["Database Schema & Seed Data\n(SQLQuery10.sql)"]:::database
    
    %% Dependencies
    Venv["Python Virtual Environment\n(venv/)"]:::server
    
    %% Connections
    Browser -->|HTTP GET/POST| Controllers
    Browser -->|Static asset request| StaticServer
    Controllers -->|SQL SELECT/INSERT/UPDATE| Database
    TemplateEngine -->|loads templates| Login
    TemplateEngine -->|loads templates| TrangChu
    TemplateEngine -->|loads templates| NVBanHang
    TemplateEngine -->|loads templates| NVThuKho
    TemplateEngine -->|loads templates| QuanLyRoot
    TemplateEngine -->|loads templates| QLKhachHang
    TemplateEngine -->|loads templates| QLNhanVien
    TemplateEngine -->|loads templates| QLLuong
    TemplateEngine -->|loads templates| QLLLV
    TemplateEngine -->|loads templates| QLTK
    TemplateEngine -->|loads templates| QLTaiChinh
    TemplateEngine -->|loads templates| TKDTNV
    TemplateEngine -->|loads templates| ChiTietDoanhThu
    Database -->|defined by| SQLSchema
    Controllers -->|runs in| Venv

    %% Click Events
    click Controllers "https://github.com/szluk133/htttql/blob/main/app.py"
    click SQLSchema "https://github.com/szluk133/htttql/blob/main/SQLQuery10.sql"
    click Login "https://github.com/szluk133/htttql/blob/main/templates/login.html"
    click TrangChu "https://github.com/szluk133/htttql/blob/main/templates/trangchu.html"
    click NVBanHang "https://github.com/szluk133/htttql/blob/main/templates/nvbanhang.html"
    click NVThuKho "https://github.com/szluk133/htttql/blob/main/templates/nvthukho.html"
    click QuanLyRoot "https://github.com/szluk133/htttql/blob/main/templates/quanly.html"
    click QLKhachHang "https://github.com/szluk133/htttql/blob/main/templates/QuanLy/QLKhachHang.html"
    click QLNhanVien "https://github.com/szluk133/htttql/blob/main/templates/QuanLy/QLNhanVien.html"
    click QLLuong "https://github.com/szluk133/htttql/blob/main/templates/QuanLy/QLLuong.html"
    click QLLLV "https://github.com/szluk133/htttql/blob/main/templates/QuanLy/QLLLV.html"
    click QLTK "https://github.com/szluk133/htttql/blob/main/templates/QuanLy/QLTK.html"
    click QLTaiChinh "https://github.com/szluk133/htttql/blob/main/templates/QuanLy/QLTaiChinh.html"
    click TKDTNV "https://github.com/szluk133/htttql/blob/main/templates/QuanLy/TKDTNV.html"
    click ChiTietDoanhThu "https://github.com/szluk133/htttql/blob/main/templates/QuanLy/ChiTietDoanhThuNV.html"
    click StaticServer "https://github.com/szluk133/htttql/tree/main/static/"
    click Venv "https://github.com/szluk133/htttql/tree/main/venv/"

    %% Styles
    classDef ui fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1;
    classDef server fill:#C8E6C9,stroke:#1B5E20,color:#1B5E20;
    classDef database fill:#FFE0B2,stroke:#E65100,color:#E65100;
```
