# xtech/self-o-mat architecture

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

- Interactive diagram: https://gitdiagram.com/xtech/self-o-mat
- Repository: https://github.com/xtech/self-o-mat

## Overview

##### Main Components Identification

- Hardware Layer:
- DSLR Camera (Multiple supported models)
- Raspberry Pi (Main processing unit)
- Arduino Controller (For hardware control)
- LED Flash System
- Printer (CUPS compatible)
- Trigger Mechanism (Buttons/Sensors)

- Software Layer:
- Core Application (C++)
- Web Interface (Angular/Ionic)
- Camera Control System
- Image Processing Pipeline
- State Management System
- API Layer

**[DSLR Camera] ←→ [Raspberry Pi] ←→ [Arduino Controller]**
- ↑               ↑                      ↑

**[Flash System]    [Printer]            [Trigger Button]**

**[Camera Controllers] → [Image Processor] → [Printer Manager]**
- ↑                    ↑                  ↑

- [State Machine] ←→ [Booth Logic] ←→ [API Service]

**[Web Frontend] ←→ [REST API] ←→ [WebSocket Updates]**

##### Key Relationships to Highlight

- Camera Control Flow:
- Path from trigger input through state machine to camera activation
- Image data flow from camera through processing to storage/printing

- User Interface Flow:
- How web interface connects to core system
- Settings and control paths

##### State Management

**[Booting] → [Idle] → [Agreement] → [CountDown] → [Busy]**
- ↑                                   |
- ┘

##### Important Technical Details

- Protocol indicators (COBS, SLIP) for Arduino communication
- Supported camera models and interfaces
- Image processing pipeline stages
- Printer integration points
- Web API endpoints

##### Implementation Notes

- Use UML notation for clarity
- Version information and supported hardware models
- Notes about key configuration requirements

##### Architectural Patterns to Highlight

- State Pattern (for booth control)
- MVC Pattern (in web interface)
- Observer Pattern (for event handling)
- Strategy Pattern (for camera control)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef hardware fill:#E0E0E0,stroke:#333
    classDef software fill:#B3E0FF,stroke:#333
    classDef interface fill:#98FB98,stroke:#333
    classDef state fill:#FFA07A,stroke:#333
    classDef api fill:#DDA0DD,stroke:#333

    %% Hardware Layer
    subgraph Hardware
        DSLR[DSLR Camera]:::hardware
        RPI[Raspberry Pi]:::hardware
        ARD[Arduino Controller]:::hardware
        FLASH[LED Flash System]:::hardware
        PRINT[Printer]:::hardware
        TRIG[Trigger Button]:::hardware

        DSLR --- RPI
        RPI --- ARD
        FLASH --- DSLR
        PRINT --- RPI
        TRIG --- ARD
    end

    %% Software Layer
    subgraph Core
        CC[Camera Controllers]:::software
        IP[Image Processor]:::software
        PM[Printer Manager]:::software
        SM[State Machine]:::software
        BL[Booth Logic]:::software
        AS[API Service]:::software
        LOG[Logging System]:::software
        IPT[Image Processing Tools]:::software

        SM --> CC
        SM --> BL
        BL --> IP
        IP --> PM
        BL --> AS
        LOG --- BL
        IPT --- IP
    end

    %% Interface Layer
    subgraph Interface
        WF[Web Frontend]:::interface
        API[REST API]:::api
        WS[WebSocket Updates]:::interface

        WF --> API
        API --> WS
    end

    %% State Machine
    subgraph States
        BS[Booting]:::state
        IS[Idle]:::state
        AS2[Agreement]:::state
        CS[CountDown]:::state
        BUS[Busy]:::state

        BS --> IS
        IS --> AS2
        AS2 --> CS
        CS --> BUS
        BUS --> IS
    end

    %% Cross-layer connections
    ARD --> SM
    DSLR --> CC
    PRINT --> PM
    AS --> API

    %% Click events for component mapping
    click ARD "https://github.com/xtech/self-o-mat/blob/master/Arduino/SelfomatController/SelfomatController.ino"
    click SM "https://github.com/xtech/self-o-mat/blob/master/Arduino/SelfomatController/State.h"
    click CC "https://github.com/xtech/self-o-mat/blob/master/src/camera/GphotoCamera.h"
    click IP "https://github.com/xtech/self-o-mat/blob/master/src/logic/filters/BasicImageFilter.h"
    click WF "https://github.com/xtech/self-o-mat/tree/master/web/src/app/"
    click AS "https://github.com/xtech/self-o-mat/blob/master/src/api/BoothApi.h"
    click PM "https://github.com/xtech/self-o-mat/blob/master/src/logic/PrinterManager.h"
    click BL "https://github.com/xtech/self-o-mat/blob/master/src/logic/BoothLogic.h"
    click CC "https://github.com/xtech/self-o-mat/tree/master/src/camera/controllers/"
    click LOG "https://github.com/xtech/self-o-mat/blob/master/src/tools/ILogger.h"
    click IPT "https://github.com/xtech/self-o-mat/blob/master/src/tools/JpegDecoder.h"
    click IS "https://github.com/xtech/self-o-mat/blob/master/Arduino/SelfomatController/IdleState.h"
    click BUS "https://github.com/xtech/self-o-mat/blob/master/Arduino/SelfomatController/BusyState.h"
    click CS "https://github.com/xtech/self-o-mat/blob/master/Arduino/SelfomatController/CountDownState.h"
    click AS2 "https://github.com/xtech/self-o-mat/blob/master/Arduino/SelfomatController/AgreementState.h"
    click API "https://github.com/xtech/self-o-mat/blob/master/web/src/app/api.service.ts"
```
