# kolabse/car-emulator architecture

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

- Interactive diagram: https://gitdiagram.com/kolabse/car-emulator
- Repository: https://github.com/kolabse/car-emulator

## Overview

##### Project type and purpose
- This is an embedded-firmware project for an ESP8266 microcontroller that bridges or interfaces with a CAN bus using an MCP2515 SPI CAN controller and a TJA1050 (or TJA1055) CAN transceiver. PlatformIO (platformio.ini) is used as the build and deployment system.

##### File structure
- Top level
- .gitignore / .vscode – IDE and VCS configs
- platformio.ini – specifies the ESP8266 platform, build flags, library dependencies (e.g., SPI, MCP2515 driver).
- README.md – lists hardware components (ESP8266 + MCP2515 + TJA1050).
- src/main.cpp – contains the application code, including initialization of SPI, MCP2515 driver, CAN bus routines, and any Wi-Fi logic.

##### README for additional insights
- Confirms hardware stack: ESP8266 ↔ SPI ↔ MCP2515 ↔ TJA1050 ↔ CAN bus.
- Implies the code likely performs one or more of the following: CAN message transmit/receive, protocol translation, or Wi-Fi-to-CAN gateway.

##### Details
- Initialization sequence: power-up → SPI init → MCP2515 reset → transceiver enable.
- Interrupt line from MCP2515 to an ESP8266 GPIO if used.
- Essential timing or frequency info (e.g., SPI clock speed, CAN bit rate) as annotations.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Software Layer
    subgraph "Software Layer"
        PIO["PlatformIO Build & Dependency Config"]:::config
        APP["ESP8266 Application Logic"]:::mcu
        DOC["Project Documentation & Hardware Overview"]:::doc
        IDE["IDE & Editor Configuration"]:::config
        VCS["Version Control Exclusions"]:::config
    end

    PIO -->|uses| APP
    PIO -->|defines build| IDE
    PIO -->|defines build| VCS
    DOC -->|documents| APP

    %% Hardware Layer
    subgraph "Hardware Layer"
        MCU["ESP8266 MCU"]:::mcu
        SPI["SPI Bus\n(MOSI/MISO/SCK/CS)"]:::bus
        CANCTRL["MCP2515 CAN Controller"]:::peri
        TRANS["TJA1050 CAN Transceiver"]:::peri
        CANSYS["External CAN Bus"]:::bus
        NET["External Network/Cloud"]:::external
    end

    APP -->|runs on| MCU
    MCU -->|SPI| SPI
    SPI -->|SPI| CANCTRL
    CANCTRL -->|TX/RX| TRANS
    TRANS -->|CAN_H/CAN_L| CANSYS
    MCU -->|Wi-Fi TCP/UDP| NET
    CANCTRL -->|INT| MCU

    %% Click Events
    click APP "https://github.com/kolabse/car-emulator/blob/master/src/main.cpp"
    click PIO "https://github.com/kolabse/car-emulator/blob/master/platformio.ini"
    click DOC "https://github.com/kolabse/car-emulator/blob/master/README.md"
    click IDE "https://github.com/kolabse/car-emulator/tree/master/.vscode/"
    click VCS "https://github.com/kolabse/car-emulator/blob/master/.gitignore"

    %% Styles
    classDef mcu fill:#e0f7fa,stroke:#0288d1
    classDef peri fill:#ffe0b2,stroke:#ef6c00
    classDef bus fill:#fff9c4,stroke:#f9a825
    classDef config fill:#e1bee7,stroke:#8e24aa
    classDef doc fill:#c8e6c9,stroke:#388e3c
    classDef external fill:#d7ccc8,stroke:#5d4037
```
