# knightfury-v/student_course_hub architecture

> Architecture diagram of the GitHub repository knightfury-v/student_course_hub, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/knightfury-v/student_course_hub
- Repository: https://github.com/knightfury-v/student_course_hub

## Overview

##### Project type and purpose
- This is a classic full-stack, LAMP-style web application (“Student Course Hub”) written in PHP.
- It exposes three user interfaces:
- Public/student UI (browsing programs/modules, search, register/withdraw interest)
- Admin panel (CRUD for programs/modules, user management, export student data)
- Staff panel (view programs/modules they lead).
- Backed by a MySQL database (created via student_course_hub.sql), uses CSS for styling and file-system images.

##### High-level architecture components
a. Client tier (browser)
- Public pages (index.php, module.php, program.php, search.php, register_interest.php, withdraw_interest.php)
- Admin UI (all files under /admin/*.php)
- Staff UI (staff_dashboard, staff_login/logout under /admin/)
- Static assets (CSS under /css, images under /images).
b. Web server & application tier
- Apache or Nginx + PHP
- includes/db_connect.php (DB connection)
- includes/functions.php (input sanitization, helper functions)
c. Data tier
- MySQL database (tables: programs, modules, students_interests, admin_users, staff_users, etc.)

##### Interactions and data flow
- Browser sends HTTP(S) requests to PHP scripts.
- PHP scripts in /root or /admin invoke includes/functions.php to validate/sanitize input, then call DB via includes/db_connect.php.
- Queries go to MySQL; results rendered as HTML + CSS.
- For AJAX or REST calls (if any), same PHP endpoints handle JSON responses.

##### Architectural patterns & principles
- Layered architecture (Presentation → Application/Business logic → Data)
- Separation of concerns:
- Public vs Admin vs Staff modules in separate folders
- Shared logic and DB connectivity centralized in /includes
- Static assets under /css and /images
- Basic security patterns: input sanitization, credential checks, session handling in login scripts.

##### Summary
- Break the server layer into three bounded contexts (Public, Admin, Staff) plus shared libraries.
- Static assets as a separate component.
- Data flows and technology stacks.
- Provide enough detail to see both high-level structure and the key subsystems.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Tier
    Browser["Client Browser"]:::presentation

    %% Web Server & Application Tier
    subgraph "Web Server & Application Tier"
        direction TB
        subgraph "Public Frontend Scripts"
            direction TB
            Index["index.php"]:::presentation
            Module["module.php"]:::presentation
            Program["program.php"]:::presentation
            Search["search.php"]:::presentation
            Register["register_interest.php"]:::presentation
            Withdraw["withdraw_interest.php"]:::presentation
        end
        subgraph "Admin Backend Scripts"
            direction TB
            AIndex["admin/index.php"]:::presentation
            ALogin["admin/login.php"]:::presentation
            ALogout["admin/logout.php"]:::presentation
            AAllLogin["admin/alllogin.php"]:::presentation
            AddProg["admin/add_program.php"]:::presentation
            EditProg["admin/edit_program.php"]:::presentation
            DelProg["admin/delete_program.php"]:::presentation
            Progs["admin/programs.php"]:::presentation
            AddMod["admin/add_module.php"]:::presentation
            EditMod["admin/edit_module.php"]:::presentation
            DelMod["admin/delete_module.php"]:::presentation
            Mods["admin/modules.php"]:::presentation
            Students["admin/students.php"]:::presentation
            DelStud["admin/delete_student.php"]:::presentation
            CAdmin["admin/create_admin.php"]:::presentation
            CStaff["admin/create_staff.php"]:::presentation
            CSuper["admin/create_superuser.php"]:::presentation
            ChPass["admin/change_password.php"]:::presentation
            ProcChPass["admin/process_change_password.php"]:::presentation
            ChPassStaff["admin/change_password_staff.php"]:::presentation
            ProcChPassStaff["admin/process_change_password_staff.php"]:::presentation
            ProcCStaff["admin/process_create_staff.php"]:::presentation
            ExportStud["admin/export_students.php"]:::presentation
        end
        subgraph "Staff Backend Scripts"
            direction TB
            StaffLogin["admin/staff_login.php"]:::presentation
            StaffLogout["admin/staff_logout.php"]:::presentation
            StaffDash["admin/staff_dashboard.php"]:::presentation
        end
        subgraph "Shared Includes"
            direction TB
            DBConnect["includes/db_connect.php"]:::application
            Functions["includes/functions.php"]:::application
        end
        subgraph "Static Assets"
            direction TB
            CSS["CSS Files"]:::presentation
            Images["Images"]:::presentation
        end
    end

    %% Data Tier
    MySQL[(MySQL Database)]:::data
    Script["student_course_hub.sql"]:::data

    %% Relationships
    Browser -->|HTTP Requests| Index
    Browser -->|HTTP Requests| AIndex
    Browser -->|HTTP Requests| StaffLogin
    Browser -->|Fetch Assets| CSS
    Browser -->|Fetch Assets| Images

    Index -->|includes| Functions
    Module -->|includes| Functions
    Program -->|includes| Functions
    Search -->|includes| Functions
    Register -->|includes| Functions
    Withdraw -->|includes| Functions

    AIndex -->|includes| Functions
    ALogin -->|includes| Functions
    ALogout -->|includes| Functions
    AAllLogin -->|includes| Functions
    AddProg -->|includes| Functions
    EditProg -->|includes| Functions
    DelProg -->|includes| Functions
    Progs -->|includes| Functions
    AddMod -->|includes| Functions
    EditMod -->|includes| Functions
    DelMod -->|includes| Functions
    Mods -->|includes| Functions
    Students -->|includes| Functions
    DelStud -->|includes| Functions
    CAdmin -->|includes| Functions
    CStaff -->|includes| Functions
    CSuper -->|includes| Functions
    ChPass -->|includes| Functions
    ProcChPass -->|includes| Functions
    ChPassStaff -->|includes| Functions
    ProcChPassStaff -->|includes| Functions
    ProcCStaff -->|includes| Functions
    ExportStud -->|includes| Functions

    StaffLogin -->|includes| Functions
    StaffLogout -->|includes| Functions
    StaffDash -->|includes| Functions

    Functions -->|DB Connect| DBConnect
    DBConnect -->|Query| MySQL
    MySQL -->|Result| Functions
    Functions -->|Response| Index
    Functions -->|Response| AIndex
    Functions -->|Response| StaffDash

    Script -->|Deployment Artifact| MySQL

    %% Click Events
    click Index "https://github.com/knightfury-v/student_course_hub/blob/main/index.php"
    click Module "https://github.com/knightfury-v/student_course_hub/blob/main/module.php"
    click Program "https://github.com/knightfury-v/student_course_hub/blob/main/program.php"
    click Search "https://github.com/knightfury-v/student_course_hub/blob/main/search.php"
    click Register "https://github.com/knightfury-v/student_course_hub/blob/main/register_interest.php"
    click Withdraw "https://github.com/knightfury-v/student_course_hub/blob/main/withdraw_interest.php"
    click AIndex "https://github.com/knightfury-v/student_course_hub/blob/main/admin/index.php"
    click ALogin "https://github.com/knightfury-v/student_course_hub/blob/main/admin/login.php"
    click ALogout "https://github.com/knightfury-v/student_course_hub/blob/main/admin/logout.php"
    click AAllLogin "https://github.com/knightfury-v/student_course_hub/blob/main/admin/alllogin.php"
    click AddProg "https://github.com/knightfury-v/student_course_hub/blob/main/admin/add_program.php"
    click EditProg "https://github.com/knightfury-v/student_course_hub/blob/main/admin/edit_program.php"
    click DelProg "https://github.com/knightfury-v/student_course_hub/blob/main/admin/delete_program.php"
    click Progs "https://github.com/knightfury-v/student_course_hub/blob/main/admin/programs.php"
    click AddMod "https://github.com/knightfury-v/student_course_hub/blob/main/admin/add_module.php"
    click EditMod "https://github.com/knightfury-v/student_course_hub/blob/main/admin/edit_module.php"
    click DelMod "https://github.com/knightfury-v/student_course_hub/blob/main/admin/delete_module.php"
    click Mods "https://github.com/knightfury-v/student_course_hub/blob/main/admin/modules.php"
    click Students "https://github.com/knightfury-v/student_course_hub/blob/main/admin/students.php"
    click DelStud "https://github.com/knightfury-v/student_course_hub/blob/main/admin/delete_student.php"
    click CAdmin "https://github.com/knightfury-v/student_course_hub/blob/main/admin/create_admin.php"
    click CStaff "https://github.com/knightfury-v/student_course_hub/blob/main/admin/create_staff.php"
    click CSuper "https://github.com/knightfury-v/student_course_hub/blob/main/admin/create_superuser.php"
    click ChPass "https://github.com/knightfury-v/student_course_hub/blob/main/admin/change_password.php"
    click ProcChPass "https://github.com/knightfury-v/student_course_hub/blob/main/admin/process_change_password.php"
    click ChPassStaff "https://github.com/knightfury-v/student_course_hub/blob/main/admin/change_password_staff.php"
    click ProcChPassStaff "https://github.com/knightfury-v/student_course_hub/blob/main/admin/process_change_password_staff.php"
    click ProcCStaff "https://github.com/knightfury-v/student_course_hub/blob/main/admin/process_create_staff.php"
    click ExportStud "https://github.com/knightfury-v/student_course_hub/blob/main/admin/export_students.php"
    click StaffLogin "https://github.com/knightfury-v/student_course_hub/blob/main/admin/staff_login.php"
    click StaffLogout "https://github.com/knightfury-v/student_course_hub/blob/main/admin/staff_logout.php"
    click StaffDash "https://github.com/knightfury-v/student_course_hub/blob/main/admin/staff_dashboard.php"
    click DBConnect "https://github.com/knightfury-v/student_course_hub/blob/main/includes/db_connect.php"
    click Functions "https://github.com/knightfury-v/student_course_hub/blob/main/includes/functions.php"
    click CSS "https://github.com/knightfury-v/student_course_hub/tree/main/css/"
    click Images "https://github.com/knightfury-v/student_course_hub/tree/main/images/"
    click Script "https://github.com/knightfury-v/student_course_hub/blob/main/student_course_hub.sql"

    %% Styles
    classDef presentation fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef application fill:#90EE90,stroke:#333,stroke-width:1px
    classDef data fill:#FFA500,stroke:#333,stroke-width:1px
```
