# thangved/ctu-extension architecture

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

- Interactive diagram: https://gitdiagram.com/thangved/ctu-extension
- Repository: https://github.com/thangved/ctu-extension

## Overview

##### Project type and purpose
- This is a browser extension (Chrome) named “CTU Extension” providing CTU students with enhanced functionality: bypassing login captcha, viewing study plans, suggesting timetables, and viewing study results.
- It is built entirely on the frontend (no custom backend), injecting or embedding requests into CTU’s existing web services.

##### File structure
- Top-level configuration and CI/CD: .github, .circleci, sonar, eslint, husky, prettier, etc.
- src: the React/Redux application code:
- App.tsx, index.tsx – entry points
- features/… – feature-based UI modules (Grade, Report, SemesterSelector, StudyPlan, Timetable)
- services/… – modules encapsulating HTTP calls or iframe interactions with CTU endpoints (course, grade, studyPlan, timetable, iframe.service)
- shared, utils – common helpers (iframe messaging, HTML parsers, HTTP client)
- constants, styles – theming and host definitions
- mocks – sample data for local testing
- scripts: build hooks (prebuild, postbuild)
- esbuild.mjs, package.json, tsconfig.json – build configuration

##### README for additional insights
- Confirms React + Redux + Ant Design stack.
- No mention of background/content scripts in README, but manifest.json implies extension context.
- Features align with the service modules under src/services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Extension boundary
    subgraph "Chrome Extension" 
        direction TB
        Manifest["Manifest & Static Assets"]:::extension
        click Manifest "https://github.com/thangved/ctu-extension/blob/main/public/manifest.json"
        click Manifest "https://github.com/thangved/ctu-extension/blob/main/public/popup.html"
        click Manifest "https://github.com/thangved/ctu-extension/tree/main/public/icons/"
        
        subgraph "Popup UI (React + Redux)" 
            direction TB
            Index["index.tsx"]:::frontend
            click Index "https://github.com/thangved/ctu-extension/blob/main/src/index.tsx"
            App["App.tsx"]:::frontend
            click App "https://github.com/thangved/ctu-extension/blob/main/src/App.tsx"
            Store["Redux Store"]:::frontend

            subgraph "Feature Modules" 
                direction TB
                Grade["Grade Feature"]:::frontend
                click Grade "https://github.com/thangved/ctu-extension/blob/main/src/features/Grade/index.tsx"
                Report["Report Feature"]:::frontend
                click Report "https://github.com/thangved/ctu-extension/blob/main/src/features/Report/index.tsx"
                Semester["Semester Selector"]:::frontend
                click Semester "https://github.com/thangved/ctu-extension/blob/main/src/features/SemesterSelector/index.tsx"
                StudyPlan["Study Plan"]:::frontend
                click StudyPlan "https://github.com/thangved/ctu-extension/blob/main/src/features/StudyPlan/index.tsx"
                subgraph "Timetable Feature" 
                    direction TB
                    TTIndex["Timetable"]:::frontend
                    click TTIndex "https://github.com/thangved/ctu-extension/blob/main/src/features/Timetable/index.tsx"
                    RenderTT["RenderTimetable"]:::frontend
                    click RenderTT "https://github.com/thangved/ctu-extension/blob/main/src/features/Timetable/RenderTimetable.tsx"
                    Groups["GroupsTable"]:::frontend
                    click Groups "https://github.com/thangved/ctu-extension/blob/main/src/features/Timetable/GroupsTable.tsx"
                    Native["NativeTable"]:::frontend
                    click Native "https://github.com/thangved/ctu-extension/blob/main/src/features/Timetable/NativeTable.tsx"
                    Footer["Footer"]:::frontend
                    click Footer "https://github.com/thangved/ctu-extension/blob/main/src/features/Timetable/Footer.tsx"
                end
            end
        end
    end

    %% Services
    subgraph "Service Layer" 
        direction TB
        CourseS["course.service"]:::service
        click CourseS "https://github.com/thangved/ctu-extension/blob/main/src/services/course.service.ts"
        GradeS["grade.service"]:::service
        click GradeS "https://github.com/thangved/ctu-extension/blob/main/src/services/grade.service.ts"
        StudyPlanS["studyPlan.service"]:::service
        click StudyPlanS "https://github.com/thangved/ctu-extension/blob/main/src/services/studyPlan.service.ts"
        TimetableS["timetable.service"]:::service
        click TimetableS "https://github.com/thangved/ctu-extension/blob/main/src/services/timetable.service.ts"
        GroupS["group.service"]:::service
        click GroupS "https://github.com/thangved/ctu-extension/blob/main/src/services/group.service.ts"
        ExceptS["except.service"]:::service
        click ExceptS "https://github.com/thangved/ctu-extension/blob/main/src/services/except.service.ts"
        InfoS["info.service"]:::service
        click InfoS "https://github.com/thangved/ctu-extension/blob/main/src/services/info.service.ts"
        IframeS["iframe.service"]:::service
        click IframeS "https://github.com/thangved/ctu-extension/blob/main/src/services/iframe.service.ts"
        SharedIframe["shared/iframe"]:::service
        click SharedIframe "https://github.com/thangved/ctu-extension/blob/main/src/shared/iframe.ts"
    end

    %% Utilities
    subgraph "Utilities & Parsers" 
        direction TB
        HTTPClient["client.ts"]:::utils
        click HTTPClient "https://github.com/thangved/ctu-extension/blob/main/src/utils/client.ts"
        ParserScores["parserScoresHtml.ts"]:::utils
        click ParserScores "https://github.com/thangved/ctu-extension/blob/main/src/utils/parserScoresHtml.ts"
        GetTT["getTimetables.ts"]:::utils
        click GetTT "https://github.com/thangved/ctu-extension/blob/main/src/utils/getTimetables.ts"
        Cleanup["removeTxtMaBaoVe.ts"]:::utils
        click Cleanup "https://github.com/thangved/ctu-extension/blob/main/src/utils/removeTxtMaBaoVe.ts"
    end

    %% Constants & Mock
    Constants["Constants"]:::config
    click Constants "https://github.com/thangved/ctu-extension/blob/main/src/constants/colors.ts"
    click Constants "https://github.com/thangved/ctu-extension/blob/main/src/constants/hosts.ts"
    Styles["Global Styles"]:::config
    click Styles "https://github.com/thangved/ctu-extension/blob/main/src/styles/main.css"
    Mocks["Mock Data"]:::config
    click Mocks "https://github.com/thangved/ctu-extension/blob/main/src/mocks/scores.ts"
    BuildCfg["Build Config & Scripts"]:::config
    click BuildCfg "https://github.com/thangved/ctu-extension/blob/main/esbuild.mjs"
    click BuildCfg "https://github.com/thangved/ctu-extension/blob/main/scripts/prebuild.js"
    click BuildCfg "https://github.com/thangved/ctu-extension/blob/main/scripts/postbuild.js"
    CICD["CI/CD & Lint Configs"]:::config
    click CICD "https://github.com/thangved/ctu-extension/tree/main/.github/"
    click CICD "https://github.com/thangved/ctu-extension/blob/main/.circleci/config.yml"
    click CICD "https://github.com/thangved/ctu-extension/blob/main/.deepsource.toml"
    click CICD "https://github.com/thangved/ctu-extension/blob/main/eslint.config.cjs"
    click CICD "https://github.com/thangved/ctu-extension/tree/main/.husky/"
    click CICD "https://github.com/thangved/ctu-extension/blob/main/.prettierrc"
    click CICD "https://github.com/thangved/ctu-extension/blob/main/sonar-project.properties"

    %% External
    CTU["External CTU APIs / Web Pages"]:::external

    %% Flows
    User["User"]:::external -->|"click icon"| Manifest
    Manifest -->|"load popup"| Index
    Index -->|"bootstrap"| App
    App -->|"renders features"| Grade
    App -->|"renders features"| Report
    App -->|"renders features"| Semester
    App -->|"renders features"| StudyPlan
    App -->|"renders features"| TTIndex
    Grade -->|"dispatch action"| Store
    Report -->|"dispatch action"| Store
    Semester -->|"dispatch action"| Store
    StudyPlan -->|"dispatch action"| Store
    TTIndex -->|"dispatch action"| Store

    Store -->|"invoke service"| CourseS
    Store -->|"invoke service"| GradeS
    Store -->|"invoke service"| StudyPlanS
    Store -->|"invoke service"| TimetableS
    Store -->|"invoke service"| GroupS
    Store -->|"invoke service"| InfoS
    Store -->|"invoke service"| ExceptS
    Store -->|"invoke service"| IframeS

    CourseS -->|"HTTP call"| CTU
    GradeS -->|"HTTP call"| CTU
    StudyPlanS -->|"HTTP call"| CTU
    TimetableS -->|"HTTP call"| CTU
    GroupS -->|"HTTP call"| CTU
    InfoS -->|"HTTP call"| CTU
    IframeS -->|"iframe msg"| CTU

    CourseS --> ParserScores
    GradeS --> ParserScores
    TimetableS --> GetTT
    IframeS --> Cleanup

    HTTPClient --> CourseS
    HTTPClient --> GradeS
    HTTPClient --> StudyPlanS
    HTTPClient --> TimetableS

    %% Styles
    classDef extension fill:#bbdefb,stroke:#1e88e5
    classDef frontend fill:#c8e6c9,stroke:#388e3c
    classDef service fill:#fff9c4,stroke:#fbc02d
    classDef utils fill:#e1bee7,stroke:#8e24aa
    classDef config fill:#ffccbc,stroke:#d84315
    classDef external fill:#cfd8dc,stroke:#607d8b
```
