# martinschaer/protogotchi architecture

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

- Interactive diagram: https://gitdiagram.com/martinschaer/protogotchi
- Repository: https://github.com/martinschaer/protogotchi

## Overview

##### Main Components Identification
The project appears to be a Rust-based embedded system application with several distinct modules. Here's how to represent the main architectural components:

a) Core System Layer:
- Base systems.rs as a fundamental controller

b) Feature Modules:
- Hardware Module (hardware/)
- Input Module (input/)
- Menu System (menu/)
- Settings Module (settings/)
- Simulation Module (sim/)
- Splash Screen Module (splash/)
- Plugin System (plugins/)

##### Component Relationships

a) Hierarchical Layout:
**Top Layer: Hardware Interface**
**Middle Layer: Core Systems**
**Bottom Layer: Feature Modules**

b) Dependencies and Data Flow:
- Hardware interactions flowing down from the Hardware Module
- Plugin system as a side-connected extensible component
- Menu system to other modules as it likely serves as a navigation hub

##### Specific Component Details

Hardware Layer:
- LCD Display interface
- Input system connections
- Resource management system

Core Systems:
- Main runtime environment
- System state management
- Resource coordination

Feature Modules:
- Each module should show its resources and systems subcomponents
- WiFi settings module as a special hardware-dependent feature

##### Implementation Details

- Deployment path (using the deploy/ directory structure)
- Build pipeline for ARM architecture
- System service integration points (protogotchi.service)

**1. Runtime Environment**
- Hardware abstraction
- Core systems
- Resource management

**2. Feature Modules**
- Menu system
- Settings
- Simulation
- Input handling

**3. External Interfaces**
- Display output
- User input
- WiFi connectivity

##### Additional Notes

- Version/build information
- Target platform (Raspberry Pi Zero 2 W)
- Cross-compilation requirements

## Diagram (Mermaid)

```mermaid
graph TB
    %% Runtime Environment Section
    subgraph Runtime
        CR[Core Runtime]
        BS[Base Systems Controller]
        RM[Resource Manager]
    end

    %% Hardware Layer Section
    subgraph Hardware
        HM[Hardware Module]
        HS[Hardware Systems]
        HR[Hardware Resources]
        LCD[LCD Display]
        GPIO[GPIO Interface]
    end

    %% Feature Modules Section
    subgraph Features
        %% Menu System
        MS[Menu System]
        MSys[Menu Systems]
        MR[Menu Resources]

        %% Settings Module
        SM[Settings Module]
        SS[Settings Systems]
        WS[WiFi Subsystem]
        WSys[WiFi Systems]

        %% Input Module
        IM[Input Module]
        IS[Input Systems]

        %% Simulation Module
        SIM[Simulation Module]
        SI[Simulation Interface]

        %% Splash Screen
        SP[Splash Screen]
        SPS[Splash Systems]
    end

    %% Plugin System Section
    subgraph Plugins
        PS[Plugin System]
        PSF[Plugin Select Feature]
        PSS[Plugin Select Systems]
        PSR[Plugin Select Resources]
    end

    %% Deployment Section
    subgraph Deployment
        DS[Deployment System]
        AC[Ansible Config]
        SVC[System Service]
    end

    %% Relationships
    CR --> BS
    BS --> RM
    
    HM --> HS
    HS --> HR
    HM --> LCD
    HM --> GPIO
    
    MS --> MSys
    MSys --> MR
    
    SM --> SS
    SS --> WS
    WS --> WSys
    
    IM --> IS
    
    SIM --> SI
    
    SP --> SPS
    
    PS --> PSF
    PSF --> PSS
    PSS --> PSR
    
    DS --> AC
    DS --> SVC

    %% Cross-layer connections
    BS --> HM
    BS --> MS
    BS --> SM
    BS --> IM
    BS --> SIM
    BS --> SP
    BS --> PS

    %% Click events for component mapping
    click CR "https://github.com/martinschaer/protogotchi/blob/main/src/main.rs"
    click BS "https://github.com/martinschaer/protogotchi/blob/main/src/systems.rs"
    click HM "https://github.com/martinschaer/protogotchi/tree/main/src/hardware/"
    click HS "https://github.com/martinschaer/protogotchi/blob/main/src/hardware/systems.rs"
    click HR "https://github.com/martinschaer/protogotchi/blob/main/src/hardware/resources.rs"
    click IM "https://github.com/martinschaer/protogotchi/tree/main/src/input/"
    click IS "https://github.com/martinschaer/protogotchi/blob/main/src/input/systems.rs"
    click MS "https://github.com/martinschaer/protogotchi/tree/main/src/menu/"
    click MSys "https://github.com/martinschaer/protogotchi/blob/main/src/menu/systems.rs"
    click MR "https://github.com/martinschaer/protogotchi/blob/main/src/menu/resources.rs"
    click SM "https://github.com/martinschaer/protogotchi/tree/main/src/settings/"
    click SS "https://github.com/martinschaer/protogotchi/blob/main/src/settings/systems.rs"
    click WS "https://github.com/martinschaer/protogotchi/tree/main/src/settings/wifi/"
    click WSys "https://github.com/martinschaer/protogotchi/blob/main/src/settings/wifi/systems.rs"
    click SIM "https://github.com/martinschaer/protogotchi/tree/main/src/sim/"
    click SI "https://github.com/martinschaer/protogotchi/blob/main/src/sim/mod.rs"
    click SP "https://github.com/martinschaer/protogotchi/tree/main/src/splash/"
    click SPS "https://github.com/martinschaer/protogotchi/blob/main/src/splash/systems.rs"
    click PS "https://github.com/martinschaer/protogotchi/tree/main/src/plugins/"
    click PSF "https://github.com/martinschaer/protogotchi/tree/main/src/plugins/select/"
    click PSS "https://github.com/martinschaer/protogotchi/blob/main/src/plugins/select/systems.rs"
    click PSR "https://github.com/martinschaer/protogotchi/blob/main/src/plugins/select/resources.rs"
    click DS "https://github.com/martinschaer/protogotchi/tree/main/deploy/"
    click AC "https://github.com/martinschaer/protogotchi/tree/main/deploy/ansible/"
    click SVC "https://github.com/martinschaer/protogotchi/blob/main/deploy/ansible/roles/protogotchi/files/protogotchi.service"

    %% Styling
    classDef core fill:#a8dadc,stroke:#457b9d
    classDef hardware fill:#e63946,stroke:#1d3557
    classDef feature fill:#f1faee,stroke:#1d3557
    classDef plugin fill:#457b9d,stroke:#1d3557
    classDef deployment fill:#1d3557,stroke:#457b9d

    class CR,BS,RM core
    class HM,HS,HR,LCD,GPIO hardware
    class MS,MSys,MR,SM,SS,WS,WSys,IM,IS,SIM,SI,SP,SPS feature
    class PS,PSF,PSS,PSR plugin
    class DS,AC,SVC deployment
```
