# shawongazi7/leading-university-student-management-system architecture

> Architecture diagram of the GitHub repository shawongazi7/leading-university-student-management-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shawongazi7/leading-university-student-management-system
- Repository: https://github.com/shawongazi7/leading-university-student-management-system

## Overview

1. **Overall shape**
   - This is a server-rendered Node.js university portal, built around Express + EJS + MySQL.
   - The application is organized as a classic layered monolith: `app.js` wires middleware and routes, `routes/` handles HTTP boundaries, `models/` encapsulates database access, and `views/` renders role-specific pages.

2. **Entry point and composition root**
   - `app.js` is the central bootstrap file. It likely initializes Express, configures sessions/security/logging, mounts route modules, serves static assets from `public/`, and connects to the database on startup.
   - `config.js` and `config/database.js` provide shared configuration, while `init-db.js` and the scripts suggest startup-time table creation and demo data seeding.

3. **Primary runtime and delivery model**
   - The system is not a SPA or API-first app; it delivers HTML directly from EJS templates.
   - Browser requests flow into Express routes, which query/update MySQL through models and then return server-rendered pages.
   - Frontend behavior is limited to small enhancements in `public/js/app.js` and styling in `public/css/style.css`.

4. **Authentication and access control boundary**
   - Authentication is session-based via `express-session`, with `middleware/auth.js` enforcing protected routes and role checks.
   - The auth subsystem supports login, registration, logout, profile access, password reset, and email verification.
   - JWT is used only for stateless email links; normal user state is maintained in the server session.

5. **Role-based application split**
   - There are two main authenticated experiences: `views/student/*` for students and `views/admin/*` for administrators.
   - Route modules mirror this split: `routes/student.js` and `routes/admin.js` are the main role-specific boundaries.
   - Students can view dashboards, results, tuition, clubs, events, and transcripts; admins manage data and reports from a dashboard-centric interface.

6. **Domain modules and data ownership**
   - `models/User.js` owns accounts, identity, and profile-related data.
   - `models/Result.js` handles academic results and transcript-related summaries.
   - `models/Club.js` manages clubs and membership data.
   - `models/Event.js` covers event publishing, registration, attendance, and feedback.
   - `models/Payment.js` stores manual payment metadata for paid event registrations.
   - `models/TuitionFee.js` represents tuition tracking.
   - `models/Settings.js` appears to hold app-level configuration persisted in the database.
   - `models/Settings.js` plus `config/` indicate that some operational behavior is configurable through data as well as environment variables.

7. **Public, student, and admin page topology**
   - `views/public/*` exposes read-only club and event browsing to anonymous users.
   - `views/auth/*` contains login/register/reset/profile flows.
   - `views/student/*` contains student dashboard, transcript, results, tuition, and participation pages.
   - `views/admin/*` contains CRUD and reporting screens for students, clubs, events, results, tuition, settings, and uploads.
   - Shared layout and navigation live in `views/layout.ejs` and `views/partials/*`, indicating a template-driven shell with role-specific sidebars.

8. **Data flow for academic and club/event workflows**
   - Admins create or import core records through admin forms and bulk workflows.
   - Those actions persist into MySQL through model methods, then surface in public/student views via separate read routes.
   - Student-facing pages are largely derived views over the same underlying records, especially for results, club membership, and event participation.

9. **Payment and registration flow**
   - Event payments are deliberately manual, not integrated with a gateway.
   - For paid events, a student registration can begin in a pending state, then a `Payment` record stores transaction ID, payment method, status, and payment date.
   - This is a distinct subsystem from tuition tracking: event payments are transactional metadata, while tuition has its own admin-managed record model and student summary page.

10. **Database and environment boundary**
   - The README states the active database path is MySQL via `config/database.js`, even though `config/database-sqlite.js` exists as an alternate configuration artifact.
   - `.env.example` shows the app depends on environment variables for server port, session secret, DB credentials, JWT secret, and optional email credentials.
   - On startup, the system appears to auto-create tables and seed demo accounts/data, which makes local setup self-contained.

11. **File handling and assets**
   - `multer`-style upload handling is implied by the presence of `public/uploads/`, `uploads/`, and admin upload screens such as result import/upload pages.
   - The repository also contains CSV-oriented admin workflows and scripts, so bulk import/export is a notable data ingestion path.
   - Static assets are isolated under `public/`, keeping uploaded media and frontend assets separate from server code.

12. **Operational scripts and validation utilities**
   - The `scripts/` folder contains non-user-facing tooling for seeding, inspecting the database, smoke-checking routes, fixing branding, and testing functionality.
   - These scripts act as maintenance and verification entry points around the main app, suggesting the repo is intended for demo/local administration as much as day-to-day use.
   - Together, they reinforce that the core architecture is a single deployable web app with supporting lifecycle utilities rather than a distributed service system.

Main entry points: [`routes/admin.js`](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/routes/admin.js) (Admin routes), [`app.js`](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/app.js) (app.js), [`routes/student.js`](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/routes/student.js) (Student routes), [`routes/public.js`](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/routes/public.js) (Public routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_core["Core runtime"]
  node_app_js["app.js<br/>Express bootstrap<br/>[app.js]"]
  node_config_js["Config<br/>[config.js]"]
  node_db_config[("DB config<br/>MySQL setup<br/>[database.js]")]
  node_auth_mw["Auth guard<br/>Middleware<br/>[auth.js]"]
  node_routes_auth["Auth routes<br/>HTTP auth<br/>[auth.js]"]
  node_routes_public["Public routes<br/>Read-only HTTP<br/>[public.js]"]
  node_routes_student["Student routes<br/>Student HTTP<br/>[student.js]"]
  node_routes_admin["Admin routes<br/>Admin HTTP<br/>[admin.js]"]
  node_routes_club["Club routes<br/>Club HTTP<br/>[club.js]"]
end

subgraph group_group_domain["Domain models"]
  node_user_model[("Users<br/>Account model<br/>[User.js]")]
  node_result_model[("Results<br/>Academic model<br/>[Result.js]")]
  node_club_model[("Clubs<br/>Membership model<br/>[Club.js]")]
  node_event_model[("Events<br/>Event model<br/>[Event.js]")]
  node_payment_model[("Payments<br/>Manual payment model<br/>[Payment.js]")]
  node_tuition_model[("Tuition<br/>[TuitionFee.js]")]
  node_settings_model[("Settings<br/>Config model<br/>[Settings.js]")]
end

subgraph group_group_views["Server views"]
  node_views_layout["Layout shell<br/>EJS layout<br/>[layout.ejs]"]
  node_views_auth["Auth pages<br/>EJS pages<br/>[login.ejs]"]
  node_views_student["Student pages<br/>EJS pages<br/>[dashboard.ejs]"]
  node_views_admin["Admin pages<br/>EJS pages<br/>[dashboard.ejs]"]
  node_views_public["Public pages<br/>EJS pages<br/>[clubs.ejs]"]
end

subgraph group_group_ops["Ops and tooling"]
  node_init_db["Init DB<br/>Setup script<br/>[init-db.js]"]
  node_seed_demo["Seed demo<br/>Maintenance script<br/>[seed-demo.js]"]
end

node_app_js -->|"loads"| node_config_js
node_app_js -->|"connects"| node_db_config
node_app_js -->|"applies"| node_auth_mw
node_app_js -->|"mounts"| node_routes_auth
node_app_js -->|"mounts"| node_routes_public
node_app_js -->|"mounts"| node_routes_student
node_app_js -->|"mounts"| node_routes_admin
node_app_js -->|"mounts"| node_routes_club
node_app_js -.->|"initializes"| node_init_db
node_init_db -.->|"seeds"| node_seed_demo
node_routes_auth -->|"reads/writes"| node_user_model
node_routes_student -->|"reads"| node_user_model
node_routes_student -->|"reads"| node_result_model
node_routes_student -->|"reads"| node_club_model
node_routes_student -->|"reads/writes"| node_event_model
node_routes_student -->|"reads"| node_tuition_model
node_routes_admin -->|"reads/writes"| node_user_model
node_routes_admin -->|"reads/writes"| node_club_model
node_routes_admin -->|"reads/writes"| node_event_model
node_routes_admin -->|"reads/writes"| node_result_model
node_routes_admin -->|"reads/writes"| node_payment_model
node_routes_admin -->|"reads/writes"| node_tuition_model
node_routes_admin -->|"reads/writes"| node_settings_model
node_routes_public -->|"reads"| node_club_model
node_routes_public -->|"reads"| node_event_model
node_routes_club -->|"reads/writes"| node_club_model
node_routes_auth -->|"renders"| node_views_auth
node_routes_public -->|"renders"| node_views_public
node_routes_student -->|"renders"| node_views_student
node_routes_admin -->|"renders"| node_views_admin
node_routes_student -->|"uses"| node_views_layout
node_routes_admin -->|"uses"| node_views_layout
node_routes_public -->|"uses"| node_views_layout

click node_app_js "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/app.js"
click node_config_js "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/config.js"
click node_db_config "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/config/database.js"
click node_auth_mw "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/middleware/auth.js"
click node_routes_auth "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/routes/auth.js"
click node_routes_public "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/routes/public.js"
click node_routes_student "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/routes/student.js"
click node_routes_admin "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/routes/admin.js"
click node_routes_club "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/routes/club.js"
click node_user_model "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/models/User.js"
click node_result_model "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/models/Result.js"
click node_club_model "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/models/Club.js"
click node_event_model "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/models/Event.js"
click node_payment_model "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/models/Payment.js"
click node_tuition_model "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/models/TuitionFee.js"
click node_settings_model "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/models/Settings.js"
click node_init_db "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/init-db.js"
click node_seed_demo "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/scripts/seed-demo.js"
click node_views_layout "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/views/layout.ejs"
click node_views_auth "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/views/auth/login.ejs"
click node_views_student "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/views/student/dashboard.ejs"
click node_views_admin "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/views/admin/dashboard.ejs"
click node_views_public "https://github.com/shawongazi7/leading-university-student-management-system/blob/main/views/public/clubs.ejs"

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_app_js,node_config_js,node_db_config,node_auth_mw,node_routes_auth,node_routes_public,node_routes_student,node_routes_admin,node_routes_club toneBlue
class node_user_model,node_result_model,node_club_model,node_event_model,node_payment_model,node_tuition_model,node_settings_model toneAmber
class node_views_layout,node_views_auth,node_views_student,node_views_admin,node_views_public toneMint
class node_init_db,node_seed_demo toneRose
```

## Components

### Core runtime

Bootstrap, configuration, middleware, and HTTP routing for the monolith.

- [app.js](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/app.js): Express bootstrap · Composition root that wires middleware, sessions, static assets, routes, and startup behavior. · `app.js`
- [Config](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/config.js): Runtime config · Shared application configuration used by the server and subsystems. · `config.js`
- [DB config](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/config/database.js): MySQL setup · Primary database connection settings for the active MySQL runtime. · `config/database.js`
- [Auth guard](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/middleware/auth.js): Middleware · Session and role-based access control for protected routes. · `middleware/auth.js`
- [Auth routes](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/routes/auth.js): HTTP auth · Login, registration, logout, profile, and password reset boundaries. · `routes/auth.js`
- [Public routes](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/routes/public.js): Read-only HTTP · Anonymous browsing for clubs and events. · `routes/public.js`
- [Student routes](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/routes/student.js): Student HTTP · Authenticated student pages for academic and participation workflows. · `routes/student.js`
- [Admin routes](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/routes/admin.js): Admin HTTP · Administrative CRUD, reporting, import, and settings pages. · `routes/admin.js`
- [Club routes](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/routes/club.js): Club HTTP · Club-specific boundaries shared across public, student, and admin flows. · `routes/club.js`

### Domain models

MySQL-backed data access and business entities.

- [Users](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/models/User.js): Account model · Accounts, identity, profiles, and access-related data. · `models/User.js`
- [Results](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/models/Result.js): Academic model · Academic results and transcript summaries. · `models/Result.js`
- [Clubs](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/models/Club.js): Membership model · Clubs and membership relationships. · `models/Club.js`
- [Events](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/models/Event.js): Event model · Event publishing, registration, attendance, and feedback. · `models/Event.js`
- [Payments](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/models/Payment.js): Manual payment model · Metadata for paid event registrations and payment tracking. · `models/Payment.js`
- [Tuition](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/models/TuitionFee.js): Tuition model · Tuition fee tracking and student summaries. · `models/TuitionFee.js`
- [Settings](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/models/Settings.js): Config model · Persisted application settings that complement environment configuration. · `models/Settings.js`

### Server views

EJS templates for public, auth, student, and admin experiences.

- [Layout shell](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/views/layout.ejs): EJS layout · Shared template shell and navigation structure for the app. · `views/layout.ejs`
- [Auth pages](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/views/auth/login.ejs): EJS pages · Login, registration, reset, and profile screens. · `views/auth/login.ejs`
- [Student pages](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/views/student/dashboard.ejs): EJS pages · Dashboard, results, transcript, tuition, clubs, and events pages for students. · `views/student/dashboard.ejs`
- [Admin pages](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/views/admin/dashboard.ejs): EJS pages · Administrative dashboards, CRUD forms, imports, reports, and settings. · `views/admin/dashboard.ejs`
- [Public pages](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/views/public/clubs.ejs): EJS pages · Anonymous club and event browsing pages. · `views/public/clubs.ejs`

### Ops and tooling

Database initialization, seeding, and maintenance scripts.

- [Init DB](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/init-db.js): Setup script · Startup-time table creation and baseline database initialization. · `init-db.js`
- [Seed demo](https://github.com/shawongazi7/leading-university-student-management-system/blob/main/scripts/seed-demo.js): Maintenance script · Demo data and account seeding for local setup. · `scripts/seed-demo.js`

## Connections

- app.js → Config: loads · Bootstraps shared runtime settings.
- app.js → DB config: connects · Uses the active MySQL database configuration.
- app.js → Auth guard: applies · Installs session and role checks before protected handlers.
- app.js → Auth routes: mounts · Registers authentication boundaries.
- app.js → Public routes: mounts · Registers anonymous read-only pages.
- app.js → Student routes: mounts · Registers the student experience.
- app.js → Admin routes: mounts · Registers the admin experience.
- app.js → Club routes: mounts · Registers club-related route handling.
- app.js → Init DB: initializes · Runs startup database setup behavior.
- Init DB → Seed demo: seeds · Populates demo data and accounts when needed.
- Auth routes → Users: reads/writes · Creates and authenticates account records.
- Student routes → Users: reads · Loads student identity and profile data.
- Student routes → Results: reads · Builds results and transcript views.
- Student routes → Clubs: reads · Shows memberships and club participation.
- Student routes → Events: reads/writes · Displays events and handles registrations.
- Student routes → Tuition: reads · Displays tuition summaries.
- Admin routes → Users: reads/writes · Manages students and account data.
- Admin routes → Clubs: reads/writes · Manages clubs and memberships.
- Admin routes → Events: reads/writes · Manages events and attendance.
- Admin routes → Results: reads/writes · Imports and reports academic results.
- Admin routes → Payments: reads/writes · Tracks manual event payment metadata.
- Admin routes → Tuition: reads/writes · Manages tuition records.
- Admin routes → Settings: reads/writes · Persists app settings from the admin area.
- Public routes → Clubs: reads · Lists clubs and club details.
- Public routes → Events: reads · Lists public events and event details.
- Club routes → Clubs: reads/writes · Shared club domain boundary.
- Auth routes → Auth pages: renders · Serves auth-related templates.
- Public routes → Public pages: renders · Serves public browsing pages.
- Student routes → Student pages: renders · Serves student-facing pages.
- Admin routes → Admin pages: renders · Serves admin pages and reports.
- Student routes → Layout shell: uses · Composes pages within the shared template shell.
- Admin routes → Layout shell: uses · Composes admin pages within the shared shell.
- Public routes → Layout shell: uses · Composes public pages within the shared shell.
