# gizmo-platform/gizmo architecture

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

- Interactive diagram: https://gitdiagram.com/gizmo-platform/gizmo
- Repository: https://github.com/gizmo-platform/gizmo

## Overview

##### Main System Components

a) Core Components:
- Gizmo Hardware Platform
- Firmware System
- Utilities (this repository)
- Arduino Library Interface
- Driver Station (DS)
- Field Management System (FMS)

b) Supporting Services:
- MQTT Server
- HTTP Server
- Configuration Server
- Metrics System
- Watchdog Service
- Game Controller Interface

##### Architectural Layers

Top Layer:
- User Interface Components (FMS HUD, Configuration Interfaces)
- Field Management System (FMS)
- Driver Station (DS)

Middle Layer:
- Core Services (MQTT, HTTP, Metrics)
- Configuration Management
- System Setup and Management

Bottom Layer:
- Hardware Interface
- Arduino Integration
- Firmware Communication

##### Implementation Details

- Component name
- Key responsibilities
- Primary interfaces
- Dependencies

- Package hierarchies (internal/cmdlets, pkg/*)
- Service groupings
- Component relationships

##### Critical Flows

- Setup workflow (fms_setup_wizard.go)
- Configuration management (pkg/config)
- Hardware communication (pkg/gamepad)
- Monitoring and metrics (pkg/metrics)
- Network management (pkg/routeros)

##### Additional Notes

- Relationship between the different repositories (hardware, firmware, utilities)
- Points of extension and customization
- Critical paths and failure points

- Hierarchical layouts
- Custom styling
- Export to standard formats

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph User_Interface
        FMS_HUD[FMS HUD]:::ui
        Config_UI[Configuration Interface]:::ui
    end

    subgraph Management_Layer
        FMS[Field Management System]:::core
        DS[Driver Station]:::core
        Setup[Setup Wizard]:::setup
    end

    subgraph Service_Layer
        MQTT[MQTT Server]:::comm
        HTTP[HTTP Server]:::comm
        Config[Configuration Server]:::config
        Metrics[Metrics System]:::util
        Watchdog[Watchdog Service]:::util
    end

    subgraph System_Layer
        SysConfig[System Configuration]:::config
        RouterConfig[RouterOS Configuration]:::config
        NetMgmt[Network Management]:::util
    end

    subgraph Hardware_Layer
        GameCtrl[Game Controller]:::hw
        Arduino[Arduino Library]:::hw
        Firmware[Firmware System]:::hw
        GizmoHW[Gizmo Hardware]:::hw
    end

    %% Relationships
    FMS_HUD --> FMS
    Config_UI --> Config
    
    FMS --> MQTT
    FMS --> HTTP
    DS --> MQTT
    DS --> HTTP
    
    Setup --> SysConfig
    Setup --> RouterConfig
    
    MQTT --> Metrics
    HTTP --> Metrics
    Watchdog --> |Monitors| Service_Layer
    
    DS --> GameCtrl
    GameCtrl --> Firmware
    Firmware --> GizmoHW
    Firmware --> Arduino
    
    SysConfig --> NetMgmt
    RouterConfig --> NetMgmt

    %% Click Events
    click FMS "https://github.com/gizmo-platform/gizmo/blob/master/pkg/fms/fms.go"
    click FMS_HUD "https://github.com/gizmo-platform/gizmo/blob/master/pkg/fms/hud.go"
    click DS "https://github.com/gizmo-platform/gizmo/blob/master/pkg/ds/ds.go"
    click MQTT "https://github.com/gizmo-platform/gizmo/blob/master/pkg/mqttserver/mqtt.go"
    click HTTP "https://github.com/gizmo-platform/gizmo/blob/master/pkg/http/server.go"
    click Config "https://github.com/gizmo-platform/gizmo/blob/master/pkg/config/server.go"
    click Metrics "https://github.com/gizmo-platform/gizmo/blob/master/pkg/metrics/metrics.go"
    click Watchdog "https://github.com/gizmo-platform/gizmo/blob/master/pkg/watchdog/watchdog.go"
    click GameCtrl "https://github.com/gizmo-platform/gizmo/blob/master/pkg/gamepad/gamepad.go"
    click RouterConfig "https://github.com/gizmo-platform/gizmo/tree/master/pkg/routeros/config"
    click SysConfig "https://github.com/gizmo-platform/gizmo/blob/master/pkg/sysconf/sysconf.go"
    click Setup "https://github.com/gizmo-platform/gizmo/blob/master/internal/cmdlets/fms_setup_wizard.go"
    click NetMgmt "https://github.com/gizmo-platform/gizmo/blob/master/pkg/tlm/net/net.go"

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef comm fill:#2ecc71,stroke:#27ae60,color:white
    classDef config fill:#e67e22,stroke:#d35400,color:white
    classDef util fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef hw fill:#9b59b6,stroke:#8e44ad,color:white
    classDef ui fill:#34495e,stroke:#2c3e50,color:white
    classDef setup fill:#f1c40f,stroke:#f39c12,color:black

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Communication Services]:::comm
        L3[Configuration Components]:::config
        L4[Utilities]:::util
        L5[Hardware Components]:::hw
        L6[User Interface]:::ui
        L7[Setup Components]:::setup
    end
```
