# kala13x/flipper-xremote architecture

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

- Interactive diagram: https://gitdiagram.com/kala13x/flipper-xremote
- Repository: https://github.com/kala13x/flipper-xremote

## Overview

##### Main Components Identification
- IR Signal Processing Module:
- Directories/Files: The “infrared” folder which contains files like infrared_signal.c/h, infrared_remote.c/h, and infrared_remote_button.c/h.
- Role: Handles the generation, analysis, and management of IR signals from the Flipper device.
- User Interface (UI) / View Layer:
- Directories/Files: “views” and “screens” directories. These files (e.g., xremote_control_view.c/h, xremote_about_view.c/h, etc.) implement different pages (main menu, control, custom layout, etc.) that users interact with.
- Role: Responsible for rendering the application’s graphical interface, receiving user input, and displaying feedback (e.g., learning mode, signal analysis, settings).
- Core Application Logic:
- Directories/Files: Files named xremote.c/h, xremote_app.c/h, xremote_control.c/h, xremote_edit.c/h, xremote_learn.c/h, etc.
- Role: Acts as the central orchestrator that connects UI events to hardware interactions, manages configuration and state, and handles IR command mapping and learning functionality.
- Configuration Management:
- Directories/Files: The project supports a file (alt_names.txt) that holds alternative names for IR commands. Additionally, the deploy.sh script and application.fam file suggest integration with the firmware and possible configuration management.
- Role: Loads and stores settings, button mappings, and alternative names—ensuring that user changes through the UI are persistent within the remote file configuration.
- Deployment / Infrastructure:
- Files like deploy.sh and directories such as .flipcorg and docs indicate deployment and documentation infrastructure, helping with building, installing, and maintaining the app.

##### Relationships and Interactions
- The UI Layer (views and screens) sends user actions (e.g., button press events, layout edits, or command learn actions) to the Core Application Logic.
- The Core Application Logic processes these events, determines if an IR signal should be sent (or a learning operation is required), and then calls into the IR Signal Processing Module.
- The IR Module interfaces directly with the Flipper hardware to send or record infrared signals.
- Configuration data (such as alternative button names and custom layouts) is loaded at startup and updated in the configuration files on the SD Card, with changes flowing back into the application logic.
- Additional supporting components (such as deployment scripts and documentation) ensure that the application can be built, installed, and updated in conjunction with the Flipper firmware.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project cleanly separates UI handling, core business logic, and hardware interfacing.
- Modularity: Each core function (IR processing, UI, configuration management) is implemented in separate modules and files, making the system easier to maintain.
- Event-Driven Workflow: User interactions from the UI propagate as events handled by the central application logic, triggering hardware operations and configuration updates.

##### Relevant Technologies and Frameworks
- C programming language is used across the application.
- The project builds for the Flipper device firmware. The deploy.sh script outlines how the application gets compiled and installed, indicating integration with Flipper Zero’s build and deployment ecosystems.
- File-based configuration (alt_names.txt) allows dynamic updating of button mappings.

## Diagram (Mermaid)

```mermaid
flowchart TD 
    %% UI / Presentation Layer
    subgraph "UI / Presentation Layer"
        about["About View"]:::ui
        control["Control View"]:::ui
        custom["Custom View"]:::ui
        learn["Learn View"]:::ui
        screens["Screens"]:::ui
    end

    %% Core Application Logic
    subgraph "Core Application Logic"
        xremoteMain["xremote"]:::core
        xremoteApp["xremote_app"]:::core
        xremoteControl["xremote_control"]:::core
        xremoteEdit["xremote_edit"]:::core
        xremoteLearn["xremote_learn"]:::core
        xremoteSettings["xremote_settings"]:::core
        xremoteSignal["xremote_signal"]:::core
        xremoteAnalyzer["xremote_analyzer"]:::core
    end

    %% IR Signal Processing Module
    subgraph "IR Signal Processing Module"
        ir_signal["IR Signal"]:::ir
        ir_remote["IR Remote"]:::ir
        ir_remote_button["IR Remote Button"]:::ir
    end

    %% Configuration Management
    subgraph "Configuration Management"
        configMgmt["Configuration Management"]:::config
    end

    %% Deployment / Infrastructure
    subgraph "Deployment / Infrastructure"
        deploy["deploy.sh"]:::dep
        flipcorg[".flipcorg"]:::dep
        docs["docs"]:::dep
    end

    %% Interactions: UI to Core
    about -->|"action"| xremoteMain
    control -->|"action"| xremoteMain
    custom -->|"action"| xremoteMain
    learn -->|"action"| xremoteMain
    screens -->|"action"| xremoteMain

    %% Interactions: Core sends IR commands to IR processing
    xremoteMain -->|"IRcommand"| ir_signal
    xremoteMain -->|"IRcommand"| ir_remote
    xremoteMain -->|"IRcommand"| ir_remote_button

    %% Interaction: Configuration Management flows to/from Core
    xremoteSettings -->|"config_update"| configMgmt
    configMgmt -->|"loaded_config"| xremoteMain

    %% Interaction: Deployment supports Configuration Management
    deploy -->|"deployment"| configMgmt
    flipcorg -->|"infrastructure"| deploy
    docs -->|"documentation"| deploy

    %% Styles
    classDef ui fill:#ffdddd,stroke:#cc0000,stroke-width:2px;
    classDef core fill:#ddffdd,stroke:#00aa00,stroke-width:2px;
    classDef ir fill:#ddddff,stroke:#0000cc,stroke-width:2px;
    classDef config fill:#ffffcc,stroke:#aaaa00,stroke-width:2px;
    classDef dep fill:#e6e6ff,stroke:#8888ff,stroke-width:2px;

    %% Click Events for UI / Presentation Layer
    click about "https://github.com/kala13x/flipper-xremote/blob/main/views/xremote_about_view.c"
    click control "https://github.com/kala13x/flipper-xremote/blob/main/views/xremote_control_view.c"
    click custom "https://github.com/kala13x/flipper-xremote/blob/main/views/xremote_custom_view.c"
    click learn "https://github.com/kala13x/flipper-xremote/blob/main/views/xremote_learn_view.c"
    click screens "https://github.com/kala13x/flipper-xremote/tree/main/screens/"

    %% Click Events for Core Application Logic
    click xremoteMain "https://github.com/kala13x/flipper-xremote/blob/main/xremote.c"
    click xremoteApp "https://github.com/kala13x/flipper-xremote/blob/main/xremote_app.c"
    click xremoteControl "https://github.com/kala13x/flipper-xremote/blob/main/xremote_control.c"
    click xremoteEdit "https://github.com/kala13x/flipper-xremote/blob/main/xremote_edit.c"
    click xremoteLearn "https://github.com/kala13x/flipper-xremote/blob/main/xremote_learn.c"
    click xremoteSettings "https://github.com/kala13x/flipper-xremote/blob/main/xremote_settings.c"
    click xremoteSignal "https://github.com/kala13x/flipper-xremote/blob/main/xremote_signal.c"
    click xremoteAnalyzer "https://github.com/kala13x/flipper-xremote/blob/main/xremote_analyzer.c"

    %% Click Events for IR Signal Processing Module
    click ir_signal "https://github.com/kala13x/flipper-xremote/blob/main/infrared/infrared_signal.c"
    click ir_remote "https://github.com/kala13x/flipper-xremote/blob/main/infrared/infrared_remote.c"
    click ir_remote_button "https://github.com/kala13x/flipper-xremote/blob/main/infrared/infrared_remote_button.c"

    %% Click Event for Configuration Management
    click configMgmt "https://github.com/kala13x/flipper-xremote/blob/main/application.fam"

    %% Click Events for Deployment / Infrastructure
    click deploy "https://github.com/kala13x/flipper-xremote/blob/main/deploy.sh"
    click flipcorg "https://github.com/kala13x/flipper-xremote/blob/main/.flipcorg"
    click docs "https://github.com/kala13x/flipper-xremote/tree/main/docs/"
```
