# rtmilliken/edfbrowser architecture

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

- Interactive diagram: https://gitdiagram.com/rtmilliken/edfbrowser
- Repository: https://github.com/rtmilliken/edfbrowser

## Overview

##### Project’s Main Components
- User Interface (UI) Components:
- Main window (main.cpp, mainwindow.cpp/h) which acts as the central UI container.
- Various dialogs and dock widgets such as about_dialog, options_dialog, annotations_dock, jump_dialog, load_montage_dialog, and more.
- Core Data Processing & Conversion Modules:
- Conversion components (e.g., ascii2edf, bdf2edf, biosemi2bdfplus, manscan2edf, emsa2edf, etc.) which implement file format conversions.
- EDF handling libraries (e.g., edflib.c/h, edf_compat, edf_annotations) are responsible for the low-level EDF file processing.
- Filter and signal processing modules (e.g., ecg_filter, filter, filtercurve, fourier, kiss_fft integration, etc.).
- Utility and Supporting Components:
- Utility functions (utils.c/h, utc_date_time) supporting time, file checks, and general computations.
- Third-party libraries such as fidlib and kiss_fft under the third_party directory to provide additional functionalities (e.g., FFT analysis).

##### File Structure for Architectural Patterns
- Clear separation of UI components (dialogs, dock widgets, main window) and business logic (conversion routines, filtering, signal analysis).
- Each conversion and processing task is implemented as standalone modules (using separate .cpp and .h pairs) which can be depicted as discrete components.
- The integration with third-party libraries (located under third_party) suggests how the system leverages external functionalities for signal processing (e.g., Fourier analysis, file manipulation).

a. Main Components:
- A “Utilities & External Libraries” section for utility functions and the third_party libraries (fidlib and kiss_fft).
b. Relationships and Interactions:
- Link UI components to the core processing modules to indicate that user actions (such as file export or filter adjustment) trigger conversion routines and processing logic.
- That the processing modules depend on both the internal EDF-handling libraries and third-party libraries for specialized tasks like FFT and file I/O.
c. Architectural Patterns and Design Principles:
- Separation of concerns: UI elements are kept separate from business logic, and both are modular.
- Patterns such as Model-View separation inherent in Qt’s structure (widgets for presentation, separate processing routines).
- Document the design such that each conversion or filter is a discrete subsystem that can be independently updated or debugged.
d. Technologies & Frameworks:
- That the project is based on Qt4 (with qmake used to build the UI), and it’s built using GCC/MinGW.
- Integration with C-based libraries (edflib, utility routines) and third-party signal processing (kiss_fft, fidlib).

##### Elements
- Clear labels for each main component (e.g., “Main Window”, “Conversion Module”, “EDF Library”, “Filter Module”, “Third-Party FFT Library”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interface"
        UI_Main["Main Window"] 
        UI_About["About Dialog"]
        UI_Options["Options Dialog"]
        UI_Annotations["Annotations Dock"]
        UI_Jump["Jump Dialog"]
        UI_LoadMontage["Load Montage Dialog"]
    end

    subgraph "Core Data Processing & Conversion"
        subgraph "Conversion Modules"
            C1["ascii2edf"]
            C2["bdf2edf"]
            C3["biosemi2bdfplus"]
            C4["manscan2edf"]
            C5["emsa2edf"]
        end
        subgraph "EDF Handling Libraries"
            E1["edflib"]
            E2["EDF Compat/Annotations"]
        end
        subgraph "Filter & Signal Processing"
            F1["ECG Filter"]
            F2["Generic Filter"]
            F3["Fourier Processing"]
        end
    end

    subgraph "Utilities & External Libraries"
        subgraph "Utility Functions"
            U1["utils"]
            U2["utc_date_time"]
        end
        subgraph "Third-Party Libraries"
            T1["Fidlib"]
            T2["Kiss FFT"]
        end
    end

    %% UI Interactions
    UI_Main -->|"opens"| UI_About
    UI_Main -->|"opens"| UI_Options
    UI_Main -->|"opens"| UI_Annotations
    UI_Main -->|"opens"| UI_Jump
    UI_Main -->|"opens"| UI_LoadMontage

    %% UI triggers processing modules
    UI_Main -->|"triggers"| C1
    UI_Main -->|"triggers"| F1

    %% Conversion Modules interactions
    C1 -->|"uses"| E1
    C1 -->|"calls"| U1
    C1 -->|"integrates"| T1

    %% Filter Modules interactions
    F1 -->|"calls"| U1
    F1 -->|"integrates"| T2

    %% Styles
    class UI_Main,UI_About,UI_Options,UI_Annotations,UI_Jump,UI_LoadMontage ui
    class C1,C2,C3,C4,C5,E1,E2,F1,F2,F3 processing
    class U1,U2 utility
    class T1,T2 thirdparty

    %% Click Events - User Interface
    click UI_Main "https://github.com/rtmilliken/edfbrowser/blob/master/main.cpp"
    click UI_About "https://github.com/rtmilliken/edfbrowser/blob/master/about_dialog.cpp"
    click UI_Options "https://github.com/rtmilliken/edfbrowser/blob/master/options_dialog.cpp"
    click UI_Annotations "https://github.com/rtmilliken/edfbrowser/blob/master/annotations_dock.cpp"
    click UI_Jump "https://github.com/rtmilliken/edfbrowser/blob/master/jump_dialog.cpp"
    click UI_LoadMontage "https://github.com/rtmilliken/edfbrowser/blob/master/load_montage_dialog.cpp"

    %% Click Events - Conversion Modules
    click C1 "https://github.com/rtmilliken/edfbrowser/blob/master/ascii2edf.cpp"
    click C2 "https://github.com/rtmilliken/edfbrowser/blob/master/bdf2edf.cpp"
    click C3 "https://github.com/rtmilliken/edfbrowser/blob/master/biosemi2bdfplus.cpp"
    click C4 "https://github.com/rtmilliken/edfbrowser/blob/master/manscan2edf.cpp"
    click C5 "https://github.com/rtmilliken/edfbrowser/blob/master/emsa2edf.cpp"

    %% Click Events - EDF Handling Libraries
    click E1 "https://github.com/rtmilliken/edfbrowser/blob/master/edflib.c"
    click E2 "https://github.com/rtmilliken/edfbrowser/blob/master/edf_compat.cpp"

    %% Click Events - Filter & Signal Processing
    click F1 "https://github.com/rtmilliken/edfbrowser/blob/master/ecg_filter.cpp"
    click F2 "https://github.com/rtmilliken/edfbrowser/blob/master/filter.cpp"
    click F3 "https://github.com/rtmilliken/edfbrowser/blob/master/fourier.c"

    %% Click Events - Utility Functions
    click U1 "https://github.com/rtmilliken/edfbrowser/blob/master/utils.c"
    click U2 "https://github.com/rtmilliken/edfbrowser/blob/master/utc_date_time.c"

    %% Click Events - Third-Party Libraries
    click T1 "https://github.com/rtmilliken/edfbrowser/blob/master/third_party/fidlib/fidlib.c"
    click T2 "https://github.com/rtmilliken/edfbrowser/blob/master/third_party/kiss_fft/kiss_fft.c"
```
