# nguyenhao1312/do_nguyen_hao-24ct1-cnpm architecture

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

- Interactive diagram: https://gitdiagram.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm
- Repository: https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm

## Overview

UniMS is a self-hosted university and student management system with a Django backend and vanilla-JavaScript SPA. The principal workflow is role-based sign-in, then using student, teacher, or administrator features; the browser can work from encrypted local data and synchronize changes with the server. The graph covers academic records, attendance, administration, AI helpdesk, and session security. Some frontend wiring and API routes are not excerpted, so those connections are shown only where the README documents them.

Main entry points: [`student_management/models.py`](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/models.py) (University data), [`static/js/core/app.js`](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/core/app.js) (SPA shell), [`student_management/views/user/auth.py`](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/views/user/auth.py) (Account sessions), [`student_management/views/user/ai.py`](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/views/user/ai.py) (AI assistant API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser application"]
  node_spa["SPA shell<br/>[app.js]"]
  node_client_auth["Client sign-in<br/>[auth.js]"]
  node_local_data[("Offline data cache<br/>[database.js]")]
  node_crypto["Cache encryption<br/>[crypto.js]"]
  node_sync_queue["Sync queue<br/>[sync-queue.js]"]
  node_dashboard["Role dashboards<br/>[dashboard.js]"]
  node_grades_ui["Grades and classes<br/>[grades.js]"]
  node_student_ui["Student portal<br/>[registration.js]"]
  node_tuition_ui["Tuition view<br/>[tuition.js]"]
  node_attendance_ui["Attendance view<br/>[teachers.js]"]
  node_admin_ui["Admin management<br/>[students.js]"]
  node_helpdesk_ui["AI helpdesk<br/>[chatbot.js]"]
  node_public_review["Public review<br/>[review.js]"]
end

subgraph group_identity["Identity and security"]
  node_api_auth["Account sessions<br/>[auth.py]"]
  node_session_guard["Single-session guard<br/>[middleware.py]"]
  node_access_controls["API access controls<br/>[decorators.py]"]
end

subgraph group_academic["Academic operations"]
  node_student_records["Student records<br/>[portal.py]"]
  node_academic_admin["Academic administration<br/>[academic.py]"]
  node_teacher_attendance["Teacher attendance<br/>[attendance.py]"]
  node_sync_api["Role-filtered sync<br/>[sync.py]"]
  node_ai_api["AI assistant API<br/>[ai.py]"]
end

subgraph group_platform["Server and data"]
  node_domain_store[("University data<br/>[models.py]")]
end

node_person(("University user"))
node_sql_server[("SQL Server")]
node_gemini["Gemini service"]

node_person -->|"uses"| node_spa
node_spa -.->|"hosts"| node_client_auth
node_client_auth -->|"authenticates"| node_api_auth
node_api_auth -->|"reads and updates"| node_domain_store
node_api_auth -.->|"issues session"| node_session_guard
node_spa -->|"renders by role"| node_dashboard
node_dashboard -.->|"opens modules"| node_grades_ui
node_person -->|"views portal"| node_student_ui
node_person -->|"checks tuition"| node_tuition_ui
node_person -.->|"manages attendance"| node_attendance_ui
node_person -->|"manages users"| node_admin_ui
node_person -->|"asks questions"| node_helpdesk_ui
node_person -.->|"views review"| node_public_review
node_local_data -->|"encrypts cache"| node_crypto
node_sync_queue -->|"queues changes"| node_local_data
node_sync_queue -->|"uploads changes"| node_sync_api
node_sync_api -->|"reads and writes"| node_domain_store
node_grades_ui -.->|"uses academic APIs"| node_academic_admin
node_student_ui -.->|"requests profile"| node_student_records
node_student_records -->|"reads records"| node_domain_store
node_tuition_ui -.->|"uses tuition APIs"| node_academic_admin
node_attendance_ui -.->|"uses attendance APIs"| node_teacher_attendance
node_academic_admin -->|"reads and writes"| node_domain_store
node_teacher_attendance -->|"reads and writes"| node_domain_store
node_helpdesk_ui -.->|"sends questions"| node_ai_api
node_ai_api -->|"reads context"| node_domain_store
node_ai_api -.->|"optionally queries"| node_gemini
node_session_guard -->|"validates sessions"| node_domain_store
node_access_controls -->|"checks sessions and logs"| node_domain_store
node_domain_store -->|"persists data"| node_sql_server

click node_spa "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/core/app.js"
click node_client_auth "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/core/auth.js"
click node_local_data "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/core/database.js"
click node_crypto "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/core/crypto.js"
click node_sync_queue "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/core/sync-queue.js"
click node_dashboard "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/views/common/dashboard.js"
click node_grades_ui "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/views/common/grades.js"
click node_student_ui "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/views/student/registration.js"
click node_tuition_ui "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/views/student/tuition.js"
click node_attendance_ui "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/views/admin/teachers.js"
click node_admin_ui "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/views/admin/students.js"
click node_helpdesk_ui "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/views/common/chatbot.js"
click node_public_review "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/views/public/review.js"
click node_api_auth "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/views/user/auth.py"
click node_session_guard "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/middleware.py"
click node_access_controls "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/decorators.py"
click node_student_records "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/views/student/portal.py"
click node_academic_admin "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/views/admin/academic.py"
click node_teacher_attendance "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/views/teacher/attendance.py"
click node_sync_api "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/views/user/sync.py"
click node_ai_api "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/views/user/ai.py"
click node_domain_store "https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/models.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_spa,node_client_auth,node_local_data,node_crypto,node_sync_queue,node_dashboard,node_grades_ui,node_student_ui,node_tuition_ui,node_attendance_ui,node_admin_ui,node_helpdesk_ui,node_public_review,node_person toneBlue
class node_api_auth,node_session_guard,node_access_controls,node_sql_server toneAmber
class node_student_records,node_academic_admin,node_teacher_attendance,node_sync_api,node_ai_api toneMint
class node_domain_store toneRose
class node_gemini toneIndigo
```

## Components

### Browser application

- [SPA shell](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/core/app.js): `static/js/core/app.js`
- [Client sign-in](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/core/auth.js): `static/js/core/auth.js`
- [Offline data cache](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/core/database.js): `static/js/core/database.js`
- [Cache encryption](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/core/crypto.js): `static/js/core/crypto.js`
- [Sync queue](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/core/sync-queue.js): `static/js/core/sync-queue.js`
- [Role dashboards](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/views/common/dashboard.js): `static/js/views/common/dashboard.js`
- [Grades and classes](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/views/common/grades.js): `static/js/views/common/grades.js`
- [Student portal](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/views/student/registration.js): `static/js/views/student/registration.js`
- [Tuition view](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/views/student/tuition.js): `static/js/views/student/tuition.js`
- [Attendance view](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/views/admin/teachers.js): `static/js/views/admin/teachers.js`
- [Admin management](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/views/admin/students.js): `static/js/views/admin/students.js`
- [AI helpdesk](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/views/common/chatbot.js): `static/js/views/common/chatbot.js`
- [Public review](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/static/js/views/public/review.js): `static/js/views/public/review.js`

### Identity and security

- [Account sessions](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/views/user/auth.py): `student_management/views/user/auth.py`
- [Single-session guard](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/middleware.py): `student_management/middleware.py`
- [API access controls](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/decorators.py): `student_management/decorators.py`

### Academic operations

- [Student records](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/views/student/portal.py): `student_management/views/student/portal.py`
- [Academic administration](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/views/admin/academic.py): `student_management/views/admin/academic.py`
- [Teacher attendance](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/views/teacher/attendance.py): `student_management/views/teacher/attendance.py`
- [Role-filtered sync](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/views/user/sync.py): `student_management/views/user/sync.py`
- [AI assistant API](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/views/user/ai.py): `student_management/views/user/ai.py`

### Server and data

- [University data](https://github.com/nguyenhao1312/do_nguyen_hao-24ct1-cnpm/blob/master/student_management/models.py): `student_management/models.py`

### Other components

- **University user**
- **SQL Server**
- **Gemini service**

## Connections

- University user → SPA shell: uses (evidence: `README.md`)
- SPA shell → Client sign-in: hosts
- Client sign-in → Account sessions: authenticates (evidence: `README.md`)
- Account sessions → University data: reads and updates (evidence: `student_management/views/user/auth.py`)
- Account sessions → Single-session guard: issues session
- SPA shell → Role dashboards: renders by role (evidence: `README.md`)
- Role dashboards → Grades and classes: opens modules
- University user → Student portal: views portal (evidence: `README.md`)
- University user → Tuition view: checks tuition (evidence: `README.md`)
- University user → Attendance view: manages attendance
- University user → Admin management: manages users (evidence: `README.md`)
- University user → AI helpdesk: asks questions (evidence: `README.md`)
- University user → Public review: views review
- Offline data cache → Cache encryption: encrypts cache (evidence: `README.md`)
- Sync queue → Offline data cache: queues changes (evidence: `README.md`)
- Sync queue → Role-filtered sync: uploads changes (evidence: `README.md`)
- Role-filtered sync → University data: reads and writes (evidence: `student_management/views/user/sync.py`)
- Grades and classes → Academic administration: uses academic APIs
- Student portal → Student records: requests profile
- Student records → University data: reads records (evidence: `student_management/views/student/portal.py`)
- Tuition view → Academic administration: uses tuition APIs
- Attendance view → Teacher attendance: uses attendance APIs
- Academic administration → University data: reads and writes (evidence: `student_management/views/admin/academic.py`)
- Teacher attendance → University data: reads and writes (evidence: `student_management/views/teacher/attendance.py`)
- AI helpdesk → AI assistant API: sends questions
- AI assistant API → University data: reads context (evidence: `student_management/views/user/ai.py`)
- AI assistant API → Gemini service: optionally queries
- Single-session guard → University data: validates sessions (evidence: `student_management/middleware.py`)
- API access controls → University data: checks sessions and logs (evidence: `student_management/decorators.py`)
- University data → SQL Server: persists data (evidence: `README.md`)
