# webdev4001/slc-web architecture

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

- Interactive diagram: https://gitdiagram.com/webdev4001/slc-web
- Repository: https://github.com/webdev4001/slc-web

## Overview

##### Project type and purpose
- This is a full-stack web application for the Student Learning Centre (SLC) at MMMUT.
- Frontend: Static HTML/CSS/JS pages (responsive UI built with Tailwind CSS and vanilla JS).
- Backend: Node.js/Express service with authentication & admin routes (currently minimal, ready for API integration).
- Future: A data store (e.g., MongoDB) and AI chatbot integration.

##### File structure
- Public/
- HTML files (index.html, library.html, engage.html, council.html, path.html)
- CSS folder (“style.css” compiled by Tailwind)
- JS folder (main.js, forms.js, chatbot.js, chat-logic)
- Images
- backend/
- server.js (Express app entry point)
- middleware (verifyToken.js, checkRole.js)
- routes (auth.js, admin.js)
- models (User.js)
- src/input.css (Tailwind directives)
- Config files: tailwind.config.js, postcss.config.js, package.json

##### README for additional insights
- Frontend built for responsive, interactive pages and forms
- Chatbot front-end stub pending real AI integration
- Backend scaffolding for token verification, role-based access
- Future enhancements: DB integration, full CRUD APIs, real chatbot service

##### Main components & interactions
a. Frontend (Browser)
- Static assets served: HTML, Tailwind CSS, JS modules
- User interaction flows:
- Navigation & page rendering
- Form submissions (book suggestion, join, feedback)
- Chat interface (PATH chatbot)
b. Static File Server / CDN
- Serves Public/ assets (could be Express static or external CDN)
c. Backend API (Express)
- Endpoints:
- /auth → login/signup, JWT issuance
- /admin → protected routes (middleware: verifyToken, checkRole)
- Business logic and model interactions
d. Data Layer (future)
- MongoDB (or SQL) storing users, suggestions, applications, feedback, event data
e. External Services
- Google Fonts
- AI Chatbot Service (Dialogflow, custom LLM API)

##### Architectural patterns & design principles
- MVC-ish separation:
- Models in backend/models
- Controllers in backend/routes
- Views = static HTML + JS on client
- Middleware pipeline for auth and role checks
- Client-Server separation with a RESTful API boundary
- Utility-first CSS (Tailwind) for styling consistency

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Side Components
    subgraph "Client Side"
        direction TB
        Browser["User Browser"]:::frontend
        subgraph "Static Assets (Public)"
            direction TB
            IndexHTML["index.html"]:::frontend
            LibraryHTML["library.html"]:::frontend
            EngageHTML["engage.html"]:::frontend
            CouncilHTML["council.html"]:::frontend
            PathHTML["path.html"]:::frontend
            StyleCSS["style.css"]:::frontend
            MainJS["main.js"]:::frontend
            FormsJS["forms.js"]:::frontend
            ChatbotJS["chatbot.js"]:::frontend
        end
    end

    %% Static File Server
    StaticServer["Static File Server / CDN"]:::backend

    %% Backend API
    subgraph "Backend API (Node.js / Express)"
        direction TB
        Server["server.js"]:::backend
        subgraph Middleware
            direction TB
            Verify["verifyToken.js"]:::middleware
            CheckRole["checkRole.js"]:::middleware
        end
        subgraph Routes
            direction TB
            AuthRoute["auth.js"]:::backend
            AdminRoute["admin.js"]:::backend
        end
        UserModel["User.js"]:::model
    end

    %% Future Data Layer
    Database["MongoDB (planned)"]:::db

    %% External Services
    subgraph "External Services"
        direction TB
        GoogleFonts["Google Fonts"]:::external
        AIService["AI Chatbot Service"]:::external
    end

    %% Data Flows
    Browser -->|Requests HTML/CSS/JS| StaticServer
    StaticServer -->|Serves assets| IndexHTML
    StaticServer --> StyleCSS
    StaticServer --> MainJS
    StaticServer --> FormsJS
    StaticServer --> ChatbotJS

    Browser -->|Navigates & submits forms| AuthRoute
    Browser -->|Accesses admin routes| AdminRoute

    AuthRoute --> Verify
    AdminRoute --> Verify
    Verify --> CheckRole
    CheckRole --> Server

    Server --> UserModel
    UserModel --> Database

    ChatbotJS -->|Fetches fonts| GoogleFonts
    ChatbotJS -->|Chats via API| AIService

    %% Click Events
    click IndexHTML "https://github.com/webdev4001/slc-web/blob/jules_wip_47597029633551261/Public/index.html"
    click LibraryHTML "https://github.com/webdev4001/slc-web/blob/jules_wip_47597029633551261/Public/library.html"
    click EngageHTML "https://github.com/webdev4001/slc-web/blob/jules_wip_47597029633551261/Public/engage.html"
    click CouncilHTML "https://github.com/webdev4001/slc-web/blob/jules_wip_47597029633551261/Public/council.html"
    click PathHTML "https://github.com/webdev4001/slc-web/blob/jules_wip_47597029633551261/Public/path.html"
    click StyleCSS "https://github.com/webdev4001/slc-web/blob/jules_wip_47597029633551261/Public/css/style.css"
    click MainJS "https://github.com/webdev4001/slc-web/blob/jules_wip_47597029633551261/Public/js/main.js"
    click FormsJS "https://github.com/webdev4001/slc-web/blob/jules_wip_47597029633551261/Public/js/forms.js"
    click ChatbotJS "https://github.com/webdev4001/slc-web/blob/jules_wip_47597029633551261/Public/js/chatbot.js"
    click Server "https://github.com/webdev4001/slc-web/blob/jules_wip_47597029633551261/backend/server.js"
    click AuthRoute "https://github.com/webdev4001/slc-web/blob/jules_wip_47597029633551261/backend/routes/auth.js"
    click AdminRoute "https://github.com/webdev4001/slc-web/blob/jules_wip_47597029633551261/backend/routes/admin.js"
    click Verify "https://github.com/webdev4001/slc-web/blob/jules_wip_47597029633551261/backend/middleware/verifyToken.js"
    click CheckRole "https://github.com/webdev4001/slc-web/blob/jules_wip_47597029633551261/backend/middleware/checkRole.js"
    click UserModel "https://github.com/webdev4001/slc-web/blob/jules_wip_47597029633551261/backend/models/User.js"

    %% Styles
    classDef frontend fill:#cfe2f3,stroke:#084b8a,color:#084b8a
    classDef backend fill:#f9d5a7,stroke:#c17900,color:#5a2e00
    classDef middleware fill:#e0e0e0,stroke:#6b6b6b,color:#343434
    classDef model fill:#d9ead3,stroke:#38761d,color:#274e13
    classDef db fill:#d5e8d4,stroke:#82b366,color:#274e13
    classDef external fill:#ffe599,stroke:#b58300,color:#735c0f
```
