# yashkarthik/where_is_my_ion architecture

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

- Interactive diagram: https://gitdiagram.com/yashkarthik/where_is_my_ion
- Repository: https://github.com/yashkarthik/where_is_my_ion

## Overview

##### Project type and purpose
- The software side parses static GTFS schedules and realtime GTFS‑RT feeds (via Protocol Buffers), computes LED on/off or count per segment, and sends commands to the hardware.
- The hardware side is a KiCad‑designed driver board (EDA/gerbers, .kicad_sch) with LED drivers and connectors for station and inter‑station LEDs.

##### File structure
─ Top level:
- GRT GTFS/…txt – raw schedule (static) data.
- eda/… – PCB design files and Gerber outputs.
- src/ – C++ application: CMakeLists.txt, main.cpp, GTFS‑PROTO, loader header, and generated .pb.cc/.pb.h files.
─ Build & config:
- Root CMakeLists.txt and src/Makefile drive compilation.
- .clangd hints at IDE integration.
- gtfs-realtime.proto → generates gtfs-realtime.pb.cc/.h.
─ Outputs:
- src/a.out, main.o, out.txt suggest a CLI tool that produces test logs or output.

##### README for additional insights
─ The README lists LED‑to‑driver assignments, counts for station and inter‑station LEDs, and a logical network topology.
─ It defines the mapping between physical rails/stations and drivers on the board.

##### Detail
- Number of LEDs per segment alongside the hardware outputs.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Sources Layer
    subgraph "Data Sources"
        direction TB
        StaticGTFS["Static GTFS Data (agency.txt, stops.txt, routes.txt, etc.)"]:::datastore
        RealtimeProto["GTFS‑RT Definition (gtfs-realtime.proto)"]:::datastore
        RealtimePBH["Generated Code (.pb.h)"]:::software
        RealtimePBC["Generated Code (.pb.cc)"]:::software
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Parser["GTFS Parser & Loader (gtfs_loader.h)"]:::software
        Controller["LED Controller App (main.cpp)"]:::software
        AppCMake["CMakeLists.txt"]:::config
        AppMake["Makefile"]:::config
        PBObj["GTFS‑RT Object (gtfs-realtime.pb.o)"]:::software
    end

    %% Build System & Config
    subgraph "Build & Config"
        direction TB
        RootCMake["Root CMakeLists.txt"]:::config
        Clangd[".clangd"]:::config
    end

    %% Hardware Layer
    subgraph "Hardware & Physical"
        direction TB
        Interface["Hardware Interface (USB/Serial or SPI)"]:::hardware
        subgraph "Custom PCB Design"
            direction TB
            PCBLayout["PCB Layout (where_is_my_ion.kicad_pcb)"]:::hardware
            PCBSch["Schematic (where_is_my_ion.kicad_sch)"]:::hardware
            Gerbers["Gerber Outputs (gerbers/*.gbr)"]:::hardware
            FootprintCache["PCB Footprint Cache (fp-info-cache)"]:::hardware
            CSV["Board CSV (where_is_my_ion.csv)"]:::hardware
            GbrJob["Gerber Job (where_is_my_ion-job.gbrjob)"]:::hardware
            subgraph "LED Driver Banks"
                direction TB
                Driver1["Driver 1 (16 outputs)"]:::hardware
                Driver2["Driver 2 (16 outputs)"]:::hardware
                Driver3["Driver 3 (16 outputs)"]:::hardware
                Driver4["Driver 4 (16 outputs)"]:::hardware
                Driver5["Driver 5 (16 outputs)"]:::hardware
            end
        end
        LEDs["Physical LED Array"]:::hardware
    end

    %% Connections
    StaticGTFS -->|provides schedule data| Parser
    RealtimeProto -->|defines stream| Parser
    RealtimePBH -->|parsing code| Parser
    RealtimePBC -->|parsing code| Parser

    Parser -->|feeds| Controller
    PBObj -->|linked into| Controller

    AppCMake -->|build config| Controller
    AppMake -->|build rules| Controller

    RootCMake -->|orchestrates| AppCMake
    RootCMake -->|orchestrates| AppMake
    Clangd -->|IDE hints| Controller

    Controller -->|sends commands| Interface
    Interface -->|USB/Serial/SPI| PCBLayout
    PCBLayout --> PCBSch
    PCBLayout --> Gerbers
    PCBLayout --> FootprintCache
    PCBLayout --> CSV
    PCBLayout --> GbrJob
    PCBLayout --> Driver1
    PCBLayout --> Driver2
    PCBLayout --> Driver3
    PCBLayout --> Driver4
    PCBLayout --> Driver5

    Driver1 --> LEDs
    Driver2 --> LEDs
    Driver3 --> LEDs
    Driver4 --> LEDs
    Driver5 --> LEDs

    %% Click Events
    click StaticGTFS "https://github.com/yashkarthik/where_is_my_ion/tree/main/GRT GTFS/"
    click RealtimeProto "https://github.com/yashkarthik/where_is_my_ion/blob/main/src/gtfs-realtime.proto"
    click RealtimePBH "https://github.com/yashkarthik/where_is_my_ion/blob/main/src/gtfs-realtime.pb.h"
    click RealtimePBC "https://github.com/yashkarthik/where_is_my_ion/blob/main/src/gtfs-realtime.pb.cc"
    click Parser "https://github.com/yashkarthik/where_is_my_ion/blob/main/src/gtfs_loader.h"
    click Controller "https://github.com/yashkarthik/where_is_my_ion/blob/main/src/main.cpp"
    click AppCMake "https://github.com/yashkarthik/where_is_my_ion/blob/main/src/CMakeLists.txt"
    click AppMake "https://github.com/yashkarthik/where_is_my_ion/tree/main/src/Makefile"
    click PBObj "https://github.com/yashkarthik/where_is_my_ion/blob/main/src/gtfs-realtime.pb.o"
    click RootCMake "https://github.com/yashkarthik/where_is_my_ion/blob/main/CMakeLists.txt"
    click Clangd "https://github.com/yashkarthik/where_is_my_ion/blob/main/.clangd"
    click PCBLayout "https://github.com/yashkarthik/where_is_my_ion/blob/main/eda/where_is_my_ion.kicad_pcb"
    click PCBSch "https://github.com/yashkarthik/where_is_my_ion/blob/main/eda/where_is_my_ion.kicad_sch"
    click Gerbers "https://github.com/yashkarthik/where_is_my_ion/tree/main/eda/gerbers/"
    click FootprintCache "https://github.com/yashkarthik/where_is_my_ion/tree/main/eda/fp-info-cache"
    click CSV "https://github.com/yashkarthik/where_is_my_ion/blob/main/eda/where_is_my_ion.csv"
    click GbrJob "https://github.com/yashkarthik/where_is_my_ion/blob/main/eda/where_is_my_ion-job.gbrjob"

    %% Styles
    classDef software fill:#cce5ff,stroke:#004085,color:#004085
    classDef datastore fill:#d4edda,stroke:#155724,color:#155724,stroke-dasharray: 5 5
    classDef hardware fill:#fff3cd,stroke:#856404,color:#856404
    classDef config fill:#e2e3e5,stroke:#6c757d,color:#6c757d,stroke-dasharray: 2 2
```
