# trananhkiet-hub/cs2401 architecture

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

- Interactive diagram: https://gitdiagram.com/trananhkiet-hub/cs2401
- Repository: https://github.com/trananhkiet-hub/cs2401

## Overview

This is a small Flask sales-catalog app. A visitor opens the catalog, where the route loads categories, filters its in-memory product list by an optional keyword, and renders the page; visitors can also open login and registration forms, whose POST handlers redirect without implementing authentication or persistence. Category records are represented by a SQLAlchemy model and loaded through a DAO. The sampled code does not show product persistence, and the database connection is configured for MySQL. Templates are represented by their existing directory; relationships are based on the sampled route and model code.

Main entry points: [`saleapp/eapp/index.py`](https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/index.py) (Catalog and forms), [`saleapp/eapp/dao.py`](https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/dao.py) (Category DAO), [`saleapp/eapp/__init__.py`](https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/__init__.py) (SQLAlchemy setup), [`saleapp/eapp/models.py`](https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/models.py) (Category model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web routes"]
  node_routes["Catalog and forms<br/>[index.py]"]
end

subgraph group_data["Category data"]
  node_dao["Category DAO<br/>[dao.py]"]
  node_category["Category model<br/>[models.py]"]
  node_app_db["SQLAlchemy setup<br/>[__init__.py]"]
end

subgraph group_views["Page templates"]
  node_catalog_view["Catalog page<br/>[index.html]"]
  node_login_view["Login page<br/>[login.html]"]
  node_register_view["Registration page<br/>[register.html]"]
end

node_visitor(("Visitor"))
node_mysql[("MySQL database")]

node_visitor -->|"requests pages"| node_routes
node_routes -->|"loads categories"| node_dao
node_dao -->|"queries"| node_category
node_app_db -->|"configures connection"| node_mysql
node_dao -->|"reads categories"| node_mysql
node_routes -->|"renders"| node_catalog_view
node_routes -->|"renders"| node_login_view
node_routes -->|"renders"| node_register_view

click node_routes "https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/index.py"
click node_dao "https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/dao.py"
click node_category "https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/models.py"
click node_app_db "https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/__init__.py"
click node_catalog_view "https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/templates/index.html"
click node_login_view "https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/templates/login.html"
click node_register_view "https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/templates/register.html"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_routes toneBlue
class node_dao,node_category,node_app_db,node_mysql toneAmber
class node_catalog_view,node_login_view,node_register_view toneMint
class node_visitor toneIndigo
```

## Components

### Web routes

- [Catalog and forms](https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/index.py): `saleapp/eapp/index.py`

### Category data

- [Category DAO](https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/dao.py): `saleapp/eapp/dao.py`
- [Category model](https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/models.py): `saleapp/eapp/models.py`
- [SQLAlchemy setup](https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/__init__.py): `saleapp/eapp/__init__.py`

### Page templates

- [Catalog page](https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/templates/index.html): `saleapp/eapp/templates/index.html`
- [Login page](https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/templates/login.html): `saleapp/eapp/templates/login.html`
- [Registration page](https://github.com/trananhkiet-hub/cs2401/blob/main/saleapp/eapp/templates/register.html): `saleapp/eapp/templates/register.html`

### Other components

- **Visitor**
- **MySQL database**

## Connections

- Visitor → Catalog and forms: requests pages (evidence: `saleapp/eapp/index.py`)
- Catalog and forms → Category DAO: loads categories (evidence: `saleapp/eapp/index.py`)
- Category DAO → Category model: queries (evidence: `saleapp/eapp/dao.py`)
- SQLAlchemy setup → MySQL database: configures connection (evidence: `saleapp/eapp/__init__.py`)
- Category DAO → MySQL database: reads categories (evidence: `saleapp/eapp/dao.py`)
- Catalog and forms → Catalog page: renders (evidence: `saleapp/eapp/index.py`)
- Catalog and forms → Login page: renders (evidence: `saleapp/eapp/index.py`)
- Catalog and forms → Registration page: renders (evidence: `saleapp/eapp/index.py`)
