# haodpsut/nop-bai-video architecture

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

- Interactive diagram: https://gitdiagram.com/haodpsut/nop-bai-video
- Repository: https://github.com/haodpsut/nop-bai-video

## Overview

Đây là ứng dụng web đa học phần để sinh viên nộp link video và giảng viên quản lý lớp, đợt nộp, chấm bài và xuất Excel. Luồng sinh viên: nhập mã → xem các lớp và đợt của mình → kiểm tra, chuẩn hóa và nộp link → xem điểm, nhận xét. Luồng giảng viên: đăng nhập → tạo lớp, nạp danh sách và mở đợt → theo dõi, chấm bài → xuất bảng điểm. README mô tả các khả năng chính; một số trang và xử lý chưa được trích mã nên các quan hệ đó chỉ được nối khi README nêu rõ.

Main entry points: [`src/lib/truy-van.ts`](https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/truy-van.ts) (Truy vấn nghiệp vụ), [`src/app/hanh-dong.ts`](https://github.com/haodpsut/nop-bai-video/blob/main/src/app/hanh-dong.ts) (Xử lý sinh viên), [`src/app/giang-vien/hanh-dong.ts`](https://github.com/haodpsut/nop-bai-video/blob/main/src/app/giang-vien/hanh-dong.ts) (Thao tác giảng viên), [`src/app/page.tsx`](https://github.com/haodpsut/nop-bai-video/blob/main/src/app/page.tsx) (Trang sinh viên)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_student["Sinh viên"]
  node_student_home["Trang sinh viên<br/>[page.tsx]"]
  node_student_code["Nhập mã SV<br/>[nhap-ma-sv.tsx]"]
  node_submit_form["Ô nộp bài<br/>[o-nop-bai.tsx]"]
  node_student_actions["Xử lý sinh viên<br/>[hanh-dong.ts]"]
end

subgraph group_lecturer["Giảng viên"]
  node_teacher_home["Trang giảng viên<br/>[page.tsx]"]
  node_teacher_login["Đăng nhập GV<br/>[dang-nhap-gv.tsx]"]
  node_teacher_session["Phiên giảng viên<br/>[phien-gv.ts]"]
  node_class_page["Quản lý lớp<br/>[page.tsx]"]
  node_class_forms["Form lớp và đợt<br/>[form-lop.tsx]"]
  node_roster_form["Nạp danh sách<br/>[form-danh-sach.tsx]"]
  node_teacher_actions["Thao tác giảng viên<br/>[hanh-dong.ts]"]
  node_grading_page["Trang chấm đợt<br/>[page.tsx]"]
  node_grading_ui["Bảng chấm bài<br/>[dong-cham.tsx]"]
  node_video_player["Xem video<br/>[xem-video.tsx]"]
end

subgraph group_domain["Nghiệp vụ và dữ liệu"]
  node_roster_parser["Đọc danh sách<br/>[doc-danh-sach.ts]"]
  node_video_rules["Chuẩn hóa video<br/>[link-video.ts]"]
  node_time_rules["Hạn và thời gian<br/>[thoi-gian.ts]"]
  node_query_layer["Truy vấn nghiệp vụ<br/>[truy-van.ts]"]
  node_data_types["Kiểu dữ liệu<br/>[kieu.ts]"]
  node_db_client["Kết nối Supabase<br/>[supabase.ts]"]
  node_database[("Cơ sở dữ liệu")]
end

subgraph group_output["Xuất kết quả"]
  node_excel_route["API xuất Excel<br/>[route.ts]"]
  node_excel_logic["Tạo bảng Excel<br/>[excel.ts]"]
end

node_student_actor(("Sinh viên"))
node_teacher_actor(("Giảng viên"))

node_student_actor -->|"mở trang"| node_student_home
node_student_home -->|"yêu cầu mã"| node_student_code
node_student_home -->|"đọc lớp và bài"| node_query_layer
node_student_code -->|"gửi mã"| node_student_actions
node_student_actions -->|"tra sinh viên, đợt"| node_query_layer
node_student_home -->|"hiển thị ô nộp"| node_submit_form
node_submit_form -->|"gửi bài"| node_student_actions
node_student_actions -->|"kiểm tra link"| node_video_rules
node_student_actions -->|"kiểm hạn"| node_time_rules
node_student_actions -->|"ghi bài, lịch sử"| node_db_client
node_teacher_actor -->|"mở trang"| node_teacher_home
node_teacher_home -->|"chưa đăng nhập"| node_teacher_login
node_teacher_login -->|"gửi thông tin"| node_teacher_actions
node_teacher_actions -->|"kiểm phiên"| node_teacher_session
node_teacher_home -->|"đọc thống kê lớp"| node_query_layer
node_teacher_home -->|"tạo lớp"| node_class_forms
node_class_page -->|"hiển thị nhập danh sách"| node_roster_form
node_class_page -->|"hiển thị form đợt"| node_class_forms
node_roster_form -->|"gửi danh sách"| node_teacher_actions
node_teacher_actions -->|"đọc dữ liệu dán"| node_roster_parser
node_teacher_actions -->|"lưu lớp, danh sách, đợt"| node_db_client
node_grading_page -->|"hiển thị bảng chấm"| node_grading_ui
node_grading_page -->|"đọc bài và tiến độ"| node_query_layer
node_grading_ui -->|"gửi kết quả chấm"| node_teacher_actions
node_grading_ui -->|"xem video"| node_video_player
node_video_player -->|"tạo link nhúng"| node_video_rules
node_query_layer -->|"truy vấn"| node_db_client
node_db_client -->|"đọc, ghi dữ liệu"| node_database
node_student_actions -->|"kiểm ghi danh"| node_query_layer
node_excel_route -->|"xác thực phiên"| node_teacher_session
node_excel_route -->|"đọc dữ liệu đợt"| node_query_layer
node_excel_route -->|"tạo tệp"| node_excel_logic
node_teacher_actor -->|"xuất đợt"| node_excel_route
node_student_home -->|"hiện thời hạn"| node_time_rules
node_query_layer -->|"dùng kiểu miền"| node_data_types

click node_student_home "https://github.com/haodpsut/nop-bai-video/blob/main/src/app/page.tsx"
click node_student_code "https://github.com/haodpsut/nop-bai-video/blob/main/src/components/nhap-ma-sv.tsx"
click node_submit_form "https://github.com/haodpsut/nop-bai-video/blob/main/src/components/o-nop-bai.tsx"
click node_student_actions "https://github.com/haodpsut/nop-bai-video/blob/main/src/app/hanh-dong.ts"
click node_teacher_home "https://github.com/haodpsut/nop-bai-video/blob/main/src/app/giang-vien/page.tsx"
click node_teacher_login "https://github.com/haodpsut/nop-bai-video/blob/main/src/components/dang-nhap-gv.tsx"
click node_teacher_session "https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/phien-gv.ts"
click node_class_page "https://github.com/haodpsut/nop-bai-video/blob/main/src/app/giang-vien/lop/%5Bma%5D/page.tsx"
click node_class_forms "https://github.com/haodpsut/nop-bai-video/blob/main/src/components/form-lop.tsx"
click node_roster_form "https://github.com/haodpsut/nop-bai-video/blob/main/src/components/form-danh-sach.tsx"
click node_teacher_actions "https://github.com/haodpsut/nop-bai-video/blob/main/src/app/giang-vien/hanh-dong.ts"
click node_grading_page "https://github.com/haodpsut/nop-bai-video/blob/main/src/app/giang-vien/dot/%5Bid%5D/page.tsx"
click node_grading_ui "https://github.com/haodpsut/nop-bai-video/blob/main/src/components/dong-cham.tsx"
click node_roster_parser "https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/doc-danh-sach.ts"
click node_video_rules "https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/link-video.ts"
click node_time_rules "https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/thoi-gian.ts"
click node_query_layer "https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/truy-van.ts"
click node_data_types "https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/kieu.ts"
click node_db_client "https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/supabase.ts"
click node_database "https://github.com/haodpsut/nop-bai-video/blob/main/supabase/migrations/20260905000100_khoi_tao.sql"
click node_video_player "https://github.com/haodpsut/nop-bai-video/blob/main/src/components/xem-video.tsx"
click node_excel_route "https://github.com/haodpsut/nop-bai-video/blob/main/src/app/api/xuat-excel/route.ts"
click node_excel_logic "https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/excel.ts"

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_student_home,node_student_code,node_submit_form,node_student_actions toneBlue
class node_teacher_home,node_teacher_login,node_teacher_session,node_class_page,node_class_forms,node_roster_form,node_teacher_actions,node_grading_page,node_grading_ui,node_video_player toneAmber
class node_roster_parser,node_video_rules,node_time_rules,node_query_layer,node_data_types,node_db_client,node_database toneMint
class node_excel_route,node_excel_logic toneRose
class node_student_actor,node_teacher_actor toneIndigo
```

## Components

### Sinh viên

- [Trang sinh viên](https://github.com/haodpsut/nop-bai-video/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Nhập mã SV](https://github.com/haodpsut/nop-bai-video/blob/main/src/components/nhap-ma-sv.tsx): `src/components/nhap-ma-sv.tsx`
- [Ô nộp bài](https://github.com/haodpsut/nop-bai-video/blob/main/src/components/o-nop-bai.tsx): `src/components/o-nop-bai.tsx`
- [Xử lý sinh viên](https://github.com/haodpsut/nop-bai-video/blob/main/src/app/hanh-dong.ts): `src/app/hanh-dong.ts`

### Giảng viên

- [Trang giảng viên](https://github.com/haodpsut/nop-bai-video/blob/main/src/app/giang-vien/page.tsx): `src/app/giang-vien/page.tsx`
- [Đăng nhập GV](https://github.com/haodpsut/nop-bai-video/blob/main/src/components/dang-nhap-gv.tsx): `src/components/dang-nhap-gv.tsx`
- [Phiên giảng viên](https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/phien-gv.ts): `src/lib/phien-gv.ts`
- [Quản lý lớp](https://github.com/haodpsut/nop-bai-video/blob/main/src/app/giang-vien/lop/%5Bma%5D/page.tsx): `src/app/giang-vien/lop/[ma]/page.tsx`
- [Form lớp và đợt](https://github.com/haodpsut/nop-bai-video/blob/main/src/components/form-lop.tsx): `src/components/form-lop.tsx`
- [Nạp danh sách](https://github.com/haodpsut/nop-bai-video/blob/main/src/components/form-danh-sach.tsx): `src/components/form-danh-sach.tsx`
- [Thao tác giảng viên](https://github.com/haodpsut/nop-bai-video/blob/main/src/app/giang-vien/hanh-dong.ts): `src/app/giang-vien/hanh-dong.ts`
- [Trang chấm đợt](https://github.com/haodpsut/nop-bai-video/blob/main/src/app/giang-vien/dot/%5Bid%5D/page.tsx): `src/app/giang-vien/dot/[id]/page.tsx`
- [Bảng chấm bài](https://github.com/haodpsut/nop-bai-video/blob/main/src/components/dong-cham.tsx): `src/components/dong-cham.tsx`
- [Xem video](https://github.com/haodpsut/nop-bai-video/blob/main/src/components/xem-video.tsx): `src/components/xem-video.tsx`

### Nghiệp vụ và dữ liệu

- [Đọc danh sách](https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/doc-danh-sach.ts): `src/lib/doc-danh-sach.ts`
- [Chuẩn hóa video](https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/link-video.ts): `src/lib/link-video.ts`
- [Hạn và thời gian](https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/thoi-gian.ts): `src/lib/thoi-gian.ts`
- [Truy vấn nghiệp vụ](https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/truy-van.ts): `src/lib/truy-van.ts`
- [Kiểu dữ liệu](https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/kieu.ts): `src/lib/kieu.ts`
- [Kết nối Supabase](https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- [Cơ sở dữ liệu](https://github.com/haodpsut/nop-bai-video/blob/main/supabase/migrations/20260905000100_khoi_tao.sql): `supabase/migrations/20260905000100_khoi_tao.sql`

### Xuất kết quả

- [API xuất Excel](https://github.com/haodpsut/nop-bai-video/blob/main/src/app/api/xuat-excel/route.ts): `src/app/api/xuat-excel/route.ts`
- [Tạo bảng Excel](https://github.com/haodpsut/nop-bai-video/blob/main/src/lib/excel.ts): `src/lib/excel.ts`

### Other components

- **Sinh viên**
- **Giảng viên**

## Connections

- Sinh viên → Trang sinh viên: mở trang (evidence: `README.md`)
- Trang sinh viên → Nhập mã SV: yêu cầu mã (evidence: `src/app/page.tsx`)
- Trang sinh viên → Truy vấn nghiệp vụ: đọc lớp và bài (evidence: `src/app/page.tsx`)
- Nhập mã SV → Xử lý sinh viên: gửi mã (evidence: `src/components/nhap-ma-sv.tsx`)
- Xử lý sinh viên → Truy vấn nghiệp vụ: tra sinh viên, đợt (evidence: `src/app/hanh-dong.ts`)
- Trang sinh viên → Ô nộp bài: hiển thị ô nộp (evidence: `src/app/page.tsx`)
- Ô nộp bài → Xử lý sinh viên: gửi bài (evidence: `src/components/o-nop-bai.tsx`)
- Xử lý sinh viên → Chuẩn hóa video: kiểm tra link (evidence: `src/app/hanh-dong.ts`)
- Xử lý sinh viên → Hạn và thời gian: kiểm hạn (evidence: `src/app/hanh-dong.ts`)
- Xử lý sinh viên → Kết nối Supabase: ghi bài, lịch sử (evidence: `src/app/hanh-dong.ts`)
- Giảng viên → Trang giảng viên: mở trang (evidence: `README.md`)
- Trang giảng viên → Đăng nhập GV: chưa đăng nhập (evidence: `src/app/giang-vien/page.tsx`)
- Đăng nhập GV → Thao tác giảng viên: gửi thông tin (evidence: `src/components/dang-nhap-gv.tsx`)
- Thao tác giảng viên → Phiên giảng viên: kiểm phiên (evidence: `src/app/giang-vien/hanh-dong.ts`)
- Trang giảng viên → Truy vấn nghiệp vụ: đọc thống kê lớp (evidence: `src/app/giang-vien/page.tsx`)
- Trang giảng viên → Form lớp và đợt: tạo lớp (evidence: `src/app/giang-vien/page.tsx`)
- Quản lý lớp → Nạp danh sách: hiển thị nhập danh sách (evidence: `src/app/giang-vien/lop/[ma]/page.tsx`)
- Quản lý lớp → Form lớp và đợt: hiển thị form đợt (evidence: `src/app/giang-vien/lop/[ma]/page.tsx`)
- Nạp danh sách → Thao tác giảng viên: gửi danh sách (evidence: `src/components/form-danh-sach.tsx`)
- Thao tác giảng viên → Đọc danh sách: đọc dữ liệu dán (evidence: `src/app/giang-vien/hanh-dong.ts`)
- Thao tác giảng viên → Kết nối Supabase: lưu lớp, danh sách, đợt (evidence: `src/app/giang-vien/hanh-dong.ts`)
- Trang chấm đợt → Bảng chấm bài: hiển thị bảng chấm (evidence: `src/app/giang-vien/dot/[id]/page.tsx`)
- Trang chấm đợt → Truy vấn nghiệp vụ: đọc bài và tiến độ (evidence: `src/app/giang-vien/dot/[id]/page.tsx`)
- Bảng chấm bài → Thao tác giảng viên: gửi kết quả chấm (evidence: `src/components/dong-cham.tsx`)
- Bảng chấm bài → Xem video: xem video (evidence: `src/components/dong-cham.tsx`)
- Xem video → Chuẩn hóa video: tạo link nhúng (evidence: `src/components/xem-video.tsx`)
- Truy vấn nghiệp vụ → Kết nối Supabase: truy vấn (evidence: `src/lib/truy-van.ts`)
- Kết nối Supabase → Cơ sở dữ liệu: đọc, ghi dữ liệu (evidence: `README.md`)
- Xử lý sinh viên → Truy vấn nghiệp vụ: kiểm ghi danh (evidence: `src/app/hanh-dong.ts`)
- API xuất Excel → Phiên giảng viên: xác thực phiên (evidence: `src/app/api/xuat-excel/route.ts`)
- API xuất Excel → Truy vấn nghiệp vụ: đọc dữ liệu đợt (evidence: `src/app/api/xuat-excel/route.ts`)
- API xuất Excel → Tạo bảng Excel: tạo tệp (evidence: `src/app/api/xuat-excel/route.ts`)
- Giảng viên → API xuất Excel: xuất đợt (evidence: `README.md`)
- Trang sinh viên → Hạn và thời gian: hiện thời hạn (evidence: `README.md`)
- Truy vấn nghiệp vụ → Kiểu dữ liệu: dùng kiểu miền (evidence: `src/lib/truy-van.ts`)
