Django Backend Development & Design Documentation¶
Author: Zhenyu Yang yangzhenyu@sust.edu.cn, Sixu Wei reisa@sust.edu.cn
Last updated: Apr 24, 2026
This document serves as the unified entry point for the backend/ Django server implementation, consolidating system-level design, reading navigation, and app documentation indexes that were previously spread across backend.md and design.md.
Document Scope¶
This page answers “how is the system layered, how do business flows work, and where should I start reading the code.”
dev/backend/*.mdsub-pages answer “how is each app currently implemented.”api/*.mdanswers “how to call the APIs.”
Reading Order¶
Start with Architecture Overview to build a holistic understanding of configuration, routing, authentication, and cross-app dependencies.
Then read the system-level roles, flows, and module collaboration on this page.
Proceed to the app-specific documentation for each business module.
Finally, consult the corresponding API documentation for request/response details.
Core Roles¶
Admin-Side Roles¶
Role |
Identifier |
Primary Responsibilities |
|---|---|---|
Super Admin |
|
Global configuration, account roles, classroom management, final approval, signage management |
Academic Secretary |
|
First review of teaching activities, course import, classroom info maintenance, user status maintenance |
Office Assistant |
|
Second review of reservations, repair ticket handling, check-in management, course/reservation rescheduling |
Counselor |
|
First review of student activities, partial repair ticket viewing and handling |
User-Side Roles¶
Role |
Identifier |
Primary Responsibilities |
|---|---|---|
Chinese Teacher |
|
Apply for reservations, view courses, create check-in sessions |
Foreign Teacher |
|
Register account, apply for reservations, view courses, create check-in sessions |
Student |
|
View personal course check-ins, submit reservation applications, report repairs, report violations |
Module Collaboration¶
accounts
├─ Provides users, roles, login, two-factor authentication
├─ Provides authentication for all business endpoints
└─ Provides current_role as a runtime context
courses
├─ Generates CourseOccurrence as the factual class record
├─ Provides time-slot basis for classrooms/signage/borrowings/checkins
└─ Depends on common.SystemConfig for seasonal schedules
classrooms
├─ Maintains classroom master data
└─ Aggregates courses and reservations into classroom schedules
borrowings
├─ Depends on classrooms as the resource object
├─ Depends on courses for conflict validation
└─ Depends on accounts.current_role for approval routing
checkins
└─ Depends on CourseOccurrence to create check-in sessions
signage
├─ Binds one-to-one with classrooms via devices
└─ Depends on courses to render display schedules
Key Flows¶
Reservation Approval¶
A user submits a reservation application based on their role and activity type.
The system validates the time window, capacity, and conflicts first.
First review is routed to
counselororsecretarybased on activity type.After first review approval, the request moves to second review by
assistant.The reservation takes effect after second review approval;
superadmincan directly grant final approval.
Courses & Classroom Occupancy¶
An admin imports the course schedule; the system generates
CourseandCourseOccurrencerecords.Classroom schedules and free classroom queries are both derived from
CourseOccurrenceoverlaid with manual reservations.Signage display also reads course instances directly, rather than maintaining a separate schedule.
Check-ins¶
A teacher or check-in admin creates a
CheckinSessionbased on aCourseOccurrence.The system automatically transitions session status based on the class period and current time.
Teachers manually maintain
CheckinRecordentries through the roster.
Signage Activation¶
An admin issues a one-time activation code for a classroom.
The device scans the code and calls the activation endpoint to exchange it for a long-lived device token.
The device subsequently uses only the device token to fetch classroom info and course schedules.
Documentation Index¶
- Backend Architecture Overview
accountsAccounts & AuthenticationclassroomsClassroom ManagementsignageSignage DevicescoursesCourses & Seasonal SchedulescheckinsClass Check-insborrowingsClassroom Reservations & ApprovalrepairsRepair TicketsabuseViolation ReportslogsOperation Logscommon& Shared Services
Module Map¶
Module |
Code Entry |
Description |
API Docs |
|---|---|---|---|
|
|
Accounts, login, roles, TOTP, WebAuthn, WeChat binding |
|
|
|
Classroom master data, free classrooms, classroom schedule, classroom import |
|
|
|
Signage device activation, device authentication, signage config, signage schedule |
|
|
|
Course master records, class occurrences, import/export, rescheduling, seasonal schedules |
|
|
|
Check-in sessions, check-in records, roster, manual check-in |
|
|
|
Classroom reservation applications, two-level approval, course-reservation rescheduling |
|
|
|
Repair tickets, emergency repairs, status transitions |
|
|
|
Violation report submission and handling |
|
|
|
Operation log queries and export |
|
|
|
System config, uploads, pagination, middleware, shared services |
Maintenance Principles¶
Code is the source of truth; historical requirement tables are not reproduced here.
Business rules should live on their respective app pages; cross-module constraints belong in Architecture Overview.
Request parameters, response examples, and error codes are documented in the API docs; this page only covers implementation and maintenance highlights.