# xtzi9859/departure-board architecture

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

- Interactive diagram: https://gitdiagram.com/xtzi9859/departure-board
- Repository: https://github.com/xtzi9859/departure-board

## Overview

##### Project Type and Purpose
- This is a small, static full-stack­-in­-miniature web application: a simulated departure display (“発車標”) for JR Ashikaga Station using the 2023 weekday timetable.
- There is no dynamic backend or database server at runtime; all data files and logic are shipped as static assets.

##### High-Level Architecture Components
a. Static File Host (Web Server or CDN)
b. Client Browser (User’s Frontend)
c. Data Assets (Timetable, Car formations, Destination codes, Number glyphs, Train types)
d. Build/Preprocessing Step (CSV → JSON conversion)

##### Relationships and Data Flows
- The build step ingests `timetable/inbound.csv` and `timetable/outbound.csv` and outputs corresponding JSON (already present in `timetable/*.json`).
- At runtime, the browser loads `index.html` from the static host.
- The HTML references `disp.js`, `disp.css`, and `main.css`.
- `disp.js` (Controller) requests the JSON timetable and supporting assets from folders `cars/`, `dest/`, `num/`, and `type/`.
- On receiving the JSON timetable (Model), `disp.js` renders the departure board UI into the DOM (View), applying styles from the CSS files.

##### Architectural Patterns and Principles
- MVC-like separation:
- Model = JSON timetable + asset directories
- View = HTML + CSS (`main.css` and `disp.css`)
- Controller = `disp.js`
- Static-site approach: no server-side computation at runtime.
- Preprocessing pipeline: CSV → JSON for easier client-side consumption.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Preprocessing Layer
    subgraph "Preprocessing" 
        direction TB
        CSV_IN["timetable/inbound.csv"]:::preprocessing
        CSV_OUT["timetable/outbound.csv"]:::preprocessing
        BUILD["Build/Preprocess (CSV→JSON)"]:::preprocessing
        JSON_IN["timetable/inbound.json"]:::model
        JSON_OUT["timetable/outbound.json"]:::model
    end

    CSV_IN -->|ingest| BUILD
    CSV_OUT -->|ingest| BUILD
    BUILD -->|outputs| JSON_IN
    BUILD -->|outputs| JSON_OUT

    %% Hosting Layer
    subgraph "Static File Host (Web Server/CDN)" 
        direction TB
        HOST["Static Host"]:::hosting
        FILE_INDEX["index.html"]:::hosting
        FILE_MAIN_CSS["main.css"]:::view
        FILE_DISP_CSS["disp.css"]:::view
        FILE_DISP_JS["disp.js"]:::controller
        DIR_CARS["cars/"]:::asset
        DIR_DEST["dest/"]:::asset
        DIR_NUM["num/"]:::asset
        DIR_TYPE["type/"]:::asset
        DIR_TIMETABLE["timetable/"]:::asset
    end

    JSON_IN -->|serve| HOST
    JSON_OUT -->|serve| HOST
    DIR_CARS -->|serve| HOST
    DIR_DEST -->|serve| HOST
    DIR_NUM -->|serve| HOST
    DIR_TYPE -->|serve| HOST
    DIR_TIMETABLE -->|serve JSON & CSV| HOST
    FILE_INDEX -->|serve| HOST
    FILE_MAIN_CSS -->|serve| HOST
    FILE_DISP_CSS -->|serve| HOST
    FILE_DISP_JS -->|serve| HOST

    %% Client Browser Layer
    HOST -->|HTTP GET| BROWSER["Browser (Client)"]:::client

    subgraph "Browser (Client)" 
        direction TB
        subgraph "Model" 
            direction TB
            M_JSON_IN["inbound.json"]:::model
            M_JSON_OUT["outbound.json"]:::model
            M_CARS["cars/"]:::asset
            M_DEST["dest/"]:::asset
            M_NUM["num/"]:::asset
            M_TYPE["type/"]:::asset
        end
        subgraph "View" 
            direction TB
            V_HTML["index.html"]:::view
            V_MAIN_CSS["main.css"]:::view
            V_DISP_CSS["disp.css"]:::view
        end
        subgraph "Controller" 
            direction TB
            C_DISP_JS["disp.js"]:::controller
        end
    end

    BROWSER -->|loads| V_HTML
    BROWSER -->|loads| V_MAIN_CSS
    BROWSER -->|loads| V_DISP_CSS
    BROWSER -->|loads| C_DISP_JS
    C_DISP_JS -->|requests JSON| M_JSON_IN
    C_DISP_JS -->|requests JSON| M_JSON_OUT
    C_DISP_JS -->|requests assets| M_CARS
    C_DISP_JS -->|requests assets| M_DEST
    C_DISP_JS -->|requests assets| M_NUM
    C_DISP_JS -->|requests assets| M_TYPE
    C_DISP_JS -->|renders UI| DOM["DOM Updates"]:::client

    %% Click Events
    click CSV_IN "https://github.com/xtzi9859/departure-board/blob/main/timetable/inbound.csv"
    click CSV_OUT "https://github.com/xtzi9859/departure-board/blob/main/timetable/outbound.csv"
    click JSON_IN "https://github.com/xtzi9859/departure-board/blob/main/timetable/inbound.json"
    click JSON_OUT "https://github.com/xtzi9859/departure-board/blob/main/timetable/outbound.json"
    click DIR_CARS "https://github.com/xtzi9859/departure-board/tree/main/cars/"
    click DIR_DEST "https://github.com/xtzi9859/departure-board/tree/main/dest/"
    click DIR_NUM "https://github.com/xtzi9859/departure-board/tree/main/num/"
    click DIR_TYPE "https://github.com/xtzi9859/departure-board/tree/main/type/"
    click DIR_TIMETABLE "https://github.com/xtzi9859/departure-board/tree/main/timetable/"
    click FILE_INDEX "https://github.com/xtzi9859/departure-board/blob/main/index.html"
    click FILE_MAIN_CSS "https://github.com/xtzi9859/departure-board/blob/main/main.css"
    click FILE_DISP_CSS "https://github.com/xtzi9859/departure-board/blob/main/disp.css"
    click FILE_DISP_JS "https://github.com/xtzi9859/departure-board/blob/main/disp.js"

    %% Styles
    classDef preprocessing fill:#cccccc,stroke:#333,stroke-width:1px
    classDef hosting fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef client fill:#99ccff,stroke:#333,stroke-width:1px
    classDef model fill:#ffcc99,stroke:#333,stroke-width:1px
    classDef view fill:#99ff99,stroke:#333,stroke-width:1px
    classDef controller fill:#ff9999,stroke:#333,stroke-width:1px
    classDef asset fill:#ffff99,stroke:#333,stroke-width:1px
```
