# ronsijm/buttfish architecture

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

- Interactive diagram: https://gitdiagram.com/ronsijm/buttfish
- Repository: https://github.com/ronsijm/buttfish

## Overview

Key Components to Include in the System Design:

##### Core Components
- Input Processing Layer
- FEN String Parser
- Manual Input Handler
- Chess Engine Integration
- UCI Engine Interface (Stockfish)
- Engine Selection System

##### Device Management Layer
- Device Discovery Manager
- Device Broadcaster
- Device Connectors
- Buttplug.io Connector
- Yeelight Connector
- Console Output Connector

##### Encoding Layer
- Morse Code Encoder
- Simplified Pulse Encoder
- Character Encoding Interface

##### Output Processing
- ASCII Visualization
- Device Output Management

##### Use a top-down approach with clear separation of concerns
- Top Layer: Input Sources (FEN strings, Manual input)
- Middle Layer: Processing (Chess engine, Encoders)
- Bottom Layer: Output Devices (Buttplug.io devices, Yeelights, Console)

##### Component Grouping
- Use clear labels for each group
- Configuration dependencies

Special Considerations:

##### Modular nature of the system
- How different encoders can be plugged in
- Demonstrate device abstraction layer
- Configuration points

##### External Dependencies
- Integration points with Stockfish
- Network connections for device discovery
- API dependencies

##### Configuration Flow
- How appsettings.json influences component behavior
- Optional features (EndPositionOnly, UseManualInput)

##### Testing Boundaries
- Test coverage scope
- Integration points with external systems

##### The configuration-driven behavior

Remember to maintain a balance between technical accuracy and readability, as this project combines serious engineering with humorous intent.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        FEN["FEN String Parser"]:::input
        Manual["Manual Input Handler"]:::input
    end

    subgraph "Chess Engine"
        UCI["UCI Engine Interface"]:::engine
        Stock["Stockfish Implementation"]:::engine
        EngSel["Engine Selector"]:::engine
    end

    subgraph "Encoding Layer"
        MorseEnc["Morse Encoder"]:::encoder
        PulseEnc["Simplified Pulse Encoder"]:::encoder
        CharEnc["Character Encoding Interface"]:::encoder
    end

    subgraph "Device Management"
        DevDisc["Device Discovery Manager"]:::device
        DevBroad["Device Broadcaster"]:::device
        
        subgraph "Device Connectors"
            ButtPlug["Buttplug.io Connector"]:::connector
            Yeelight["Yeelight Connector"]:::connector
            Console["Console Output"]:::connector
        end
    end

    subgraph "Output Processing"
        ASCII["ASCII Visualization"]:::output
        DevOut["Device Output Management"]:::output
    end

    %% Relationships
    FEN --> UCI
    Manual --> UCI
    UCI --> Stock
    Stock --> EngSel
    EngSel --> MorseEnc & PulseEnc
    MorseEnc & PulseEnc --> CharEnc
    CharEnc --> DevBroad
    DevBroad --> DevDisc
    DevDisc --> ButtPlug & Yeelight & Console
    DevDisc --> ASCII
    ASCII --> DevOut
    DevOut --> ButtPlug & Yeelight & Console

    %% Click Events
    click FEN "https://github.com/RonSijm/ButtFish/blob/main/RonSijm.ButtFish/InputLoops/FENBasedLoop.cs"
    click Manual "https://github.com/RonSijm/ButtFish/blob/main/RonSijm.ButtFish/InputLoops/ManualInputLoop.cs"
    click UCI "https://github.com/RonSijm/ButtFish/blob/main/RonSijm.UCIEngineInterop/Core/IUCIEngine.cs"
    click Stock "https://github.com/RonSijm/ButtFish/blob/main/RonSijm.UCIEngineInterop/Core/Stockfish.cs"
    click EngSel "https://github.com/RonSijm/ButtFish/blob/main/RonSijm.ButtFish/EngineSelector.cs"
    click DevDisc "https://github.com/RonSijm/ButtFish/blob/main/RonSijm.ButtFish/DeviceDiscoveryManager.cs"
    click DevBroad "https://github.com/RonSijm/ButtFish/blob/main/RonSijm.ButtFish/DeviceBroadcaster.cs"
    click ButtPlug "https://github.com/RonSijm/ButtFish/blob/main/RonSijm.ButtFish/Connectors/ButtplugConnector.cs"
    click Yeelight "https://github.com/RonSijm/ButtFish/blob/main/RonSijm.ButtFish/Connectors/YeelightConnector.cs"
    click Console "https://github.com/RonSijm/ButtFish/blob/main/RonSijm.ButtFish/Devices/ConsoleOutputDevice.cs"
    click MorseEnc "https://github.com/RonSijm/ButtFish/blob/main/RonSijm.ButtFish/Encoders/MorseEncoder.cs"
    click PulseEnc "https://github.com/RonSijm/ButtFish/blob/main/RonSijm.ButtFish/Encoders/SimplifiedPulseEncoder.cs"
    click CharEnc "https://github.com/RonSijm/ButtFish/blob/main/RonSijm.ButtFish/Encoders/ICharacterEncoder.cs"
    click ASCII "https://github.com/RonSijm/ButtFish/blob/main/RonSijm.ButtFish/Ascii/BoardToAscii.cs"
    click DevOut "https://github.com/RonSijm/ButtFish/blob/main/RonSijm.ButtFish/Devices/IDeviceAbstraction.cs"

    %% Styling
    classDef input fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef engine fill:#90EE90,stroke:#333,stroke-width:2px
    classDef encoder fill:#FFD700,stroke:#333,stroke-width:2px
    classDef device fill:#FFA07A,stroke:#333,stroke-width:2px
    classDef connector fill:#DEB887,stroke:#333,stroke-width:2px
    classDef output fill:#FF6B6B,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["Input Components"]:::input
        L2["Engine Components"]:::engine
        L3["Encoder Components"]:::encoder
        L4["Device Management"]:::device
        L5["Device Connectors"]:::connector
        L6["Output Components"]:::output
    end
```
