# hafedefheij/registration-system-v3 architecture

> Architecture diagram of the GitHub repository hafedefheij/registration-system-v3, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hafedefheij/registration-system-v3
- Repository: https://github.com/hafedefheij/registration-system-v3

## Overview

##### Project type and purpose
- This is a full-stack web application: a university course registration system built with Node.js, Express, and SQLite.
- It provides a static frontend (HTML/JS/CSS) for two user roles—Admin and Student—and a RESTful API backend for authentication, data management, and business logic.

##### File structure
- Top-level directories:
- `.data` / `server` – SQLite database files and database initialization code (persistence layer).
- `public` – Static assets subdivided into `admin` UI pages, `student` UI pages, shared CSS, JS, images.
- Root scripts:
- `index.js` / `server/server.js` – Main entry points that configure Express, middleware (static serving, body parsing, authentication), and REST routes.
- Helper scripts like `check-db.js`, `read-users.js`, `update.js` – one-off maintenance or data-migration utilities.
- Config/build files:
- `package.json` / `package-lock.json` – Node dependencies and scripts.
- `sample.env` – Environment variables (e.g., `PORT`, database paths).

##### README for additional insights
- Key features: student course registration, admin CRUD for courses/students/departments, prerequisites, enrollment tracking.
- API endpoints: grouped under `/api/login`, `/api/admin/...`, `/api/student/...`.
- Database persistence: single SQLite instance stored in `.data` for production (Glitch) and `server` folder for local.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        AdminUI["Admin UI"]:::frontend
        StudentUI["Student UI"]:::frontend
        subgraph "Shared Static Assets"
            direction TB
            CSS["CSS Files"]:::frontend
            JS["JS Files"]:::frontend
            Images["Images"]:::frontend
            Landing["Landing Page (index.html)"]:::frontend
        end
    end

    %% Server Layer
    subgraph "Web Server Layer"
        direction TB
        ExpressServer["Express Server"]:::server
        subgraph "Modules"
            direction TB
            StaticServe["Static File Server"]:::server
            AuthModule["Authentication (/api/login)"]:::server
            AdminAPI["Admin API (/api/admin/*)"]:::server
            StudentAPI["Student API (/api/student/*)"]:::server
            DBInit["DB Initialization Module"]:::server
        end
        UtilityBox["Maintenance / Utility Scripts"]:::scripts
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        SQLiteDB["SQLite Database"]:::database
    end

    %% Connections
    AdminUI -->|"HTTP Requests"| StaticServe
    StudentUI -->|"HTTP Requests"| StaticServe
    Landing -->|"HTTP Requests"| StaticServe

    AdminUI -->|"API Calls"| AuthModule
    StudentUI -->|"API Calls"| AuthModule

    AuthModule -->|"Auth Middleware"| AdminAPI
    AuthModule -->|"Auth Middleware"| StudentAPI

    StaticServe -->|serves files| CSS
    StaticServe -->|serves files| JS
    StaticServe -->|serves files| Images
    StaticServe -->|serves files| Landing

    AdminAPI -->|SQL Queries| SQLiteDB
    StudentAPI -->|SQL Queries| SQLiteDB
    DBInit -->|Initialization Queries| SQLiteDB

    UtilityBox -->|Maintenance Operations| SQLiteDB

    %% Click Events - Client Layer
    click AdminUI "https://github.com/hafedefheij/registration-system-v3/tree/master/public/admin"
    click StudentUI "https://github.com/hafedefheij/registration-system-v3/tree/master/public/student"
    click CSS "https://github.com/hafedefheij/registration-system-v3/tree/master/public/css"
    click JS "https://github.com/hafedefheij/registration-system-v3/tree/master/public/js"
    click Images "https://github.com/hafedefheij/registration-system-v3/tree/master/public/images"
    click Landing "https://github.com/hafedefheij/registration-system-v3/blob/master/public/index.html"

    %% Click Events - Server Layer
    click ExpressServer "https://github.com/hafedefheij/registration-system-v3/blob/master/index.js"
    click ExpressServer "https://github.com/hafedefheij/registration-system-v3/blob/master/server/server.js"
    click DBInit "https://github.com/hafedefheij/registration-system-v3/blob/master/server/database.js"
    click AuthModule "https://github.com/hafedefheij/registration-system-v3/blob/master/server/server.js"
    click AdminAPI "https://github.com/hafedefheij/registration-system-v3/blob/master/server/server.js"
    click StudentAPI "https://github.com/hafedefheij/registration-system-v3/blob/master/server/server.js"

    click UtilityBox "https://github.com/hafedefheij/registration-system-v3/blob/master/check-db.js"
    click UtilityBox "https://github.com/hafedefheij/registration-system-v3/blob/master/check-max-limit.js"
    click UtilityBox "https://github.com/hafedefheij/registration-system-v3/blob/master/read-users.js"
    click UtilityBox "https://github.com/hafedefheij/registration-system-v3/blob/master/reset-enrollments.js"
    click UtilityBox "https://github.com/hafedefheij/registration-system-v3/blob/master/update.js"
    click UtilityBox "https://github.com/hafedefheij/registration-system-v3/blob/master/update-auto-logout.js"
    click UtilityBox "https://github.com/hafedefheij/registration-system-v3/blob/master/update-max-limit.js"

    %% Click Events - Data Layer
    click SQLiteDB "https://github.com/hafedefheij/registration-system-v3/blob/master/.data/university.db"
    click SQLiteDB "https://github.com/hafedefheij/registration-system-v3/blob/master/server/database.db"
    click SQLiteDB "https://github.com/hafedefheij/registration-system-v3/blob/master/server/university.db"

    %% Click Events - Config & Docs
    Config["Configuration & Dependencies"]:::config
    Docs["Project Documentation"]:::docs

    click Config "https://github.com/hafedefheij/registration-system-v3/blob/master/package.json"
    click Config "https://github.com/hafedefheij/registration-system-v3/blob/master/package-lock.json"
    click Config "https://github.com/hafedefheij/registration-system-v3/blob/master/sample.env"
    click Docs "https://github.com/hafedefheij/registration-system-v3/blob/master/README.md"
    click Docs "https://github.com/hafedefheij/registration-system-v3/blob/master/explain.md"

    Config --> ExpressServer
    Docs --> AdminUI

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#005B96,stroke-width:1px;
    classDef server fill:#DFF0D8,stroke:#3C763D,stroke-width:1px;
    classDef database fill:#FDEBD0,stroke:#D35400,stroke-width:1px,stroke-dasharray: 5 5;
    classDef scripts fill:#EEEEEE,stroke:#AAAAAA,stroke-width:1px;
    classDef config fill:#FCF8E3,stroke:#8A6D3B,stroke-width:1px;
    classDef docs fill:#F2DEDE,stroke:#A94442,stroke-width:1px;
```
