# slowlydev/f1-dash architecture

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

## Overview

##### Project Type and Purpose
- This is a full‐stack application that delivers real-time Formula 1 telemetry and timing.
- The backend is built in Rust and is split into multiple “crates” (e.g., api, client, data, env, live, saver, simulator) that handle services such as delivering API endpoints (health, schedule), processing and transforming data, managing live real-time streams, saving data, and simulating telemetry for testing.

##### File Structure
- Top-Level:
- Key files like Docker-related files (.dockerignore, docker-compose.yaml, dockerfile) and environment examples show containerization and deployment are considered.
- “crates” Directory:
- Contains several Rust crates with distinct responsibilities:
▪ api – Provides REST endpoints (health and schedule) via defined endpoints.
▪ client – Likely manages client-side communication logic.
▪ data – Performs compression, merging, and transformation of raw telemetry data.
▪ env – Manages configuration and environment variables.
▪ live – Implements the live real-time server, handling WebSocket connections, CORS, and live telemetry state.
▪ saver – Persists or archives telemetry data.
▪ simulator – Emulates telemetry data inputs, useful for development/testing.
- “dash” Directory:
- Hosts the Next.js front-end with clearly structured directories (app, components, hooks, lib, styles, stores) that underpin the UI and client-side logic.
- The modern tech stack (Next.js, Tailwind CSS, TypeScript) is used for a responsive and highly interactive web app.

##### README
- The README is brief and emphasizes that the project is an unofficial real-time F1 dashboard. It invites contributions and explains that the project shows various telemetry data such as leader boards, tires, laps, and mini sectors.

##### Instructing the Principal Software Engineer to Include the Following Elements
- Component Labels:
- Use clear, descriptive labels for each component: “Frontend Dashboard,” “API Service,” “Live Telemetry Server,” “Data Processor,” “Simulator,” “Saver,” “Environment Manager,” etc.
- Data or control flow between components—e.g., from the “Frontend Dashboard” to the “API Service” (HTTP requests), and from the “Live Telemetry Server” back to the dashboard (WebSocket events).
- Visual Differentiation:
- Annotations:

##### Final Touch – Make it Pretty
- Components logically (e.g., group backend services together) and maintain ample whitespace to avoid clutter.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Level: User
    UB("User Browser"):::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        FD("Frontend Dashboard"):::frontend
    end

    %% Backend Services
    subgraph "Backend Services"
        API("API Service"):::backend
        LT("Live Telemetry Server"):::backend
        DP("Data Processor"):::backend
        SIM("Simulator"):::backend
        SAV("Saver Service"):::backend
        CC("Client Communication Module"):::backend
        ENV("Environment Manager"):::backend
    end

    %% Deployment & Configuration
    subgraph "Deployment & Configuration"
        DEP("Docker & Deployment"):::infra
    end

    %% Connections between User and Frontend
    UB -->|"HTTP"| FD

    %% Connections from Frontend to Backend Services
    FD -->|"REST_API"| API
    FD -->|"WebSocket"| LT

    %% Backend internal interactions
    API -->|"data_process"| DP
    SIM -->|"simulate_data"| LT
    SIM -->|"simulate_data"| DP
    SAV -->|"persist_data"| LT
    SAV -->|"persist_data"| DP
    CC -->|"communicate"| API

    %% Environment Manager supports all backend services
    ENV --> API
    ENV --> LT
    ENV --> DP
    ENV --> SIM
    ENV --> SAV
    ENV --> CC

    %% Deployment influences all layers
    DEP --> FD
    DEP --> API
    DEP --> LT
    DEP --> DP
    DEP --> SIM
    DEP --> SAV
    DEP --> CC
    DEP --> ENV

    %% Click Events for Component Mapping
    click FD "https://github.com/slowlydev/f1-dash/tree/main/dash/"
    click API "https://github.com/slowlydev/f1-dash/tree/main/crates/api/src/endpoints"
    click LT "https://github.com/slowlydev/f1-dash/tree/main/crates/live/src/server/"
    click DP "https://github.com/slowlydev/f1-dash/blob/main/crates/data/src/compression.rs"
    click SIM "https://github.com/slowlydev/f1-dash/blob/main/crates/simulator/src/main.rs"
    click SAV "https://github.com/slowlydev/f1-dash/blob/main/crates/saver/src/main.rs"
    click CC "https://github.com/slowlydev/f1-dash/blob/main/crates/client/src/client.rs"
    click ENV "https://github.com/slowlydev/f1-dash/blob/main/crates/env/src/env.rs"
    click DEP "https://github.com/slowlydev/f1-dash/blob/main/docker-compose.yaml"

    %% Styles
    classDef frontend fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef backend fill:#AED6F1,stroke:#2E86C1,stroke-width:2px;
    classDef infra fill:#A9DFBF,stroke:#28B463,stroke-width:2px;
    classDef external fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
```
