# truong027/cnpm24 architecture

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

- Interactive diagram: https://gitdiagram.com/truong027/cnpm24
- Repository: https://github.com/truong027/cnpm24

## Overview

Smart Parking AI manages resident vehicle and parking services alongside guard-operated entry/exit and administrator oversight. In the principal gate workflow, a guard monitors vehicle imagery; Flask coordinates plate recognition and parking transactions, and MySQL stores operational state. Residents register and manage vehicles, slots, tickets, history, and transfer requests; administrators manage users, transfers, vehicle lists, parking visibility, and reports. OCR implementation and role helpers are represented as internal layers. README documents the role capabilities and intended Flask/MySQL architecture; unsampled route details are not inferred.

Main entry points: [`ongthanquoctruong_24CT2_cnpm/be/app.py`](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py) (Flask app), [`ongthanquoctruong_24CT2_cnpm/be/database.py`](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/database.py) (MySQL access), [`ongthanquoctruong_24CT2_cnpm/be/crnn_ocr_wrapper.py`](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/crnn_ocr_wrapper.py) (CRNN wrapper), [`ongthanquoctruong_24CT2_cnpm/be/plate_ocr_integration.py`](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/plate_ocr_integration.py) (OCR integration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gate["Gate Operations"]
  node_gate_ops["Gate transactions<br/>[app.py]"]
  node_camera_ai["Camera monitoring<br/>[app.py]"]
end

subgraph group_vision["Plate Recognition"]
  node_ocr_pipeline["Plate OCR<br/>[app.py]"]
  node_crnn_wrapper["CRNN wrapper"]
  node_ocr_integration["OCR integration"]
  node_ocr_model["CRNN inference"]
end

subgraph group_resident["Resident Services"]
  node_resident_portal["Resident portal"]
  node_resident_accounts["Resident accounts<br/>[app.py]"]
  node_resident_vehicles["Vehicle and slot services<br/>[app.py]"]
  node_resident_history["Tickets and history<br/>[app.py]"]
  node_transfers["Transfer requests<br/>[app.py]"]
end

subgraph group_admin["Administration"]
  node_admin_panel["Operations dashboard"]
  node_user_rbac["User and RBAC<br/>[app.py]"]
  node_admin_oversight["Fleet and reports<br/>[app.py]"]
  node_parking_slots["Parking layout setup<br/>[setup_bai_do.py]"]
end

subgraph group_core["Application Core"]
  node_flask["Flask app<br/>[app.py]"]
  node_database[("MySQL access<br/>[database.py]")]
  node_guard_role["Guard role<br/>[guard_user.py]"]
  node_admin_role["Admin role<br/>[admin_user.py]"]
  node_resident_role["Resident role<br/>[resident_user.py]"]
end

node_guard(("Guard"))
node_admin_actor(("Admin"))
node_resident_actor(("Resident"))

node_guard -->|"monitors"| node_camera_ai
node_guard -->|"controls entry"| node_gate_ops
node_camera_ai -.->|"sends imagery"| node_flask
node_flask -->|"dispatches recognition"| node_ocr_pipeline
node_flask -->|"coordinates"| node_gate_ops
node_gate_ops -->|"processes transactions"| node_database
node_flask -->|"initializes"| node_database
node_flask -->|"imports"| node_crnn_wrapper
node_flask -->|"imports"| node_ocr_integration
node_crnn_wrapper -->|"uses inference"| node_ocr_model
node_ocr_integration -->|"loads model"| node_ocr_model
node_resident_actor -->|"uses"| node_resident_portal
node_resident_portal -->|"uses portal routes"| node_flask
node_resident_actor -->|"registers"| node_resident_accounts
node_resident_actor -->|"manages vehicles"| node_resident_vehicles
node_resident_actor -->|"views history"| node_resident_history
node_resident_actor -->|"requests transfer"| node_transfers
node_admin_actor -->|"uses"| node_admin_panel
node_admin_panel -->|"uses admin routes"| node_flask
node_admin_actor -->|"manages users"| node_user_rbac
node_admin_actor -->|"reviews requests"| node_transfers
node_admin_actor -->|"manages fleet"| node_admin_oversight
node_admin_actor -->|"views reports"| node_admin_oversight
node_parking_slots -->|"seeds slots"| node_database
node_flask -->|"imports role check"| node_guard_role
node_flask -->|"imports role check"| node_admin_role
node_flask -->|"imports role check"| node_resident_role

click node_flask "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py"
click node_database "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/database.py"
click node_guard_role "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/roles/guard_user.py"
click node_admin_role "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/roles/admin_user.py"
click node_resident_role "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/roles/resident_user.py"
click node_gate_ops "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py"
click node_camera_ai "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py"
click node_ocr_pipeline "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py"
click node_crnn_wrapper "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/crnn_ocr_wrapper.py"
click node_ocr_integration "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/plate_ocr_integration.py"
click node_ocr_model "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/plate_ocr_inference.py"
click node_resident_portal "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/fe/templates/resident_dashboard.html"
click node_resident_accounts "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py"
click node_resident_vehicles "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py"
click node_resident_history "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py"
click node_transfers "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py"
click node_admin_panel "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/public/operations-dashboard.html"
click node_user_rbac "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py"
click node_admin_oversight "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py"
click node_parking_slots "https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/setup_bai_do.py"

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_gate_ops,node_camera_ai toneBlue
class node_ocr_pipeline,node_crnn_wrapper,node_ocr_integration,node_ocr_model toneAmber
class node_resident_portal,node_resident_accounts,node_resident_vehicles,node_resident_history,node_transfers toneMint
class node_admin_panel,node_user_rbac,node_admin_oversight,node_parking_slots toneRose
class node_flask,node_database,node_guard_role,node_admin_role,node_resident_role,node_guard,node_admin_actor,node_resident_actor toneIndigo
```

## Components

### Gate Operations

- [Gate transactions](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py): `ongthanquoctruong_24CT2_cnpm/be/app.py`
- [Camera monitoring](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py): `ongthanquoctruong_24CT2_cnpm/be/app.py`

### Plate Recognition

- [Plate OCR](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py): `ongthanquoctruong_24CT2_cnpm/be/app.py`
- [CRNN wrapper](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/crnn_ocr_wrapper.py): `ongthanquoctruong_24CT2_cnpm/be/crnn_ocr_wrapper.py`
- [OCR integration](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/plate_ocr_integration.py): `ongthanquoctruong_24CT2_cnpm/be/plate_ocr_integration.py`
- [CRNN inference](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/plate_ocr_inference.py): `ongthanquoctruong_24CT2_cnpm/be/plate_ocr_inference.py`

### Resident Services

- [Resident portal](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/fe/templates/resident_dashboard.html): `ongthanquoctruong_24CT2_cnpm/fe/templates/resident_dashboard.html`
- [Resident accounts](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py): `ongthanquoctruong_24CT2_cnpm/be/app.py`
- [Vehicle and slot services](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py): `ongthanquoctruong_24CT2_cnpm/be/app.py`
- [Tickets and history](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py): `ongthanquoctruong_24CT2_cnpm/be/app.py`
- [Transfer requests](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py): `ongthanquoctruong_24CT2_cnpm/be/app.py`

### Administration

- [Operations dashboard](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/public/operations-dashboard.html): `ongthanquoctruong_24CT2_cnpm/public/operations-dashboard.html`
- [User and RBAC](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py): `ongthanquoctruong_24CT2_cnpm/be/app.py`
- [Fleet and reports](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py): `ongthanquoctruong_24CT2_cnpm/be/app.py`
- [Parking layout setup](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/setup_bai_do.py): `ongthanquoctruong_24CT2_cnpm/be/setup_bai_do.py`

### Application Core

- [Flask app](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/app.py): `ongthanquoctruong_24CT2_cnpm/be/app.py`
- [MySQL access](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/database.py): `ongthanquoctruong_24CT2_cnpm/be/database.py`
- [Guard role](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/roles/guard_user.py): `ongthanquoctruong_24CT2_cnpm/be/roles/guard_user.py`
- [Admin role](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/roles/admin_user.py): `ongthanquoctruong_24CT2_cnpm/be/roles/admin_user.py`
- [Resident role](https://github.com/truong027/cnpm24/blob/main/ongthanquoctruong_24CT2_cnpm/be/roles/resident_user.py): `ongthanquoctruong_24CT2_cnpm/be/roles/resident_user.py`

### Other components

- **Guard**
- **Admin**
- **Resident**

## Connections

- Guard → Camera monitoring: monitors
- Guard → Gate transactions: controls entry
- Camera monitoring → Flask app: sends imagery (evidence: `ongthanquoctruong_24CT2_cnpm/be/app.py`)
- Flask app → Plate OCR: dispatches recognition (evidence: `ongthanquoctruong_24CT2_cnpm/be/app.py`)
- Flask app → Gate transactions: coordinates (evidence: `ongthanquoctruong_24CT2_cnpm/be/app.py`)
- Gate transactions → MySQL access: processes transactions (evidence: `ongthanquoctruong_24CT2_cnpm/be/database.py`)
- Flask app → MySQL access: initializes (evidence: `ongthanquoctruong_24CT2_cnpm/be/app.py`)
- Flask app → CRNN wrapper: imports (evidence: `ongthanquoctruong_24CT2_cnpm/be/app.py`)
- Flask app → OCR integration: imports (evidence: `ongthanquoctruong_24CT2_cnpm/be/app.py`)
- CRNN wrapper → CRNN inference: uses inference (evidence: `ongthanquoctruong_24CT2_cnpm/be/crnn_ocr_wrapper.py`)
- OCR integration → CRNN inference: loads model (evidence: `ongthanquoctruong_24CT2_cnpm/be/plate_ocr_integration.py`)
- Resident → Resident portal: uses
- Resident portal → Flask app: uses portal routes
- Resident → Resident accounts: registers
- Resident → Vehicle and slot services: manages vehicles
- Resident → Tickets and history: views history
- Resident → Transfer requests: requests transfer (evidence: `ongthanquoctruong_24CT2_cnpm/be/app.py`)
- Admin → Operations dashboard: uses
- Operations dashboard → Flask app: uses admin routes
- Admin → User and RBAC: manages users
- Admin → Transfer requests: reviews requests
- Admin → Fleet and reports: manages fleet
- Admin → Fleet and reports: views reports
- Parking layout setup → MySQL access: seeds slots (evidence: `ongthanquoctruong_24CT2_cnpm/be/setup_bai_do.py`)
- Flask app → Guard role: imports role check (evidence: `ongthanquoctruong_24CT2_cnpm/be/app.py`)
- Flask app → Admin role: imports role check (evidence: `ongthanquoctruong_24CT2_cnpm/be/app.py`)
- Flask app → Resident role: imports role check (evidence: `ongthanquoctruong_24CT2_cnpm/be/app.py`)
