# waxlamp/elgato architecture

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

- Interactive diagram: https://gitdiagram.com/waxlamp/elgato
- Repository: https://github.com/waxlamp/elgato

## Overview

##### Main Components
- Core Logic and Command Parsing: Outline the “elgato” package which includes modules (__init__.py and __main__.py) handling the core functionality. This is where the commands are parsed and operations are directed.
- Integration with External Library: Highlight the usage of the leglight package. Even though the package wraps it, include it as a key component that handles the low-level interactions with the El Gato hardware.
- Configuration and Persistent Data: Represent the config file (e.g., discovered lights stored in ~/.config/elgato/discovered.json). This is where state-data about discovered lights is saved.
- Development and CI/CD Infrastructure: Although not strictly part of runtime architecture, it’s useful to note supportive files like Pipfile, Pipfile.lock, GitHub workflows, and linting (.flake8) which help in maintaining and deploying the project.

##### Relationships and Interactions
- The CLI interface (user commands) routes to the core logic of the “elgato” module.
- Operations related to "discovery" update/read a local JSON file that persists the list and state of available lights.
- The development tools (development environment setup via Pipenv and CI/CD workflows) ensure quality and continuous deployment but remain separate from runtime interactions.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Different parts of the system are responsible for CLI parsing, business logic, and hardware interactions.
- Wrapper Pattern: The “elgato” package acts as a wrapper around the leglight library, providing a consistent CLI experience.
- Modular Design: A single package with clearly separated responsibilities even though the project is compact.

##### Relevant Technologies, Frameworks, and Libraries
- Python for the core implementation.
- Pipenv for environment and dependency management.
- leglight (external dependency) for communicating with the El Gato hardware.
- GitHub Actions for CI/CD processes.
- Mypy for type checking (as indicated by the presence of mypy_stubs).

- This to a “CLI Interface / Entry Point” (represented by __main__.py), which then routes commands to the “Core Application” component (the rest of the elgato package).
– The “leglight Library” component, denoting external dependencies.
– A “Configuration Storage” component for handling discovered lights (depicting the JSON file).

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["User (CLI Commands)"]:::external
    B["CLI Interface (__main__.py)"]:::runtime
    C["Core Application (elgato package)"]:::runtime
    D["External Light API (leglight Integration)"]:::api
    E["Persistent Light Discovery (discovered.json)"]:::runtime

    A -->|"issues commands"| B
    B -->|"dispatches to"| C
    C -->|"calls"| D
    C -->|"reads/writes"| E

    subgraph "CI/CD & Development Tools"
        F1["Linting (.flake8)"]:::dev
        F2["Type Checking (mypy_stubs)"]:::dev
        F3["Dependency Management (Pipfile)"]:::dev
        F4["Dependency Management (Pipfile.lock)"]:::dev
        F5["CI/CD Workflow (main.yml)"]:::dev
        F6["CI/CD Workflow (publish.yml)"]:::dev
    end

    %% Click Events
    click B "https://github.com/waxlamp/elgato/blob/master/elgato/__main__.py"
    click C "https://github.com/waxlamp/elgato/blob/master/elgato/__init__.py"
    click D "https://github.com/waxlamp/elgato/blob/master/mypy_stubs/leglight.pyi"
    click F1 "https://github.com/waxlamp/elgato/blob/master/.flake8"
    click F2 "https://github.com/waxlamp/elgato/tree/master/mypy_stubs"
    click F3 "https://github.com/waxlamp/elgato/tree/master/Pipfile"
    click F4 "https://github.com/waxlamp/elgato/blob/master/Pipfile.lock"
    click F5 "https://github.com/waxlamp/elgato/blob/master/.github/workflows/main.yml"
    click F6 "https://github.com/waxlamp/elgato/blob/master/.github/workflows/publish.yml"

    %% Styles
    classDef external fill:#CFF,stroke:#333,stroke-width:2px;
    classDef runtime fill:#BBF,stroke:#333,stroke-width:2px;
    classDef api fill:#F96,stroke:#333,stroke-width:2px;
    classDef dev fill:#FFC,stroke:#333,stroke-width:2px;
```
