# mauznemo/smartifyos architecture

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

- Interactive diagram: https://gitdiagram.com/mauznemo/smartifyos
- Repository: https://github.com/mauznemo/smartifyos

## Overview

##### Project type and purpose
- Unity-based monolithic application for a DIY car infotainment GUI.
- “Assets/SmartifyOS”: reusable core framework.
- “Assets/Scripts”, “Assets/ScriptableObjects”: Miata-specific controllers and UI extensions.

##### File structure
- Top-level Unity directories:
– Assets/SmartifyOS (Core framework)
– Assets/Scripts (Project-specific controllers)
– Assets/ScriptableObjects (Configuration data)
– Assets/Scenes, Assets/Materials, Assets/Prefabs (Unity runtime content)
- Packages: LeanTween, Universal Blur, TextMeshPro (third-party libs).
- ProjectSettings, Packages/manifest.json: build & deployment config.

##### README for insights
- “Assets/SmartifyOS” is the base; “Assets/Scripts” extends it for a specific car setup.
- Supported on Linux (editor & build), partial Windows editor.

##### Main components & interactions

A. Unity Engine Core (Runtime)
– Scene Management (MainScene.unity)
– Render Pipeline (URP, Blur pass)
– Main Thread Dispatcher

B. Core Framework (“Assets/SmartifyOS”)
1. SystemManager & SystemEventManager
- Boots subsystems, routes events.
2. SerialCommunication Layer
- BaseSerialCommunication, BaseLiveSerialCommunication → ARDUINO boards.
3. Bluetooth Layer
- BluetoothManager, BluetoothParser → external BLE devices.
4. Audio System
- AudioManager, FilePlayer (media playback) → filesystem.
5. UI Framework
- BaseUIManager, BaseUIWindow
- Core Windows: AppList, SettingsUIWindow, PowerOffUIWindow, etc.
- UI Components: Buttons, ToggleButtons, QuickSettings entries, VolumeOverlay, StatusBar, GraphLineRenderer, ReverseCameraOverlay.
6. SaveSystem
- SaveManager, SaveData, JSON converters
7. EditorTools (design-time helpers, only relevant in Editor)

C. Project-Specific Extensions (“Assets/Scripts”)
1. Arduino Controllers
- LightController, LockController, MainController, LiveDataController
2. AnimatedObjects
- LeftDoor, RightDoor, Trunk, PopupLights, WheelAnimator
3. UI Extensions
- ActionButtonManager, ControlwheelManager, LedManager, WarningManager
- Windows: RealtimeInfoUIWindow, ReverseCameraUIWindow, StatisticsUIWindow, ZeroTo100UIWindow
- QuickSettings entries: LockToggle, ToggleInteriorLight, ToggleWave, etc.
- Settings pages: ArduinoPorts, CameraSettings, DisplaySettings, InteriorLightingSettings, NotificationsSettings, PopupsSettings.
4. ScriptableObjects for car-specific config (AudioConfigSO, ThemeData)

D. Third-Party Libraries
- LeanTween (tween animations)
- Unified-Universal-Blur (post-processing)
- TextMeshPro (text rendering)

E. External Actors
- Arduino boards (via serial)
- Bluetooth devices (phones, sensors)
- Filesystem (media files under Assets/SmartifyOS/Audio)
- Car sensors (speed, acceleration) → via LiveDataController

##### Relationships & Data Flows
- SystemManager initializes Core Framework at startup.
- SystemEventManager broadcasts events between subsystems.
- UI Framework listens for SystemEvents; user input → UIManager → SystemEventManager → subsystems.
- SerialCommunication ↔ Arduino Controllers (commands & telemetry).
- BluetoothManager ↔ external devices.
- AudioManager ← FilePlayer reads from filesystem.
- SaveManager persists settings changes from UI.

##### Architectural patterns & principles
- Event-driven architecture (SystemEventManager).
- Layered approach: Core Framework vs. Project Extensions.
- Modular subsystems (Audio, UI, Serial, Bluetooth, Save).
- Extensibility via ScriptableObjects and base classes.

##### Essential elements
- Component labels (e.g., “BluetoothManager”).

## Diagram (Mermaid)

```mermaid
graph TD
  subgraph "External Actors" 
    Arduino["Arduino Boards"]:::external
    BLEDevices["Bluetooth Devices"]:::external
    CarSensors["Car Sensors"]:::external
    Filesystem["Filesystem"]:::external
  end

  subgraph "Third-Party Libraries"
    LeanTween["LeanTween"]:::thirdparty
    Blur["Unified-Universal-Blur"]:::thirdparty
    TextMeshPro["TextMeshPro"]:::thirdparty
  end

  subgraph "Project-Specific Extensions"
    subgraph "Arduino Controllers"
      LightController["LightController"]:::project
      LockController["LockController"]:::project
      MainController["MainController"]:::project
      LiveDataController["LiveDataController"]:::project
    end
    subgraph "AnimatedObjects"
      LeftDoor["LeftDoor"]:::project
      RightDoor["RightDoor"]:::project
      Trunk["Trunk"]:::project
      LeftPopupLight["LeftPopupLight"]:::project
      RightPopupLight["RightPopupLight"]:::project
      WheelAnimator["WheelAnimator"]:::project
    end
    subgraph "UI Extensions"
      ActionButtonManager["ActionButtonManager"]:::project
      ControlwheelManager["ControlwheelManager"]:::project
      LedManager["LedManager"]:::project
      WarningManager["WarningManager"]:::project
      subgraph "Windows"
        RealtimeInfoUIWindow["RealtimeInfoUIWindow"]:::project
        ReverseCameraUIWindow["ReverseCameraUIWindow"]:::project
        StatisticsUIWindow["StatisticsUIWindow"]:::project
        ZeroTo100UIWindow["ZeroTo100UIWindow"]:::project
      end
      subgraph "QuickSettings Entries"
        LockToggle["LockToggleQuickSettingsEntry"]:::project
        ToggleInterior["ToggleInteriorLightQuickSettingsEntry"]:::project
        TogglePopups["TogglePopupsQuickSettingsEntry"]:::project
        ToggleWave["ToggleWaveQuickSettingsEntry"]:::project
        OpenTrunk["OpenTrunkQuickSettingsEntry"]:::project
      end
      subgraph "Settings Pages"
        ArduinoPorts["ArduinoPortsSettingsPage"]:::project
        CameraSettings["CameraSettingsPage"]:::project
        DisplaySettings["DisplaySettingsPage"]:::project
        InteriorLighting["InteriorLightingSettingsPage"]:::project
        Notifications["NotificationsSettingsPage"]:::project
        PopupsSettings["PopupsSettingsPage"]:::project
      end
      ScriptableAudioSO["AudioConfigSO"]:::project
      ScriptableThemeSO["ThemeData"]:::project
    end
  end

  subgraph "Core Framework"
    SystemManager["SystemManager"]:::core
    SystemEventManager["SystemEventManager"]:::core
    subgraph "SerialCommunication"
      BaseSerialComm["BaseSerialCommunication"]:::core
      BaseLiveSerialComm["BaseLiveSerialCommunication"]:::core
    end
    subgraph "Bluetooth Layer"
      BluetoothManager["BluetoothManager"]:::core
      BluetoothParser["BluetoothParser"]:::core
    end
    subgraph "Audio System"
      AudioManager["AudioManager"]:::core
      FilePlayer["FilePlayer"]:::core
    end
    subgraph "UI Framework"
      BaseUIManager["BaseUIManager"]:::core
      BaseUIWindow["BaseUIWindow"]:::core
      subgraph "Core Windows"
        AppListUIWindow["AppListUIWindow"]:::core
        SettingsUIWindow["SettingsUIWindow"]:::core
        PowerOffUIWindow["PowerOffUIWindow"]:::core
      end
      subgraph "UI Components"
        Button["Button"]:::core
        QuickSettingsEntry["BaseQuickSettingsEntry"]:::core
        VolumeOverlay["VolumeOverlay"]:::core
        StatusBar["StatusBar"]:::core
        GraphLineRenderer["UIGraphLineRenderer"]:::core
        ReverseOverlay["UIReverseOverlay"]:::core
      end
    end
    subgraph "SaveSystem"
      SaveManager["SaveManager"]:::core
      SaveData["SaveData"]:::core
      ColorConverter["ColorConverter"]:::core
    end
    EditorTools["EditorTools"]:::core
  end

  subgraph "Unity Engine Core"
    SceneManagement["Scene Management\n(MainScene.unity)"]:::unity
    RenderPipeline["Render Pipeline\n(URP)"]:::unity
    MainThreadDispatcher["Main Thread Dispatcher"]:::unity
  end

  %% Relationships
  SceneManagement --> SystemManager
  MainThreadDispatcher --> SystemEventManager

  SystemManager --> SystemEventManager
  SystemManager --> BaseSerialComm
  SystemManager --> BluetoothManager
  SystemManager --> AudioManager
  SystemManager --> BaseUIManager
  SystemManager --> SaveManager

  BaseUIManager -->|"ButtonPressEvent"| SystemEventManager
  SystemEventManager -->|"DispatchEvent"| BaseUIManager

  SystemEventManager --> BaseSerialComm
  SystemEventManager --> BluetoothManager
  SystemEventManager --> AudioManager
  SystemEventManager --> SaveManager

  BaseSerialComm <--> LightController
  BaseSerialComm <--> LockController
  BaseSerialComm <--> MainController
  BaseLiveSerialComm <--> LiveDataController

  BluetoothManager <--> BLEDevices
  BluetoothManager --> BluetoothParser

  AudioManager --> FilePlayer
  FilePlayer --> Filesystem

  SaveManager --> Filesystem

  CarSensors --> LiveDataController

  %% Click Events
  click SceneManagement "https://github.com/mauznemo/smartifyos/blob/main/Assets/Scenes/MainScene.unity"
  click RenderPipeline "https://github.com/mauznemo/smartifyos/blob/main/Assets/Settings/URP-HighFidelity.asset"
  click MainThreadDispatcher "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/UnityMainThreadDispatcher.cs"
  click SystemManager "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/SystemManager.cs"
  click SystemEventManager "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/SystemEvents/SystemEventManager.cs"
  click BaseSerialComm "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/SerialCommunication/BaseSerialCommunication.cs"
  click BaseLiveSerialComm "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/SerialCommunication/BaseLiveSerialCommunication.cs"
  click BluetoothManager "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/Bluetooth/BluetoothManager.cs"
  click BluetoothParser "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/Bluetooth/BluetoothParser.cs"
  click AudioManager "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/Audio/AudioManager.cs"
  click FilePlayer "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/FilePlayer/PlayerManager.cs"
  click BaseUIManager "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/UI/BaseUIManager.cs"
  click BaseUIWindow "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/UI/Bases/BaseUIWindow.cs"
  click AppListUIWindow "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/UI/Core/Windows/AppListUIWindow.cs"
  click SettingsUIWindow "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/UI/Core/Windows/SettingsUIWindow.cs"
  click PowerOffUIWindow "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/UI/Core/Windows/PowerOffUIWindow.cs"
  click Button "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/UI/Components/Button.cs"
  click QuickSettingsEntry "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/UI/Components/QuickSettings/BaseQuickSettingsEntry.cs"
  click VolumeOverlay "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/UI/Components/VolumeOverlay.cs"
  click StatusBar "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/UI/Components/StatusBar/StatusBar.cs"
  click GraphLineRenderer "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/UI/Components/UIGraphLineRenderer.cs"
  click ReverseOverlay "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/UI/Components/UIReverseOvlerlay.cs"
  click SaveManager "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/SaveSystem/SaveManager.cs"
  click SaveData "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/SaveSystem/SaveData.cs"
  click ColorConverter "https://github.com/mauznemo/smartifyos/blob/main/Assets/SmartifyOS/Scripts/System/SaveSystem/JsonConverters/ColorConverter.cs"
  click LightController "https://github.com/mauznemo/smartifyos/blob/main/Assets/Scripts/Arduinos/LightController.cs"
  click LockController "https://github.com/mauznemo/smartifyos/blob/main/Assets/Scripts/Arduinos/LockController.cs"
  click MainController "https://github.com/mauznemo/smartifyos/blob/main/Assets/Scripts/Arduinos/MainController.cs"
  click LiveDataController "https://github.com/mauznemo/smartifyos/blob/main/Assets/Scripts/Arduinos/LiveDataController.cs"

  classDef core fill:#D0E6FF,stroke:#099,stroke-width:1px
  classDef project fill:#D0FFD8,stroke:#096,stroke-width:1px
  classDef thirdparty fill:#FFE0B2,stroke:#E77614,stroke-width:1px
  classDef external fill:#D3D3D3,stroke:#666,stroke-width:1px
  classDef unity fill:#E8DAEF,stroke:#8844AA,stroke-width:1px
```
