# denr01/fz-chiefcooker architecture

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

- Interactive diagram: https://gitdiagram.com/denr01/fz-chiefcooker
- Repository: https://github.com/denr01/fz-chiefcooker

## Overview

##### Project type and purpose
- Chief Cooker is a firmware “app” (plugin) for Flipper Zero (Momentum firmware) that receives, decodes, edits, stores, and re-sends restaurant pager signals via an external CC1101 Sub-GHz radio module.

##### Top-level logical layers
a. UI Layer
b. Application Core
c. Storage & Configuration
d. Hardware Abstraction

##### Main components
– UiManager (lib/ui/UiManager.hpp)
– Views (lib/ui/view/…)
– Screens (app/screen/MainMenuScreen, ScanStationsScreen, EditPagerScreen, etc.)
– Notifications UI (app/AppNotifications.hpp → lib/hardware/notification/Notification.hpp)

– App (app/App.hpp & AppConfig.hpp)
– Pager Module (app/pager/…)
- PagerReceiver (captures raw Sub-GHz payloads)
- ProtocolAndDecoderProvider (chooses correct app/pager/protocol/*Protocol & app/pager/decoder/*Decoder)
- PagerDecoder classes (Td157Decoder, L8RDecoder, etc.)
- PagerSerializer (serializes messages for storage or re-transmission)
- PagerAction (triggers sending or re-sending)
- SavedStationStrategy (logic for storing/naming stations)

– AppFileSystem (app/AppFileSystem.hpp)
– FileManager, Directory, FlipperFile (lib/file/*)
– Data models (app/pager/data/KnownStationData, NamedPagerData, StoredPagerData, ReceivedPagerData)

– SubGhzModule & FrequencyManager (lib/hardware/subghz/*)
– SubGhzPayload, SubGhzState, SubGhzReceivedData implementations
– Notification hardware (lib/hardware/notification/Notification.hpp)
– FlipperDolphin core helpers (lib/FlipperDolphin.hpp, HandlerContext.hpp)

##### Relationships and data flow
- On app startup, AppConfig + SavedStationData loaded from Storage → feeds Core & UI

##### Architectural patterns and principles
- Layered separation: UI, business logic, storage, hardware
- Strategy pattern: ProtocolAndDecoderProvider chooses a decoding strategy
- Adapter/Facade: AppFileSystem + lib/file classes wrap raw filesystem
- Modular design: each pager protocol, decoder, and screen is its own class/file

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Chief Cooker App"
        subgraph "UI Layer"
            UiManager["UiManager"]:::ui
            Views["Views"]:::ui
            subgraph "Screens"
                MainMenuScreen["MainMenuScreen"]:::ui
                ScanStationsScreen["ScanStationsScreen"]:::ui
                EditPagerScreen["EditPagerScreen"]:::ui
                BatchTransmissionScreen["BatchTransmissionScreen"]:::ui
                PagerActionsScreen["PagerActionsScreen"]:::ui
                SelectCategoryScreen["SelectCategoryScreen"]:::ui
                SettingsScreen["SettingsScreen"]:::ui
            end
            NotificationsUI["AppNotifications / Notification"]:::ui
        end

        subgraph "Application Core"
            App["App"]:::core
            AppConfig["AppConfig"]:::core
            subgraph "Pager Module"
                PagerReceiver["PagerReceiver"]:::core
                ProtocolAndDecoderProvider["ProtocolAndDecoderProvider"]:::core
                PagerSerializer["PagerSerializer"]:::core
                PagerAction["PagerAction"]:::core
                SavedStationStrategy["SavedStationStrategy"]:::core
                subgraph "Protocols"
                    PagerProtocol["PagerProtocol"]:::core
                    PrincetonProtocol["PrincetonProtocol"]:::core
                    Smc5326Protocol["Smc5326Protocol"]:::core
                end
                subgraph "Decoders"
                    PagerDecoder["PagerDecoder"]:::core
                    Td157Decoder["Td157Decoder"]:::core
                    Td165Decoder["Td165Decoder"]:::core
                    Td174Decoder["Td174Decoder"]:::core
                    L8RDecoder["L8RDecoder"]:::core
                    L8SDecoder["L8SDecoder"]:::core
                end
            end
        end

        subgraph "Storage & Configuration"
            AppFileSystem["AppFileSystem"]:::storage
            FileManager["FileManager"]:::storage
            Directory["Directory"]:::storage
            FlipperFile["FlipperFile"]:::storage
            KnownStationData["KnownStationData"]:::storage
            NamedPagerData["NamedPagerData"]:::storage
            ReceivedPagerData["ReceivedPagerData"]:::storage
            StoredPagerData["StoredPagerData"]:::storage
        end

        subgraph "Hardware Abstraction"
            SubGhzModule["SubGhzModule"]:::hardware
            FrequencyManager["FrequencyManager"]:::hardware
            SubGhzPayload["SubGhzPayload"]:::hardware
            SubGhzState["SubGhzState"]:::hardware
            subgraph "SubGhzReceivedData"
                SubGhzReceivedData["SubGhzReceivedData"]:::hardware
                SubGhzReceivedDataImpl["SubGhzReceivedDataImpl"]:::hardware
                SubGhzReceivedDataStub["SubGhzReceivedDataStub"]:::hardware
            end
            NotificationHW["Notification"]:::hardware
        end

        subgraph "Core Helpers"
            FlipperDolphin["FlipperDolphin"]:::helper
            HandlerContext["HandlerContext"]:::helper
        end

        subgraph "Deployment"
            BuildScript["build-and-clear.py"]:::script
        end
    end

    %% Connections
    MainMenuScreen -->|"user input"| App
    ScanStationsScreen --> App
    AppConfig -->|load config| App
    App -->|"scan/send"| SubGhzModule
    SubGhzModule -->|SubGhzPayload| PagerReceiver
    PagerReceiver -->|raw payload| ProtocolAndDecoderProvider
    ProtocolAndDecoderProvider -->|choose decoder| Td157Decoder
    ProtocolAndDecoderProvider -->|choose decoder| L8RDecoder
    Td157Decoder -->|decode| ReceivedPagerData
    L8RDecoder -->|decode| ReceivedPagerData
    App -->|serialize| PagerSerializer
    PagerSerializer -->|store data| AppFileSystem
    AppFileSystem -->|write| FileManager
    AppFileSystem -->|write| FlipperFile
    AppFileSystem -->|create dir| Directory
    App -->|trigger action| PagerAction
    PagerAction -->|send| SubGhzModule
    App -->|notify| NotificationsUI

    BuildScript -->|deploy| App

    %% Click events
    click UiManager "https://github.com/denr01/fz-chiefcooker/blob/master/lib/ui/UiManager.hpp"
    click Views "https://github.com/denr01/fz-chiefcooker/tree/master/lib/ui/view/"
    click MainMenuScreen "https://github.com/denr01/fz-chiefcooker/blob/master/app/screen/MainMenuScreen.hpp"
    click ScanStationsScreen "https://github.com/denr01/fz-chiefcooker/blob/master/app/screen/ScanStationsScreen.hpp"
    click EditPagerScreen "https://github.com/denr01/fz-chiefcooker/blob/master/app/screen/EditPagerScreen.hpp"
    click BatchTransmissionScreen "https://github.com/denr01/fz-chiefcooker/blob/master/app/screen/BatchTransmissionScreen.hpp"
    click PagerActionsScreen "https://github.com/denr01/fz-chiefcooker/blob/master/app/screen/PagerActionsScreen.hpp"
    click SelectCategoryScreen "https://github.com/denr01/fz-chiefcooker/blob/master/app/screen/SelectCategoryScreen.hpp"
    click SettingsScreen "https://github.com/denr01/fz-chiefcooker/blob/master/app/screen/SettingsScreen.hpp"
    click NotificationsUI "https://github.com/denr01/fz-chiefcooker/blob/master/app/AppNotifications.hpp"
    click NotificationHW "https://github.com/denr01/fz-chiefcooker/blob/master/lib/hardware/notification/Notification.hpp"
    click App "https://github.com/denr01/fz-chiefcooker/blob/master/app/App.hpp"
    click AppConfig "https://github.com/denr01/fz-chiefcooker/blob/master/app/AppConfig.hpp"
    click PagerReceiver "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/PagerReceiver.hpp"
    click ProtocolAndDecoderProvider "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/ProtocolAndDecoderProvider.hpp"
    click PagerSerializer "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/PagerSerializer.hpp"
    click PagerAction "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/PagerAction.hpp"
    click SavedStationStrategy "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/SavedStationStrategy.hpp"
    click PagerProtocol "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/protocol/PagerProtocol.hpp"
    click PrincetonProtocol "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/protocol/PrincetonProtocol.hpp"
    click Smc5326Protocol "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/protocol/Smc5326Protocol.hpp"
    click PagerDecoder "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/decoder/PagerDecoder.hpp"
    click Td157Decoder "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/decoder/Td157Decoder.hpp"
    click Td165Decoder "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/decoder/Td165Decoder.hpp"
    click Td174Decoder "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/decoder/Td174Decoder.hpp"
    click L8RDecoder "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/decoder/L8RDecoder.hpp"
    click L8SDecoder "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/decoder/L8SDecoder.hpp"
    click AppFileSystem "https://github.com/denr01/fz-chiefcooker/blob/master/app/AppFileSystem.hpp"
    click FileManager "https://github.com/denr01/fz-chiefcooker/blob/master/lib/file/FileManager.hpp"
    click Directory "https://github.com/denr01/fz-chiefcooker/blob/master/lib/file/Directory.hpp"
    click FlipperFile "https://github.com/denr01/fz-chiefcooker/blob/master/lib/file/FlipperFile.hpp"
    click KnownStationData "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/data/KnownStationData.hpp"
    click NamedPagerData "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/data/NamedPagerData.hpp"
    click ReceivedPagerData "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/data/ReceivedPagerData.hpp"
    click StoredPagerData "https://github.com/denr01/fz-chiefcooker/blob/master/app/pager/data/StoredPagerData.hpp"
    click SubGhzModule "https://github.com/denr01/fz-chiefcooker/blob/master/lib/hardware/subghz/SubGhzModule.hpp"
    click FrequencyManager "https://github.com/denr01/fz-chiefcooker/blob/master/lib/hardware/subghz/FrequencyManager.hpp"
    click SubGhzPayload "https://github.com/denr01/fz-chiefcooker/blob/master/lib/hardware/subghz/SubGhzPayload.hpp"
    click SubGhzState "https://github.com/denr01/fz-chiefcooker/blob/master/lib/hardware/subghz/SubGhzState.hpp"
    click SubGhzReceivedData "https://github.com/denr01/fz-chiefcooker/blob/master/lib/hardware/subghz/data/SubGhzReceivedData.hpp"
    click SubGhzReceivedDataImpl "https://github.com/denr01/fz-chiefcooker/blob/master/lib/hardware/subghz/data/SubGhzReceivedDataImpl.hpp"
    click SubGhzReceivedDataStub "https://github.com/denr01/fz-chiefcooker/blob/master/lib/hardware/subghz/data/SubGhzReceivedDataStub.hpp"
    click FlipperDolphin "https://github.com/denr01/fz-chiefcooker/blob/master/lib/FlipperDolphin.hpp"
    click HandlerContext "https://github.com/denr01/fz-chiefcooker/blob/master/lib/HandlerContext.hpp"
    click BuildScript "https://github.com/denr01/fz-chiefcooker/blob/master/scripts/build-and-clear.py"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0066CC,color:#000
    classDef core fill:#DFF5D0,stroke:#339900,color:#000
    classDef storage fill:#FFF9C4,stroke:#E6A800,color:#000
    classDef hardware fill:#FFD6D6,stroke:#CC0000,color:#000
    classDef helper fill:#E0E0E0,stroke:#888888,color:#000
    classDef script fill:#F0F0F0,stroke:#666666,color:#000
```
