# autorope/donkeycar architecture

> Architecture diagram of the GitHub repository autorope/donkeycar, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/autorope/donkeycar
- Repository: https://github.com/autorope/donkeycar

## Overview

##### Main System Components

a) Core Vehicle System:
- Vehicle Controller (central orchestrator)
- Parts Pipeline System
- Memory Management System
- Configuration System

b) Parts Subsystems:
- Input Systems (Cameras, Controllers, Sensors)
- Processing Systems (Computer Vision, Neural Networks)
- Output Systems (Motor Controllers, Actuators)
- Storage Systems (Data Recording)

##### Architectural Patterns to Highlight

a) Pipeline Architecture:
- Flow of data through the parts system
- Modular nature of components
- Threaded execution model

b) Plugin Architecture:
- How different parts can be added/removed
- Template system for different configurations
- Extension points

**[Hardware Layer]**
- ↑↓
**[Device Interfaces]**
- ↑↓
**[Core System]**
- ↑↓
**[Processing Pipeline]**
- ↑↓
**[Storage & Telemetry]**

##### Key Relationships

a) Data Flow:
- Camera → Image Processing → Neural Network → Motor Control
- Controller → Vehicle Management → Motor Control
- Sensors → Data Collection → Storage

b) Control Flow:
- Vehicle Loop Orchestration
- Part Management
- Configuration Management

##### Implementation Details

- donkeycar/vehicle.py (core orchestration)
- donkeycar/parts/* (modular components)
- donkeycar/management/* (management tools)
- donkeycar/pipeline/* (data pipeline)

##### External Interfaces

Connections to:
- Web Controller Interface
- Training Systems
- Simulator Integration
- Remote Management Tools

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Hardware
        CAM[Camera]:::hardware
        CTRL[Controller]:::hardware
        SENS[Sensors]:::hardware
        MOT[Motors]:::hardware
    end

    subgraph "Device Interfaces"
        CAMI["Camera Interface"]:::interface
        click CAMI "https://github.com/autorope/donkeycar/blob/main/donkeycar/parts/camera.py"
        CTRLI["Controller Interface"]:::interface
        click CTRLI "https://github.com/autorope/donkeycar/blob/main/donkeycar/parts/controller.py"
        SENSI["Sensor Interface"]:::interface
        click SENSI "https://github.com/autorope/donkeycar/blob/main/donkeycar/parts/imu.py"
        MOTI["Actuator Interface"]:::interface
        click MOTI "https://github.com/autorope/donkeycar/blob/main/donkeycar/parts/actuator.py"
    end

    subgraph "Core System"
        VC["Vehicle Controller"]:::core
        click VC "https://github.com/autorope/donkeycar/blob/main/donkeycar/vehicle.py"
        MEM["Memory Manager"]:::core
        click MEM "https://github.com/autorope/donkeycar/blob/main/donkeycar/memory.py"
        CONF["Configuration System"]:::core
        click CONF "https://github.com/autorope/donkeycar/blob/main/donkeycar/config.py"
        TMPL["Templates System"]:::core
        click TMPL "https://github.com/autorope/donkeycar/tree/main/donkeycar/templates/"
    end

    subgraph "Processing Pipeline"
        CV["Computer Vision"]:::processing
        click CV "https://github.com/autorope/donkeycar/blob/main/donkeycar/parts/cv.py"
        NN["Neural Networks"]:::processing
        click NN "https://github.com/autorope/donkeycar/blob/main/donkeycar/parts/keras.py"
        PIPE["Pipeline Manager"]:::processing
        click PIPE "https://github.com/autorope/donkeycar/tree/main/donkeycar/pipeline/"
        TRAIN["Training Pipeline"]:::processing
        click TRAIN "https://github.com/autorope/donkeycar/blob/main/donkeycar/pipeline/training.py"
    end

    subgraph "Storage & Telemetry"
        DS["Data Storage"]:::storage
        click DS "https://github.com/autorope/donkeycar/blob/main/donkeycar/parts/datastore_v2.py"
        WEB["Web Controller"]:::interface
        click WEB "https://github.com/autorope/donkeycar/tree/main/donkeycar/parts/web_controller/"
        MGT["Management Tools"]:::management
        click MGT "https://github.com/autorope/donkeycar/tree/main/donkeycar/management/"
    end

    %% Hardware to Interface Connections
    CAM --> CAMI
    CTRL --> CTRLI
    SENS --> SENSI
    MOTI --> MOT

    %% Interface to Core Connections
    CAMI --> VC
    CTRLI --> VC
    SENSI --> VC
    VC --> MOTI

    %% Core System Connections
    VC --> MEM
    VC --> CONF
    TMPL --> CONF
    PIPE --> VC

    %% Processing Pipeline Connections
    CAMI --> CV
    CV --> NN
    NN --> PIPE
    PIPE --> TRAIN

    %% Storage & Management Connections
    VC --> DS
    WEB --> VC
    MGT --> VC
    DS --> TRAIN

    %% Styles
    classDef hardware fill:#d3d3d3,stroke:#333,stroke-width:2px
    classDef interface fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef processing fill:#FFD700,stroke:#333,stroke-width:2px
    classDef storage fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef management fill:#F08080,stroke:#333,stroke-width:2px

    %% Legend
    HWLEG["Hardware"]:::hardware
    INTLEG["Interfaces"]:::interface
    CORLEG["Core System"]:::core
    PROLEG["Processing"]:::processing
    STLEG["Storage"]:::storage
    MGMTLEG["Management"]:::management
```
