# alanjsfleming/greenarrowsdashboard architecture

> Architecture diagram of the GitHub repository alanjsfleming/greenarrowsdashboard, 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/alanjsfleming/greenarrowsdashboard
- Repository: https://github.com/alanjsfleming/greenarrowsdashboard

## Overview

##### Project Type and Purpose
- This is a full-stack, real-time telemetry dashboard used for monitoring and analyzing sensor data from a car.
- The data originates at the eChook board (via a mobile app) and travels to dweet.io, from where it is fetched and processed.
- The system displays calculated metrics (like gear estimation, battery status, lap data) on a dashboard built with React, while using Firebase (hosting, functions, realtime database, or Firestore rules) as the backend.

##### Main Components
a. Frontend (Client-Side Web UI):
- Built in React (located in the “src” directory).
- Contains pages (e.g., HomePage, Login, Settings, etc.), components (e.g., Telemetry, LapSummary, DataVisualisation, Dashboard), layouts, contexts (for auth, settings, telemetry), and hooks.
- Manages local storage of settings and the dynamic display of telemetry data.
b. Backend (Firebase Components):
- Firebase Functions (code under “functions”): Custom backend logic (written in TypeScript, includes linting via .eslintrc.js) that might handle data processing, authentication coordination, or API endpoints.
- Firebase Configuration (firebase.json, .firebaserc, firestore.rules, and related index files) indicating hosting, security, and database configurations.
c. Database:
- The project uses Firebase’s Realtime Database (or Firestore as a backup) to store user data, car configurations, telemetry records, lap summaries, and settings.
- The README describes a database schema with a “users” node – where each user’s document contains their settings and associated car documents.
d. External Services:
- dweet.io: Serves as the telemetry data source; the JavaScript Fetch API retrieves JSON data from dweet.
- eChook Board: Although not part of the project code, it is the origin of sensor data.

##### Depicting Relationships and Data Flow
- Flow from external sensors (eChook board) → mobile phone (sending data via the eChook app) → dweet.io → the client application or Firebase Functions (which may merge new data with existing data).
- Firebase Hosting component that serves the static assets from the “public” folder.

##### Design Patterns and Technologies
- The project’s structure (separating “src” for UI and “functions” for server-side logic) indicates a clear separation of concerns consistent with modern full-stack practices.
- The usage of React contexts, hooks, and modular “features” folders reflects a component-based architecture.
- Firebase functions, database rules, and hosting configurations embody a serverless backend design.
- That the telemetry calculations are performed both client-side (through various utility modules and feature components) as well as possibly on the server through Firebase Functions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Sources
    subgraph "External Sources"
        E1["eChook Board (Sensor Data)"]:::external
        E2["dweet.io (Telemetry Source)"]:::external
    end

    %% Frontend Section
    subgraph "Frontend"
        F1["React UI - src"]:::frontend
        F2["Pages - src/pages"]:::frontend
        F3["UI Components - src/pages/components"]:::frontend
        F4["Contexts - src/contexts"]:::frontend
        F5["Telemetry Calculations - src/features/TelemetryCalculations.js"]:::frontend
        F6["Utilities - src/utils"]:::frontend
        F7["External Service Interaction - handleGetDweet.js"]:::frontend
    end

    %% Backend Section
    subgraph "Backend"
        B1["Firebase Functions - functions/src/index.ts"]:::backend
        B2["Firebase Configuration (firebase.json, .firebaserc, database.rules.json, firestore.rules)"]:::backend
        B3["Firebase Hosting - public"]:::backend
    end

    %% Database Section
    subgraph "Database"
        D1["Firebase Realtime Database (users, car telemetry)"]:::database
    end

    %% Data Flow Connections
    E1 -->|"sendsData"| E2
    E2 -->|"fetchTelemetry"| F7
    F7 -->|"passTelemetry"| F5
    F6 -->|"utilitySupport"| F5
    F5 -->|"calculatesTelemetry"| F3
    F3 -->|"rendersUI"| F2
    F4 -->|"stateManagement"| F2
    F2 -->|"userActions"| B1
    B1 -->|"updatesReadsData"| D1
    B2 -->|"configures"| B1
    B3 -->|"servesStaticAssets"| F1

    %% Click Events for Frontend Components
    click F1 "https://github.com/alanjsfleming/greenarrowsdashboard/tree/main/src"
    click F2 "https://github.com/alanjsfleming/greenarrowsdashboard/tree/main/src/pages"
    click F3 "https://github.com/alanjsfleming/greenarrowsdashboard/tree/main/src/pages/components"
    click F4 "https://github.com/alanjsfleming/greenarrowsdashboard/tree/main/src/contexts"
    click F5 "https://github.com/alanjsfleming/greenarrowsdashboard/blob/main/src/features/TelemetryCalculations.js"
    click F6 "https://github.com/alanjsfleming/greenarrowsdashboard/tree/main/src/utils"
    click F7 "https://github.com/alanjsfleming/greenarrowsdashboard/blob/main/src/services/dweet/handleGetDweet.js"

    %% Click Events for Backend Components
    click B1 "https://github.com/alanjsfleming/greenarrowsdashboard/blob/main/functions/src/index.ts"
    click B2 "https://github.com/alanjsfleming/greenarrowsdashboard/blob/main/firebase.json"
    click B3 "https://github.com/alanjsfleming/greenarrowsdashboard/tree/main/public"

    %% Styling Classes
    classDef external fill:#FFCC00,stroke:#333,stroke-width:2px;
    classDef frontend fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef backend fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef database fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
```
