# maddisagar/raw_can architecture

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

- Interactive diagram: https://gitdiagram.com/maddisagar/raw_can
- Repository: https://github.com/maddisagar/raw_can

## Overview

##### Project type and purpose
- This is a full-stack telemetry dashboard built with Next.js (React) that visualizes real-time CAN-bus data, decoded via an Arduino/JavaScript pipeline.
- The README confirms it's a Next.js application, bootstrapped with create-next-app, serving up a front-end on port 3000.

##### File structure
Top-level entries:
- components/ – dozens of React UI pieces (charts, gauges, status cards), plus CAN decoding scripts (canDecoder.js, dbc files, Arduino C++ code).
- src/app/ – the Next.js App Router directory (layout.tsx, page.tsx, CSS).
- Configuration files – next.config.mjs, tsconfig.json, jsconfig.json, postcss.config.mjs, eslint.config.mjs.
- package.json, package-lock.json – lists Next.js, React, WebSocket libraries, charting utilities.
Patterns & clues:
- components/data-context.js – React Context for passing live data.
- components/websocketurl.js – likely holds the URL for a live WebSocket server.
- Arduino code and DBC files indicate a hardware ingestion pipeline.

##### README for additional insights
- It's a Next.js front-end only. No backend code here, so the real-time data must come from an external service (e.g., a Node.js WebSocket server you deploy separately, or from the Arduino via serial-to-WebSocket bridge).
- Deployment target is Vercel, but the real-time pipeline is external.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hardware Layer
    subgraph "Hardware Layer"
        CANbus["CAN Bus Network"]:::hardware
        Arduino["Arduino CAN Ingestor"]:::hardware
        ArduinoAlt["Alternative Arduino Sketch"]:::hardware
    end

    %% Middleware Ingestion Layer
    subgraph "Ingestion Layer"
        DecoderService["CAN Decoder Service"]:::service
        DBCDefs["DBC Definitions"]:::service
    end

    %% WebSocket Layer
    subgraph "WebSocket Layer"
        WSURL["WebSocket Server URL Config"]:::service
        WebSocketServer["WebSocket Server"]:::service
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        NextLayout["Next.js Layout"]:::frontend
        NextPage["Next.js Main Page"]:::frontend
        GlobalsCSS["globals.css"]:::frontend
        DatePickerCSS["date-picker.css"]:::frontend
        DataContext["React Data Context"]:::data
        Dashboard["Dashboard Container"]:::frontend
        Metrics["Metric Visualizations"]:::frontend
        ChartJS["Chart Utilities (chart.js)"]:::frontend
        MuiGraph["Chart Utilities (mui-graph.js)"]:::frontend
        AlertsSys["System Alerts"]:::frontend
        AlertsCrit["Critical Alerts List"]:::frontend
        UICard["UI Card Wrapper"]:::frontend
        MobileNav["Mobile Navigation"]:::frontend
        FooterComp["Footer Component"]:::frontend
        FooterCtx["Footer Context"]:::frontend
    end

    %% Client Browser
    subgraph "Client Browser"
        Browser["User Browser"]:::external
    end

    %% Connections
    CANbus --> Arduino
    CANbus --> ArduinoAlt
    Arduino --> DecoderService
    ArduinoAlt --> DecoderService
    DecoderService --> DBCDefs
    DecoderService --> WebSocketServer
    WebSocketServer -->|WebSocket Stream| Browser
    Browser -->|HTTP Request| NextPage
    NextPage --> NextLayout
    NextPage --> GlobalsCSS
    NextPage --> DatePickerCSS
    NextLayout --> MobileNav
    NextLayout --> Dashboard
    NextLayout --> FooterComp
    NextLayout --> FooterCtx
    Dashboard --> DataContext
    DataContext --> Metrics
    DataContext --> AlertsSys
    DataContext --> AlertsCrit
    Metrics --> ChartJS
    Metrics --> MuiGraph
    AlertsSys --> UICard
    AlertsCrit --> UICard

    %% Click Events
    click Arduino "https://github.com/maddisagar/raw_can/blob/main/components/decodeCANarduino.c++"
    click ArduinoAlt "https://github.com/maddisagar/raw_can/blob/main/components/arduino_code.c++"
    click DBCDefs "https://github.com/maddisagar/raw_can/blob/main/components/dbc_v08_1.c"
    click DecoderService "https://github.com/maddisagar/raw_can/blob/main/components/canDecoder.js"
    click DataContext "https://github.com/maddisagar/raw_can/blob/main/components/data-context.js"
    click WSURL "https://github.com/maddisagar/raw_can/blob/main/components/websocketurl.js"
    click NextLayout "https://github.com/maddisagar/raw_can/blob/main/src/app/layout.tsx"
    click NextPage "https://github.com/maddisagar/raw_can/blob/main/src/app/page.tsx"
    click GlobalsCSS "https://github.com/maddisagar/raw_can/blob/main/src/app/globals.css"
    click DatePickerCSS "https://github.com/maddisagar/raw_can/blob/main/src/app/date-picker.css"
    click Dashboard "https://github.com/maddisagar/raw_can/blob/main/components/dashboard.js"
    click Metrics "https://github.com/maddisagar/raw_can/tree/main/components/metrics/"
    click ChartJS "https://github.com/maddisagar/raw_can/blob/main/components/chart.js"
    click MuiGraph "https://github.com/maddisagar/raw_can/blob/main/components/mui-graph.js"
    click AlertsSys "https://github.com/maddisagar/raw_can/blob/main/components/system-alerts.js"
    click AlertsCrit "https://github.com/maddisagar/raw_can/blob/main/components/critical-alerts-list.js"
    click UICard "https://github.com/maddisagar/raw_can/blob/main/components/ui/card.js"
    click MobileNav "https://github.com/maddisagar/raw_can/blob/main/components/mobile-nav.js"
    click FooterComp "https://github.com/maddisagar/raw_can/blob/main/components/Footer.tsx"
    click FooterCtx "https://github.com/maddisagar/raw_can/blob/main/components/FooterContext.js"

    %% Styles
    classDef hardware fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef service fill:#89CFF0,stroke:#333,stroke-width:1px
    classDef frontend fill:#FFA500,stroke:#333,stroke-width:1px
    classDef data fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
