# reacto11mecha/unj-timetable architecture

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

- Interactive diagram: https://gitdiagram.com/reacto11mecha/unj-timetable
- Repository: https://github.com/reacto11mecha/unj-timetable

## Overview

##### Main Components
- Frontend UI Layer:
- Astro pages (files in src/pages like index.astro and 404.astro)
- Layouts (src/layouts/Layout.astro)
- Component Modules:
- React components for the interactive parts (e.g., components in src/components/IndexPage and src/components/ui)
- UI elements like alert dialogs, buttons, cards, forms, etc., housed under src/components/ui
- Business Logic and Data Processing:
- The file processor and data extractor: submit-handler.ts in src/lib; this is the core module that reads, validates, and processes the uploaded KRS file.
- Additional utility modules (src/lib/utils.ts and atom.ts)
- Styles and Configurations:
- Tailwind CSS with its configuration (tailwind.config.js and src/styles/global.css)
- Astro configuration (astro.config.mjs)
- TypeScript configurations (tsconfig.json) and package management files (package.json, pnpm-lock.yaml)

##### Relationships and Interactions
- Data Flow:
- The user interacts with the frontend UI (built with Astro pages and React components). When the “Tambah File” button is clicked, the process starts via event handlers wired to the file input.
- The UI components (e.g., NoData.tsx) rely on the submit-handler.ts to:
- Read and validate the raw KRS file.
- Extract and parse student identity data and schedule table from the HTML/MHTML content.
- Restructure and sort the data.
- Once processing is complete, the cleaned data is stored using local storage on the client (via functions such as setKrsData).
- Component Integration:
- Astro acts as the shell and routing framework that then calls or embeds React components.
- React UI components make use of Tailwind for styling.
- Utility libraries (src/lib) support components with shared functions or state management (using atoms, for example).

##### Architectural Patterns and Principles
- Client-Side Data Processing:
- Emphasis on local processing of data – meaning the heavy lifting is performed in the browser.
- Modular Design:
- Clear separation between UI (components directory), logic (lib directory), and layout/pages (layouts and pages directories).
- Reusability:
- The design pattern is based on reusable UI components (notice a dedicated ui folder for elements such as buttons, dialogs, inputs, etc.).
- Integration of multiple frameworks:
- Astro for page composition and routing.
- React for interactive front-end behavior.
- Tailwind CSS for styling.

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Interaction
    User["User"]:::frontend

    %% Frontend UI Layer
    subgraph "Frontend UI Layer"
        IndexAstro["Index.astro"]:::frontend
        Astro404["404.astro"]:::frontend
        Layout["Layout.astro"]:::frontend
        PublicAssets["Public Assets"]:::frontend
    end

    %% Component Modules
    subgraph "Component Modules"
        IndexPage["IndexPage Components"]:::component
        UIComponents["UI Components"]:::component
    end

    %% Business Logic & Data Processing
    subgraph "Business Logic & Data Processing"
        FileProcessor["submit-handler.ts"]:::logic
        Utils["utils.ts"]:::logic
        Atom["atom.ts"]:::logic
    end

    %% Styles & Configurations
    subgraph "Styles & Configurations"
        TailwindConfig["Tailwind Config"]:::config
        GlobalStyles["Global Styles"]:::config
        AstroConfig["Astro Config"]:::config
        TSConfig["tsconfig.json"]:::config
        PackageJson["package.json"]:::config
        PNPMLock["pnpm-lock.yaml"]:::config
    end

    %% Client Storage
    subgraph "Client Storage"
        LocalStorage["Local Storage"]:::storage
    end

    %% Data Flow and Interactions
    User -->|"click_TambahFile"| UIComponents
    IndexAstro -->|"embeds"| IndexPage
    UIComponents -->|"triggers"| FileProcessor
    FileProcessor -->|"processes"| Utils
    FileProcessor -->|"manages_state"| Atom
    FileProcessor -->|"stores_data"| LocalStorage
    IndexPage -->|"styled_with"| GlobalStyles
    IndexAstro -->|"uses"| Layout

    AstroConfig -->|"configures"| Layout
    TailwindConfig -->|"defines_styles"| GlobalStyles
    PackageJson -->|"manages_deps"| IndexPage
    PNPMLock -->|"locks_deps"| IndexPage
    TSConfig -->|"type_checking"| FileProcessor

    %% Styles
    classDef frontend fill:#A2D2FF,stroke:#000,stroke-width:1px;
    classDef component fill:#BDE0FE,stroke:#000,stroke-width:1px;
    classDef logic fill:#FFC8DD,stroke:#000,stroke-width:1px;
    classDef config fill:#CFF9CF,stroke:#000,stroke-width:1px;
    classDef storage fill:#FCE38A,stroke:#000,stroke-width:1px;

    %% Click Events
    click IndexAstro "https://github.com/reacto11mecha/unj-timetable/blob/main/src/pages/index.astro"
    click Astro404 "https://github.com/reacto11mecha/unj-timetable/blob/main/src/pages/404.astro"
    click Layout "https://github.com/reacto11mecha/unj-timetable/blob/main/src/layouts/Layout.astro"
    click PublicAssets "https://github.com/reacto11mecha/unj-timetable/tree/main/public/assets"
    click IndexPage "https://github.com/reacto11mecha/unj-timetable/tree/main/src/components/IndexPage"
    click UIComponents "https://github.com/reacto11mecha/unj-timetable/tree/main/src/components/ui"
    click FileProcessor "https://github.com/reacto11mecha/unj-timetable/blob/main/src/lib/submit-handler.ts"
    click Utils "https://github.com/reacto11mecha/unj-timetable/blob/main/src/lib/utils.ts"
    click Atom "https://github.com/reacto11mecha/unj-timetable/blob/main/src/lib/atom.ts"
    click TailwindConfig "https://github.com/reacto11mecha/unj-timetable/blob/main/tailwind.config.js"
    click GlobalStyles "https://github.com/reacto11mecha/unj-timetable/blob/main/src/styles/global.css"
    click AstroConfig "https://github.com/reacto11mecha/unj-timetable/blob/main/astro.config.mjs"
    click TSConfig "https://github.com/reacto11mecha/unj-timetable/blob/main/tsconfig.json"
    click PackageJson "https://github.com/reacto11mecha/unj-timetable/blob/main/package.json"
    click PNPMLock "https://github.com/reacto11mecha/unj-timetable/blob/main/pnpm-lock.yaml"
```
