# phamminhtan1122/hcmuaf-schedule-exporter architecture

> Architecture diagram of the GitHub repository phamminhtan1122/hcmuaf-schedule-exporter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/phamminhtan1122/hcmuaf-schedule-exporter
- Repository: https://github.com/phamminhtan1122/hcmuaf-schedule-exporter

## Overview

##### Main Components
a. Frontend (User Interface):
- Located in the "public" directory, which includes the index.html, script.js, and styles.css.
- Responsible for rendering the different screens based on the user flow described in the README (login screen, schedule/exam choice, semester selection, ICS file download, and Google Calendar integration guide).
b. Backend (API Server):
- Located in the "api" directory. The file server.js is the main entry point, and the "routes" directory contains specific endpoints:
- auth.js: handles user authentication.
- exam.js: processes exam schedule requests.
- schedule.js: processes timetable (TKB) requests.
- ics.js: responsible for generating or processing the ICS file.
c. Deployment/Configuration:
- File like vercel.json indicates that the app is configured for deployment on Vercel.
- package.json and .babelrc indicate the use of JavaScript tools and possible transpilation steps.

##### Relationships and Interactions
- The User Interface (frontend) sends HTTP requests (likely via Ajax/fetch from script.js) to the backend API endpoints.
- The authentication endpoint (/api/routes/auth) validates user credentials entered on the login screen.
- Once authenticated, users choose between "TKB" or "Lịch thi", triggering requests to either the schedule endpoint (schedule.js) or exam endpoint (exam.js).
- After processing the selected schedule type, the backend uses the ics.js module to convert the retrieved data into an ICS file.
- The generated ICS file is then provided to the frontend, which lets the user download it or trigger an “Add to Google Calendar” process.
- The overall flow is controlled by the frontend which steps the user through login, selection, fetching data, and finishing the conversion.

##### Architectural Patterns and Technologies
- Separation of concerns: There is a clear division between front-end (presentation layer) and backend (business logic and data processing).
- RESTful design: Each API endpoint (authentication, schedule, exam, ICS generation) is likely exposed as a RESTful route.
- Single Page Application (SPA) style: Although the project structure is simple, the public/script.js likely orchestrates the user flow without full page reloads.
- Deployment configuration indicates use of modern cloud deployment (e.g., Vercel).

##### Essential Details
- That every step in the process (as outlined in the README) is represented either as a component or as an interaction path.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Subgraph
    subgraph "UI/Frontend"
        UI1["Login Screen"]:::frontend
        UI2["Schedule/Exam Selection"]:::frontend
        UI3["Semester Selection & ICS Download/Google Calendar Integration"]:::frontend
    end

    %% Backend API Server Subgraph
    subgraph "Backend API Server"
        BE0["API Server (server.js)"]:::backend
        BE1["Authentication Service (auth.js)"]:::backend
        BE2["Schedule Service (schedule.js)"]:::backend
        BE3["Exam Service (exam.js)"]:::backend
        BE4["ICS Generation Service (ics.js)"]:::backend
    end

    %% Infrastructure/Deployment Subgraph
    subgraph "Infrastructure/Deployment"
        DEP["Vercel Deployment (vercel.json)"]:::deployment
    end

    %% External Service Subgraph
    subgraph "External Service"
        EX["Google Calendar"]:::external
    end

    %% Connections between Frontend and Backend
    UI1 -->|"POST/login"| BE1
    BE0 --> BE1

    UI2 -->|"GET/schedule"| BE2
    UI2 -->|"GET/exam"| BE3

    BE2 -->|"GenerateICS"| BE4
    BE3 -->|"GenerateICS"| BE4

    BE4 -->|"ReturnICS"| UI3
    UI3 -->|"AddtoGoogle"| EX

    %% Deployment Hosting Arrows
    DEP -->|"Hosts"| BE0
    DEP -->|"Hosts"| UI1

    %% Click Events for Frontend Components
    click UI1 "https://github.com/phamminhtan1122/hcmuaf-schedule-exporter/blob/main/public/index.html"
    click UI2 "https://github.com/phamminhtan1122/hcmuaf-schedule-exporter/blob/main/public/script.js"
    click UI3 "https://github.com/phamminhtan1122/hcmuaf-schedule-exporter/blob/main/public/styles.css"

    %% Click Events for Backend Components
    click BE0 "https://github.com/phamminhtan1122/hcmuaf-schedule-exporter/blob/main/api/server.js"
    click BE1 "https://github.com/phamminhtan1122/hcmuaf-schedule-exporter/blob/main/api/routes/auth.js"
    click BE2 "https://github.com/phamminhtan1122/hcmuaf-schedule-exporter/blob/main/api/routes/schedule.js"
    click BE3 "https://github.com/phamminhtan1122/hcmuaf-schedule-exporter/blob/main/api/routes/exam.js"
    click BE4 "https://github.com/phamminhtan1122/hcmuaf-schedule-exporter/blob/main/api/routes/ics.js"

    %% Click Event for Deployment Configuration
    click DEP "https://github.com/phamminhtan1122/hcmuaf-schedule-exporter/blob/main/vercel.json"

    %% Styles
    classDef frontend fill:#ccf,stroke:#333,stroke-width:2px;
    classDef backend fill:#cfc,stroke:#333,stroke-width:2px;
    classDef deployment fill:#fc9,stroke:#333,stroke-width:2px;
    classDef external fill:#fcc,stroke:#333,stroke-width:2px;
```
