# ricardocasares/kurbus architecture

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

- Interactive diagram: https://gitdiagram.com/ricardocasares/kurbus
- Repository: https://github.com/ricardocasares/kurbus

## Overview

##### Main Components
- Frontend Client:
- Elm Application – Located in the src folder (e.g., Main.elm, Route.elm, UI components, and Data).
- index.html – Bootstraps and hosts the Elm application.
- CSS and build configurations (src/main.css, tailwind.config.ts) which indicate the styling strategy.
- API Backend:
- API endpoints in the api folder (files like [...api].ts, _api.ts, _config.ts, etc.). These endpoints, likely deployed as serverless functions via Vercel (using vercel.json), handle data requests.
- Build & Deployment Pipeline:
- Configuration files for Vite (vite.config.ts) and Vercel (vercel.json) that define the build/deployment process.
- Package management through package.json and Bun’s lockfile (bun.lockb) indicates the dependency management used.
- Static Assets & Progressive Web App (PWA):
- The public folder contains static assets.
- pwa-assets.config.ts suggests configuration for PWA functionalities (e.g., service workers, caching).

##### Interactions and Relationships
- User Interaction Flow:
- Users access index.html, which loads the Elm frontend.
- The Elm app (in src) is responsible for rendering the UI (src/UI) and handling user interactions.
- Upon certain actions (such as checking bus/tram schedules), the Elm app makes requests to the API endpoints.
- API Communication:
- The API (in the api directory) processes incoming requests, potentially interacting with external data sources (or files like _stops.json) to fetch transit schedule data.
- Build and Deployment:
- Vite (vite.config.ts) and tsconfig.json manage the application’s build process.
- Deployment is managed via Vercel as indicated in vercel.json, combining static assets, Elm app, and API endpoints into a cohesive web service.

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Interaction
    U["User Browser"]:::user

    %% Frontend - Elm Application Subgraph
    subgraph "Frontend - Elm Application"
        INDEX["index.html"]:::frontend
        ELM["Elm App"]:::frontend
        MAIN["src/Main.elm"]:::frontend
        ROUTE["src/Route.elm"]:::frontend
        DATA["src/Data"]:::frontend
        UI["src/UI"]:::frontend
        CSS["src/main.css"]:::frontend
    end

    %% API Backend Subgraph
    subgraph "API Backend"
        API1["api/[...api].ts"]:::api
        API2["api/_api.ts"]:::api
        CONFIG["api/_config.ts"]:::api
        SCHEMAS["api/_schemas.ts"]:::api
        TTSS["api/_ttss.ts"]:::api
        STOPS["api/_stops.json"]:::api
    end

    %% Build & Deployment Pipeline Subgraph
    subgraph "Build & Deployment"
        VITE["vite.config.ts"]:::build
        TSCONFIG["tsconfig.json"]:::build
        ELMJSON["elm.json"]:::build
        TAILWIND["tailwind.config.ts"]:::build
        PACKAGE["package.json"]:::build
        BUN["bun.lockb"]:::build
        VERCEL["vercel.json"]:::build
    end

    %% Static Assets & PWA Subgraph
    subgraph "Static Assets & PWA"
        PUBLIC["public"]:::assets
        PWACONFIG["pwa-assets.config.ts"]:::assets
    end

    %% Connections - User Interaction Flow
    U -->|"loads"| INDEX
    INDEX -->|"bootstraps"| ELM

    %% Frontend Internal Composition
    ELM -->|"comprises"| MAIN
    ELM -->|"comprises"| ROUTE
    ELM -->|"comprises"| DATA
    ELM -->|"comprises"| UI
    ELM -->|"styles via"| CSS
    
    %% Interaction between Frontend and API Backend
    ELM -->|"HTTP-request"| API1
    ELM -->|"HTTP-request"| API2
    API1 -->|"response"| ELM
    API2 -->|"response"| ELM
    CONFIG --- SCHEMAS
    TTSS --- STOPS

    %% Build & Deployment Relationships
    VITE -->|"builds"| INDEX
    TSCONFIG -->|"configures"| API1
    ELMJSON -->|"configures"| MAIN
    TAILWIND -->|"styles"| CSS
    PACKAGE & BUN -->|"manage dependencies"| VERCEL
    VERCEL -->|"deploys"| INDEX
    VERCEL -->|"deploys"| API1

    %% Static Assets Integration
    INDEX -->|"loads assets"| PUBLIC
    PUBLIC -->|"configured by"| PWACONFIG

    %% Click Events for Frontend
    click INDEX "https://github.com/ricardocasares/kurbus/blob/main/index.html"
    click MAIN "https://github.com/ricardocasares/kurbus/blob/main/src/Main.elm"
    click ROUTE "https://github.com/ricardocasares/kurbus/blob/main/src/Route.elm"
    click DATA "https://github.com/ricardocasares/kurbus/tree/main/src/Data"
    click UI "https://github.com/ricardocasares/kurbus/tree/main/src/UI"
    click CSS "https://github.com/ricardocasares/kurbus/blob/main/src/main.css"

    %% Click Events for API Backend
    click API1 "https://github.com/ricardocasares/kurbus/blob/main/api/[...api].ts"
    click API2 "https://github.com/ricardocasares/kurbus/blob/main/api/_api.ts"
    click CONFIG "https://github.com/ricardocasares/kurbus/blob/main/api/_config.ts"
    click SCHEMAS "https://github.com/ricardocasares/kurbus/blob/main/api/_schemas.ts"
    click TTSS "https://github.com/ricardocasares/kurbus/blob/main/api/_ttss.ts"
    click STOPS "https://github.com/ricardocasares/kurbus/blob/main/api/_stops.json"

    %% Click Events for Build & Deployment
    click VITE "https://github.com/ricardocasares/kurbus/blob/main/vite.config.ts"
    click TSCONFIG "https://github.com/ricardocasares/kurbus/blob/main/tsconfig.json"
    click ELMJSON "https://github.com/ricardocasares/kurbus/blob/main/elm.json"
    click TAILWIND "https://github.com/ricardocasares/kurbus/blob/main/tailwind.config.ts"
    click PACKAGE "https://github.com/ricardocasares/kurbus/blob/main/package.json"
    click BUN "https://github.com/ricardocasares/kurbus/blob/main/bun.lockb"
    click VERCEL "https://github.com/ricardocasares/kurbus/blob/main/vercel.json"

    %% Click Events for Static Assets & PWA
    click PUBLIC "https://github.com/ricardocasares/kurbus/tree/main/public"
    click PWACONFIG "https://github.com/ricardocasares/kurbus/blob/main/pwa-assets.config.ts"

    %% Styles
    classDef user fill:#FFEEAD,stroke:#F39C12,stroke-width:2px;
    classDef frontend fill:#D3E5FF,stroke:#2980B9,stroke-width:2px;
    classDef api fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef build fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef assets fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
```
