# mehdiabidri/vision architecture

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

- Interactive diagram: https://gitdiagram.com/mehdiabidri/vision
- Repository: https://github.com/mehdiabidri/vision

## Overview

1. **Overall shape**
   - This repo is a small Adaptive AUTOSAR-inspired platform split into clear layers:
     - `runtime/` for boot and orchestration,
     - `core/` for messaging and service lifecycle abstractions,
     - `services/` for platform services,
     - `hal/` for hardware-specific adapters,
     - `apps/` for adaptive applications.
   - The architecture is event-driven and service-oriented rather than request/response or UI-centric.

2. **Startup and boot pipeline**
   - `main.cpp` likely enters `runtime::Startup` / `runtime::Runtime`.
   - Boot progression is modeled explicitly with `BootStageEvent` and `ExecutionStateEvent`.
   - The README indicates a simulated chain such as BootROM → XBL → ABL → Kernel → Foundation Platform → Adaptive startup.
   - This makes boot a first-class data flow, not just a one-time initialization step.

3. **Runtime orchestration boundary**
   - `runtime/Runtime`, `RuntimeContext`, `Startup`, and `HardwareInfo` define the platform’s top-level execution context.
   - `RuntimeContext` likely holds shared references to the event bus, service manager, configuration, and discovered hardware state.
   - `HardwareInfo` acts as the dynamic “machine manifest” produced at runtime rather than baked into the build.

4. **Core communication backbone**
   - `core/EventBus.hpp` is the central message bus used by all services and applications.
   - Events are typed: `BootStageEvent`, `ExecutionStateEvent`, `PlatformDiscoveredEvent`, `CameraStateEvent`, `Frame`.
   - This is the main decoupling boundary: producers publish events, consumers subscribe without direct dependencies.

5. **Service lifecycle and orchestration**
   - `core/ServiceManager.hpp` and `core/IService.hpp` define the lifecycle contract for services.
   - The service manager is responsible for initialize/start/stop sequencing and platform orchestration.
   - `ExecutionManager.hpp` and `ExecutionStateEvent.hpp` suggest a separate execution-state coordination layer, similar to Adaptive exec management.

6. **Foundation-platform style services**
   - `services/PlatformDiscoveryService` is the key foundation service.
   - It discovers hardware at runtime and publishes `PlatformDiscoveredEvent` carrying `HardwareInfo`.
   - `services/LoggerService`, `EventMonitor`, and `FailureManager` act as cross-cutting platform services: logging, observability, and fault handling.

7. **Hardware abstraction layer**
   - `hal/` contains adapters for environment-specific behavior:
     - `UsbCameraSource.hpp` for real camera input,
     - `SimulatedBootProvider.hpp` and `QualcommBootProvider.hpp` for boot-stage sourcing,
     - `IBootProvider.hpp` and `ICameraSource.hpp` as abstraction interfaces.
   - This boundary lets the same service logic run against real Linux hardware or simulated inputs.

8. **Platform discovery data flow**
   - The README states `PlatformDiscoveryService` reads the real EDID from `/sys/class/drm/card1-eDP-1/edid`.
   - That data comes from Linux GPU driver exposure, is parsed into vendor/model/resolution/year, and then published as `PlatformDiscoveredEvent`.
   - So the flow is: Linux sysfs hardware source → discovery service → event bus → consumers.

9. **Camera pipeline**
   - `core/Frame.hpp`, `core/ICameraSource.hpp`, `services/CameraService.hpp`, and `hal/UsbCameraSource.hpp` indicate a camera capture path.
   - `config/camera.yaml` suggests camera parameters are externalized.
   - The likely flow is: config → camera source selection/setup → frames → camera service → event bus → app consumers.

10. **Adaptive application layer**
   - `apps/DisplayApp.hpp` is the main adaptive application in the tree.
   - It likely subscribes to platform discovery and camera/frame events, then renders or displays current state.
   - The app layer is intentionally thin and depends on services/events rather than directly touching hardware.

11. **Configuration and platform utilities**
   - `platform/ConfigurationManager.*` centralizes config loading.
   - `platform/Logger.hpp` and `platform/TimeService.hpp` provide shared infrastructure used by multiple services.
   - These are utility boundaries, not business logic; they support services and runtime coordination.

12. **External dependencies and runtime environment**
   - The project targets Linux and relies on real OS-exposed hardware interfaces such as `/sys/class/drm/.../edid` and USB webcam devices.
   - CMake is the build system, which fits a native C++ runtime rather than a managed application stack.
   - The architecture is therefore “embedded-style on PC Linux”: hardware-adjacent services with an AUTOSAR-like runtime model.

13. **What to show in an architecture diagram**
   - Draw `main` → `Startup/Runtime` → `ServiceManager`.
   - Place `EventBus` as the central hub connecting services and apps.
   - Show `hal` as the hardware adapter layer feeding services.
   - Show `PlatformDiscoveryService` consuming Linux hardware data and publishing `PlatformDiscoveredEvent`.
   - Show `CameraService` consuming `ICameraSource` and publishing `Frame`/camera state.
   - Show `DisplayApp` consuming events from the bus, not calling hardware directly.

14. **Key design intent**
   - The repo’s main purpose is to demonstrate an AUTOSAR Adaptive-style separation of concerns:
     - boot/execution management,
     - service-oriented communication,
     - runtime hardware discovery,
     - application/service decoupling.
   - The architecture is deliberately modular so individual services, boot providers, or camera sources can be swapped without changing the rest of the platform.

Main entry points: [`core/ServiceManager.hpp`](https://github.com/mehdiabidri/vision/blob/main/core/ServiceManager.hpp) (ServiceManager), [`services/PlatformDiscoveryService.hpp`](https://github.com/mehdiabidri/vision/blob/main/services/PlatformDiscoveryService.hpp) (Discovery), [`services/CameraService.hpp`](https://github.com/mehdiabidri/vision/blob/main/services/CameraService.hpp) (CameraSvc), [`core/EventBus.hpp`](https://github.com/mehdiabidri/vision/blob/main/core/EventBus.hpp) (EventBus)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_main(("main<br/>entrypoint<br/>[main.cpp]"))
  node_startup["Startup<br/>boot orchestrator<br/>[Startup.hpp]"]
  node_runtimecore["Runtime<br/>execution shell<br/>[Runtime.hpp]"]
  node_context["Context<br/>shared state<br/>[RuntimeContext.hpp]"]
  node_hwinfo["HardwareInfo<br/>runtime model<br/>[HardwareInfo.hpp]"]
end

subgraph group_core["Core"]
  node_eventbus{{"EventBus<br/>message bus<br/>[EventBus.hpp]"}}
  node_servicemgr["ServiceManager<br/>lifecycle manager<br/>[ServiceManager.hpp]"]
  node_execmgr["ExecManager<br/>state coordinator"]
  node_platformdisc_evt["PlatformEvent<br/>domain event"]
  node_boot_evt["BootEvent<br/>domain event<br/>[BootStageEvent.hpp]"]
  node_exec_evt["ExecState<br/>domain event"]
  node_camera_evt["CameraEvent<br/>domain event"]
  node_frame["Frame<br/>data event<br/>[Frame.hpp]"]
end

subgraph group_services["Services"]
  node_platformdisc["Discovery<br/>foundation service"]
  node_camera["CameraSvc<br/>media service<br/>[CameraService.hpp]"]
  node_logger["LoggerSvc<br/>observability service<br/>[LoggerService.hpp]"]
  node_monitor["Monitor<br/>observability service<br/>[EventMonitor.hpp]"]
  node_failure["FailureMgr<br/>fault service<br/>[FailureManager.hpp]"]
end

subgraph group_hal["HAL"]
  node_bootprov["BootProvider<br/>adapter interface<br/>[IBootProvider.hpp]"]
  node_bootsim["SimBoot<br/>boot adapter"]
  node_bootqcom["QualcommBoot<br/>boot adapter"]
  node_camerasrc["CameraSource<br/>adapter interface<br/>[ICameraSource.hpp]"]
  node_usbcam["USB Camera<br/>camera adapter"]
end

subgraph group_apps["Apps"]
  node_display["DisplayApp<br/>[DisplayApp.hpp]"]
end

subgraph group_platform["Platform"]
  node_config["ConfigMgr<br/>configuration"]
  node_loggerutil["Logger<br/>[Logger.hpp]"]
  node_time["TimeService<br/>[TimeService.hpp]"]
end

node_main -->|"starts"| node_startup
node_startup -->|"creates"| node_runtimecore
node_runtimecore -->|"uses"| node_context
node_context -->|"loads"| node_config
node_context -->|"provides"| node_eventbus
node_context -->|"provides"| node_servicemgr
node_startup -->|"publishes"| node_boot_evt
node_bootprov -->|"implemented by"| node_bootsim
node_bootprov -->|"implemented by"| node_bootqcom
node_bootprov -->|"sources"| node_boot_evt
node_servicemgr -->|"manages"| node_platformdisc
node_servicemgr -->|"manages"| node_camera
node_servicemgr -->|"manages"| node_logger
node_servicemgr -->|"manages"| node_monitor
node_servicemgr -->|"manages"| node_failure
node_platformdisc -->|"publishes"| node_eventbus
node_platformdisc -->|"emits"| node_platformdisc_evt
node_platformdisc_evt -->|"carries"| node_hwinfo
node_platformdisc -->|"builds"| node_hwinfo
node_camera -->|"publishes"| node_eventbus
node_camera -->|"emits"| node_frame
node_camera -->|"emits"| node_camera_evt
node_camera -->|"uses"| node_camerasrc
node_camerasrc -->|"implemented by"| node_usbcam
node_logger -->|"uses"| node_loggerutil
node_display -->|"subscribes"| node_eventbus
node_display -->|"consumes"| node_platformdisc_evt
node_display -->|"consumes"| node_camera_evt
node_display -->|"consumes"| node_frame
node_execmgr -->|"coordinates"| node_eventbus
node_execmgr -->|"publishes"| node_exec_evt
node_startup -->|"hands off"| node_execmgr
node_platformdisc -->|"reads"| node_config
node_camera -->|"reads"| node_config
node_platformdisc -->|"timestamps"| node_time
node_monitor -->|"subscribes"| node_eventbus
node_failure -->|"subscribes"| node_eventbus

click node_main "https://github.com/mehdiabidri/vision/blob/main/main.cpp"
click node_startup "https://github.com/mehdiabidri/vision/blob/main/runtime/Startup.hpp"
click node_runtimecore "https://github.com/mehdiabidri/vision/blob/main/runtime/Runtime.hpp"
click node_context "https://github.com/mehdiabidri/vision/blob/main/runtime/RuntimeContext.hpp"
click node_eventbus "https://github.com/mehdiabidri/vision/blob/main/core/EventBus.hpp"
click node_servicemgr "https://github.com/mehdiabidri/vision/blob/main/core/ServiceManager.hpp"
click node_execmgr "https://github.com/mehdiabidri/vision/blob/main/core/ExecutionManager.hpp"
click node_platformdisc_evt "https://github.com/mehdiabidri/vision/blob/main/core/PlatformDiscoveredEvent.hpp"
click node_boot_evt "https://github.com/mehdiabidri/vision/blob/main/core/BootStageEvent.hpp"
click node_exec_evt "https://github.com/mehdiabidri/vision/blob/main/core/ExecutionStateEvent.hpp"
click node_camera_evt "https://github.com/mehdiabidri/vision/blob/main/core/CameraStateEvent.hpp"
click node_frame "https://github.com/mehdiabidri/vision/blob/main/core/Frame.hpp"
click node_platformdisc "https://github.com/mehdiabidri/vision/blob/main/services/PlatformDiscoveryService.hpp"
click node_camera "https://github.com/mehdiabidri/vision/blob/main/services/CameraService.hpp"
click node_logger "https://github.com/mehdiabidri/vision/blob/main/services/LoggerService.hpp"
click node_monitor "https://github.com/mehdiabidri/vision/blob/main/services/EventMonitor.hpp"
click node_failure "https://github.com/mehdiabidri/vision/blob/main/services/FailureManager.hpp"
click node_bootprov "https://github.com/mehdiabidri/vision/blob/main/core/IBootProvider.hpp"
click node_bootsim "https://github.com/mehdiabidri/vision/blob/main/hal/SimulatedBootProvider.hpp"
click node_bootqcom "https://github.com/mehdiabidri/vision/blob/main/hal/QualcommBootProvider.hpp"
click node_camerasrc "https://github.com/mehdiabidri/vision/blob/main/core/ICameraSource.hpp"
click node_usbcam "https://github.com/mehdiabidri/vision/blob/main/hal/UsbCameraSource.hpp"
click node_display "https://github.com/mehdiabidri/vision/blob/main/apps/DisplayApp.hpp"
click node_config "https://github.com/mehdiabidri/vision/blob/main/platform/ConfigurationManager.hpp"
click node_loggerutil "https://github.com/mehdiabidri/vision/blob/main/platform/Logger.hpp"
click node_time "https://github.com/mehdiabidri/vision/blob/main/platform/TimeService.hpp"
click node_hwinfo "https://github.com/mehdiabidri/vision/blob/main/runtime/HardwareInfo.hpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_startup,node_runtimecore,node_context,node_hwinfo toneBlue
class node_eventbus,node_servicemgr,node_execmgr,node_platformdisc_evt,node_boot_evt,node_exec_evt,node_camera_evt,node_frame toneAmber
class node_platformdisc,node_camera,node_logger,node_monitor,node_failure toneMint
class node_bootprov,node_bootsim,node_bootqcom,node_camerasrc,node_usbcam toneRose
class node_display toneIndigo
class node_config,node_loggerutil,node_time toneTeal
```

## Components

### Runtime

Boot, orchestration, and shared execution context

- [main](https://github.com/mehdiabidri/vision/blob/main/main.cpp): entrypoint · Program entry that starts the platform runtime · `main.cpp`
- [Startup](https://github.com/mehdiabidri/vision/blob/main/runtime/Startup.hpp): boot orchestrator · Coordinates boot progression and initial platform bring-up · `runtime/Startup.hpp`
- [Runtime](https://github.com/mehdiabidri/vision/blob/main/runtime/Runtime.hpp): execution shell · Top-level runtime container for services and context · `runtime/Runtime.hpp`
- [Context](https://github.com/mehdiabidri/vision/blob/main/runtime/RuntimeContext.hpp): shared state · Runtime context carrying config, hardware, and service references · `runtime/RuntimeContext.hpp`
- [HardwareInfo](https://github.com/mehdiabidri/vision/blob/main/runtime/HardwareInfo.hpp): runtime model · Runtime-discovered hardware manifest · `runtime/HardwareInfo.hpp`

### Core

Messaging and lifecycle contracts

- [EventBus](https://github.com/mehdiabidri/vision/blob/main/core/EventBus.hpp): message bus · Typed event backbone used by services and apps · `core/EventBus.hpp`
- [ServiceManager](https://github.com/mehdiabidri/vision/blob/main/core/ServiceManager.hpp): lifecycle manager · Initializes, starts, and stops platform services · `core/ServiceManager.hpp`
- [ExecManager](https://github.com/mehdiabidri/vision/blob/main/core/ExecutionManager.hpp): state coordinator · Coordinates execution-state transitions across the platform · `core/ExecutionManager.hpp`
- [PlatformEvent](https://github.com/mehdiabidri/vision/blob/main/core/PlatformDiscoveredEvent.hpp): domain event · Published when hardware/platform discovery completes · `core/PlatformDiscoveredEvent.hpp`
- [BootEvent](https://github.com/mehdiabidri/vision/blob/main/core/BootStageEvent.hpp): domain event · Represents boot-stage progression through startup · `core/BootStageEvent.hpp`
- [ExecState](https://github.com/mehdiabidri/vision/blob/main/core/ExecutionStateEvent.hpp): domain event · Represents platform execution-state changes · `core/ExecutionStateEvent.hpp`
- [CameraEvent](https://github.com/mehdiabidri/vision/blob/main/core/CameraStateEvent.hpp): domain event · Carries camera state changes through the bus · `core/CameraStateEvent.hpp`
- [Frame](https://github.com/mehdiabidri/vision/blob/main/core/Frame.hpp): data event · Camera frame payload passed to consumers · `core/Frame.hpp`

### Services

Platform services built on the core

- [Discovery](https://github.com/mehdiabidri/vision/blob/main/services/PlatformDiscoveryService.hpp): foundation service · Detects hardware and publishes platform information · `services/PlatformDiscoveryService.hpp`
- [CameraSvc](https://github.com/mehdiabidri/vision/blob/main/services/CameraService.hpp): media service · Acquires camera frames and emits camera-related events · `services/CameraService.hpp`
- [LoggerSvc](https://github.com/mehdiabidri/vision/blob/main/services/LoggerService.hpp): observability service · Centralizes runtime logging output · `services/LoggerService.hpp`
- [Monitor](https://github.com/mehdiabidri/vision/blob/main/services/EventMonitor.hpp): observability service · Watches platform events and runtime behavior · `services/EventMonitor.hpp`
- [FailureMgr](https://github.com/mehdiabidri/vision/blob/main/services/FailureManager.hpp): fault service · Handles failures and platform fault reporting · `services/FailureManager.hpp`

### HAL

Hardware and environment adapters

- [BootProvider](https://github.com/mehdiabidri/vision/blob/main/core/IBootProvider.hpp): adapter interface · Abstracts boot-stage sourcing for different environments · `core/IBootProvider.hpp`
- [SimBoot](https://github.com/mehdiabidri/vision/blob/main/hal/SimulatedBootProvider.hpp): boot adapter · Simulated boot-stage provider · `hal/SimulatedBootProvider.hpp`
- [QualcommBoot](https://github.com/mehdiabidri/vision/blob/main/hal/QualcommBootProvider.hpp): boot adapter · Target-specific boot-stage provider · `hal/QualcommBootProvider.hpp`
- [CameraSource](https://github.com/mehdiabidri/vision/blob/main/core/ICameraSource.hpp): adapter interface · Abstract camera input source contract · `core/ICameraSource.hpp`
- [USB Camera](https://github.com/mehdiabidri/vision/blob/main/hal/UsbCameraSource.hpp): camera adapter · USB webcam-backed camera source · `hal/UsbCameraSource.hpp`

### Apps

Adaptive application layer

- [DisplayApp](https://github.com/mehdiabidri/vision/blob/main/apps/DisplayApp.hpp): application · Consumes platform and camera events to present state · `apps/DisplayApp.hpp`

### Platform

Shared utilities and configuration

- [ConfigMgr](https://github.com/mehdiabidri/vision/blob/main/platform/ConfigurationManager.hpp): configuration · Loads and provides platform configuration · `platform/ConfigurationManager.hpp`
- [Logger](https://github.com/mehdiabidri/vision/blob/main/platform/Logger.hpp): utility · Shared logging support used across the platform · `platform/Logger.hpp`
- [TimeService](https://github.com/mehdiabidri/vision/blob/main/platform/TimeService.hpp): utility · Shared time and timing support · `platform/TimeService.hpp`

## Connections

- main → Startup: starts · Entry point begins startup orchestration
- Startup → Runtime: creates · Startup initializes the runtime container
- Runtime → Context: uses · Runtime is built around shared execution context
- Context → ConfigMgr: loads · Context carries configuration into services
- Context → EventBus: provides · Event bus is shared across the platform
- Context → ServiceManager: provides · Service manager is stored in runtime context
- Startup → BootEvent: publishes · Startup reports boot progression as events
- BootProvider → SimBoot: implemented by · Simulated provider fulfills the boot contract
- BootProvider → QualcommBoot: implemented by · Target-specific provider fulfills the boot contract
- BootProvider → BootEvent: sources · Boot providers emit boot-stage events
- ServiceManager → Discovery: manages · Service manager orchestrates platform discovery
- ServiceManager → CameraSvc: manages · Service manager orchestrates camera service lifecycle
- ServiceManager → LoggerSvc: manages · Service manager orchestrates logging service lifecycle
- ServiceManager → Monitor: manages · Service manager orchestrates monitoring service lifecycle
- ServiceManager → FailureMgr: manages · Service manager orchestrates failure handling lifecycle
- Discovery → EventBus: publishes · Discovery publishes platform information to the bus
- Discovery → PlatformEvent: emits · Discovery produces platform-discovered events
- PlatformEvent → HardwareInfo: carries · Platform event transports discovered hardware info
- Discovery → HardwareInfo: builds · Discovery constructs runtime hardware manifest
- CameraSvc → EventBus: publishes · Camera service publishes frames and camera state
- CameraSvc → Frame: emits · Camera service produces frames
- CameraSvc → CameraEvent: emits · Camera service produces camera-state events
- CameraSvc → CameraSource: uses · Camera service depends on abstract camera source
- CameraSource → USB Camera: implemented by · USB camera source fulfills the input contract
- LoggerSvc → Logger: uses · Logging service relies on shared logging utility
- DisplayApp → EventBus: subscribes · Application consumes events from the bus
- DisplayApp → PlatformEvent: consumes · Application reacts to platform discovery
- DisplayApp → CameraEvent: consumes · Application reacts to camera state
- DisplayApp → Frame: consumes · Application may render or inspect frames
- ExecManager → EventBus: coordinates · Execution manager uses events to drive state transitions
- ExecManager → ExecState: publishes · Execution manager emits execution-state events
- Startup → ExecManager: hands off · Startup transfers control into execution coordination
- Discovery → ConfigMgr: reads · Discovery may use configuration to locate hardware sources
- CameraSvc → ConfigMgr: reads · Camera service uses external camera configuration
- Discovery → TimeService: timestamps · Discovery can attach timing information to events
- Monitor → EventBus: subscribes · Monitoring observes platform activity on the bus
- FailureMgr → EventBus: subscribes · Failure manager observes errors and state changes
