# tkntrec/edcb architecture

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

- Interactive diagram: https://gitdiagram.com/tkntrec/edcb
- Repository: https://github.com/tkntrec/edcb

## Overview

##### Main Components
- “BonCtrl” Module: Contains low-level code for managing digital broadcast data such as TS packets, PAT/PMT handling, service filtering, etc. This is the core driver layer interfacing with the tuner hardware.
- “Common” Library: Provides shared utilities, definitions, configuration parsing (via INI file processing), logging, error/stack trace handling, TCP/pipe servers, and other reusable functions consumed by other components.
- “EpgDataCap_Bon” and “EpgDataCap3”: These components are responsible for capturing and processing EPG data. They convert the broadcast signals into electronic program guide information.
- “EpgTimer” and its related modules: This is the graphical user interface part of the system that lets users view EPG data, configure reservations, perform searches, and manage settings. It uses WPF/XAML for window design.
- “EpgTimerSrv” (and related admin proxy and plug-in modules): Acts as a background service (or server) managing reservations, interacting with the BonCtrl layer, and handling communications with the GUI (EpgTimer) as well as plugins like EpgTimerPlugIn. The server handles tasks like database management, scheduling, and event notifications.

##### Relationships and Interactions
- The GUI front-end (EpgTimer) interacts with the background service (EpgTimerSrv) to send commands (such as reservation updates or program searches). Data flows in both directions via defined command protocols (using the Common library’s messaging and pipe/TCP server capabilities).
- The service and data capture components (EpgDataCap_Bon/EpgDataCap3) interface with the BonCtrl module to acquire and process raw broadcast streams.
- Plugins (e.g., EdcbPlugIn, EpgTimerPlugIn) extend or modify the built-in functionalities of the main timer application.
- The “ini” directory acts as the configuration hub for many modules. Changes in these INI/XML settings can affect behavior across the system.
- External tools (in “Tools”, “SendTSTCP”, etc.) likely allow for additional operations like file format conversion, debugging support, or stream manipulation.

##### Architectural Patterns and Design Principles
- Modularity: Each directory represents a nearly self-contained module (e.g., BonCtrl for driver specific tasks, Common for shared utilities, EpgTimer as the UI, etc.).
- Layered Approach: There is a clear separation between the low-level driver/tuning components, an intermediate layer for data capture and processing (EPG data), and the presentation/control layer (user interface and service backend). This layered architecture simplifies maintenance and extension.
- Plugin Extensibility: The use of plugins and external tools shows that the system is built to be extensible and customizable. The design encourages modifications via additional modules (for example, through changes in the EpgTimer plug-in or the custom modifications in the fork).

##### Relevant Technologies, Frameworks, and Libraries
- Microsoft Visual Studio Solutions and project files (VCXPROJ, SLN) indicate a C/C++ and C# based application, with GUI built in WPF/XAML (as seen in EpgTimer).
- Standard Windows libraries (for creating pipe/TCP servers, decoding broadcast signals, etc.), along with custom libraries for TS packet utilities and EPG data handling.
- The use of configuration files (INI, XML) suggests runtime customization.
- External libraries such as Civetweb (embedded web server for HTTP communication in EpgTimerSrv) and Lua (for scripting in the server) also play significant roles.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Driver/Data Acquisition Layer
    subgraph "Driver/Data Acquisition Layer"
        BONCTRL["BonCtrl – TS/DVB Handling"]:::driver
    end

    %% Shared Utilities Layer
    subgraph "Shared Utilities Layer"
        COMMON["Common – Utilities & Messaging"]:::utilities
    end

    %% Data Capture/Processing Layer
    subgraph "Data Capture/Processing Layer"
        DATA_CAP_BON["EpgDataCap_Bon – EPG Capture (Bon)"]:::datacap
        DATA_CAP3["EpgDataCap3 – EPG Capture v3"]:::datacap
    end

    %% Application/Service Layer
    subgraph "Application/Service Layer"
        EPG_TIMER["EpgTimer – GUI Frontend"]:::ui
        EPG_TIMER_SRV["EpgTimerSrv – Backend Service"]:::service
        EPG_TIMER_ADMIN["EpgTimerAdminProxy – Service Administration"]:::service
    end

    %% Plugin Extensions
    subgraph "Plugin Extensions"
        EPG_TIMER_PLUGIN["EpgTimerPlugIn"]:::plugin
        EDCB_PLUGIN["EdcbPlugIn"]:::plugin
    end

    %% External Tools & Utilities
    subgraph "External Tools & Utilities"
        TOOLS["Tools"]:::tools
        SENDTSTCP["SendTSTCP"]:::tools
        RECNAME["RecName_Macro"]:::tools
        WRITE_DEFAULT["Write_Default"]:::tools
        WRITE_ONE["Write_OneService"]:::tools
    end

    %% Configuration & Documentation
    subgraph "Configuration & Documentation"
        CONFIG["ini – Configuration Files"]:::config
        DOC["Document – Documentation"]:::config
    end

    %% Data/Command Flows
    EPG_TIMER -->|"sendsCommands"| EPG_TIMER_SRV
    EPG_TIMER_SRV -->|"uses"| COMMON
    EPG_TIMER_SRV -->|"communicatesWith"| BONCTRL
    DATA_CAP_BON -->|"getsStreamFrom"| BONCTRL
    DATA_CAP3 -->|"getsStreamFrom"| BONCTRL
    EPG_TIMER -->|"loadsPlugin"| EPG_TIMER_PLUGIN
    EPG_TIMER_SRV -->|"integratesPlugin"| EDCB_PLUGIN
    COMMON -->|"readsConfig"| CONFIG
    EPG_TIMER_SRV -->|"activates"| EPG_TIMER_ADMIN
    EPG_TIMER_SRV -->|"utilizes"| TOOLS
    TOOLS --> SENDTSTCP
    TOOLS --> RECNAME
    TOOLS --> WRITE_DEFAULT
    TOOLS --> WRITE_ONE

    %% Click Events
    click BONCTRL "https://github.com/tkntrec/edcb/tree/my-build/BonCtrl/"
    click COMMON "https://github.com/tkntrec/edcb/tree/my-build/Common/"
    click DATA_CAP_BON "https://github.com/tkntrec/edcb/tree/my-build/EpgDataCap_Bon/"
    click DATA_CAP3 "https://github.com/tkntrec/edcb/tree/my-build/EpgDataCap3/"
    click EPG_TIMER "https://github.com/tkntrec/edcb/tree/my-build/EpgTimer/"
    click EPG_TIMER_SRV "https://github.com/tkntrec/edcb/tree/my-build/EpgTimerSrv/"
    click EPG_TIMER_ADMIN "https://github.com/tkntrec/edcb/tree/my-build/EpgTimerAdminProxy/"
    click EPG_TIMER_PLUGIN "https://github.com/tkntrec/edcb/tree/my-build/EpgTimerPlugIn/"
    click EDCB_PLUGIN "https://github.com/tkntrec/edcb/tree/my-build/EdcbPlugIn/"
    click TOOLS "https://github.com/tkntrec/edcb/tree/my-build/Tools/"
    click SENDTSTCP "https://github.com/tkntrec/edcb/tree/my-build/SendTSTCP/"
    click RECNAME "https://github.com/tkntrec/edcb/tree/my-build/RecName_Macro/"
    click WRITE_DEFAULT "https://github.com/tkntrec/edcb/tree/my-build/Write_Default/"
    click WRITE_ONE "https://github.com/tkntrec/edcb/tree/my-build/Write_OneService/"
    click CONFIG "https://github.com/tkntrec/edcb/tree/my-build/ini/"
    click DOC "https://github.com/tkntrec/edcb/tree/my-build/Document/"

    %% Styles
    classDef driver fill:#f99,stroke:#333,stroke-width:2px;
    classDef utilities fill:#ddd,stroke:#333,stroke-width:2px;
    classDef datacap fill:#ccf,stroke:#333,stroke-width:2px;
    classDef ui fill:#9f9,stroke:#333,stroke-width:2px;
    classDef service fill:#9ff,stroke:#333,stroke-width:2px;
    classDef plugin fill:#ff9,stroke:#333,stroke-width:2px;
    classDef tools fill:#f9f,stroke:#333,stroke-width:2px;
    classDef config fill:#fc9,stroke:#333,stroke-width:2px;
```
