# kaihendry/ltabus architecture

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

- Interactive diagram: https://gitdiagram.com/kaihendry/ltabus
- Repository: https://github.com/kaihendry/ltabus

## Overview

##### Project type and purpose
- This is a serverless, full-stack web application (“Singapore bus arrival Web application”) written in Go.
- It serves a static single-page frontend (HTML/CSS/JS) and a Go-based backend function that proxies requests to the MyTransport DataMall bus‐arrival API.

##### File structure
- Top-level Go files:
- main.go: entry point for the serverless function or local HTTP server
- busstops_test.go: unit tests for bus-stop related code
- allthebusstops.sh: shell script to generate static/all.json
- static/: contains the SPA assets
- index.html, app.js, app.css, lite.css, all.json
- template.yml: AWS SAM template defining the Lambda function, API Gateway, and any IAM roles
- .github/workflows/*.yml: GitHub Actions pipelines (SAM build & deploy, SLOC checks, weekly data updates)
- Makefile: common dev tasks (build, test, package)
- go.mod/go.sum: Go modules

##### README
- Confirms it’s a Web application for bus-arrival times
- Requires a DataMall API account key
- Mentions related open-source projects for inspiration
- No dedicated database—relies on a third-party REST API

##### Elements
– Blue for AWS-managed services
– Green for your code/components
– Orange for external third-party APIs
- Related resources in a “VPC” or AWS “region” boundary if desired

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["User's Browser"]:::external
        subgraph "Static Asset Host (CloudFront/S3)"
            CF["CloudFront / S3"]:::aws
            static_index["index.html"]:::code
            static_js["app.js"]:::code
            static_css["app.css"]:::code
            lite_css["lite.css"]:::code
            all_json["all.json"]:::code
        end
    end

    %% Backend Layer
    subgraph "Backend Layer (AWS Cloud)"
        APIGW["API Gateway"]:::aws
        Lambda["Lambda: bus-arrival-handler"]:::code
        icon_go["icon.go"]:::code
        main_go["main.go"]:::code
    end

    %% External API
    ExternalAPI["MyTransport DataMall API"]:::external

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        GH["GitHub Actions"]:::ci
        sam_pipeline["sam-pipeline.yml"]:::code
        sloc["sloc.yml"]:::code
        weekly["weekly-busstop-update.yml"]:::code
    end

    %% Dev Environment
    subgraph "Local Dev Environment"
        Makefile["Makefile"]:::code
        localServer["Local HTTP Server"]:::code
        busstops_test["busstops_test.go"]:::code
        all_script["allthebusstops.sh"]:::code
    end

    %% Connections
    Browser -->|"GET HTML/CSS/JS"| CF
    CF -->|serves assets| Browser
    Browser -->|"XHR /bus-arrival"| APIGW
    APIGW -->|"Invoke"| Lambda
    Lambda -->|"HTTPS request"| ExternalAPI
    ExternalAPI -->|"Return JSON"| Lambda
    Lambda -->|"Return JSON"| APIGW
    APIGW -->|"Return JSON"| Browser

    GH -->|"push triggers"| sam_pipeline
    sam_pipeline -->|"build & deploy"| APIGW
    sam_pipeline -->|"deploy static"| CF
    sam_pipeline -->|"deploy IaC"| APIGW

    Makefile -->|"serve locally"| localServer
    Makefile -->|"run tests"| busstops_test
    Makefile -->|"generate all.json"| all_script
    all_script -->|"outputs"| all_json

    %% Click Events
    click static_index "https://github.com/kaihendry/ltabus/blob/main/static/index.html"
    click static_js "https://github.com/kaihendry/ltabus/blob/main/static/app.js"
    click static_css "https://github.com/kaihendry/ltabus/blob/main/static/app.css"
    click lite_css "https://github.com/kaihendry/ltabus/blob/main/static/lite.css"
    click all_json "https://github.com/kaihendry/ltabus/blob/main/static/all.json"
    click icon_go "https://github.com/kaihendry/ltabus/blob/main/icon.go"
    click main_go "https://github.com/kaihendry/ltabus/blob/main/main.go"
    click all_script "https://github.com/kaihendry/ltabus/blob/main/allthebusstops.sh"
    click busstops_test "https://github.com/kaihendry/ltabus/blob/main/busstops_test.go"
    click sam_pipeline "https://github.com/kaihendry/ltabus/blob/main/.github/workflows/sam-pipeline.yml"
    click sloc "https://github.com/kaihendry/ltabus/blob/main/.github/workflows/sloc.yml"
    click weekly "https://github.com/kaihendry/ltabus/blob/main/.github/workflows/weekly-busstop-update.yml"
    click Makefile "https://github.com/kaihendry/ltabus/tree/main/Makefile"

    %% Styles
    classDef aws fill:#D0E6FA,stroke:#333,stroke-width:1px
    classDef code fill:#DFFFD6,stroke:#333,stroke-width:1px
    classDef external fill:#FDD6BF,stroke:#333,stroke-width:1px
    classDef ci fill:#EAD1DC,stroke:#333,stroke-width:1px
```
