# eliostvs/tomate-gtk architecture

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

- Interactive diagram: https://gitdiagram.com/eliostvs/tomate-gtk
- Repository: https://github.com/eliostvs/tomate-gtk

## Overview

##### Main Components Identification

The system can be broken down into these major components:

a. Core (Pomodoro Logic)
- Timer Management
- Session Management
- Event System
- Configuration Management
- Plugin System

b. User Interface
- GTK3 Windows and Dialogs
- Widgets (Countdown, HeaderBar, etc.)
- System Tray Integration

c. Plugin Architecture
- Built-in Plugins
- External Plugin Support
- Audio System

**[Configuration Manager] <-> [Event System]**
- ↑                       ↑
- [Timer Core] <-------> [Session Manager]
- ↑
- [State Machine]

**[Plugin Manager]**
- ↑
**[Built-in Plugins] | [External Plugins]**
- Alarm            | - Indicator
- Ticking         | - StatusIcon
- Notify          | - Launcher
- Script          | - StatusNotifierItem
- Break Screen    |
- Auto Pause      |

**[Main Window] <-> [Dialogs] <-> [Widgets]**
- ↑              ↑           ↑
**[System Tray] <--> [GTK3 Interface]**

##### Important Relationships to Highlight

- Event-driven nature of the application with the Event System connecting all components
- Plugin architecture's extensibility
- Demonstrate the separation between UI and core logic
- How the audio system integrates with various plugins

##### Technical Details

- GTK3 as the UI framework
- Python as the implementation language
- File system integration for configuration
- Audio system architecture
- Plugin loading mechanism

##### Implementation Notes

- The Model-View-Controller pattern evident in the codebase
- The event-driven architecture (tomate/pomodoro/event.py)
- The finite state machine implementation (tomate/pomodoro/fsm.py)
- The plugin system's extensibility
- The configuration management system

##### External Integration Points

Connections to:
- System notifications
- Audio system
- Desktop environment integration
- File system (for configuration and plugins)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef core fill:#b3d1ff,stroke:#333
    classDef plugin fill:#b3ffb3,stroke:#333
    classDef ui fill:#ffd9b3,stroke:#333
    classDef media fill:#e6e6e6,stroke:#333

    %% Core Layer
    subgraph Core
        ConfigMgr["Configuration Manager"]:::core
        EventSys["Event System"]:::core
        TimerCore["Timer Core"]:::core
        SessionMgr["Session Manager"]:::core
        StateMachine["State Machine"]:::core
        AppCore["Application Core"]:::core

        TimerCore <--> EventSys
        TimerCore <--> SessionMgr
        TimerCore --> StateMachine
        ConfigMgr <--> EventSys
        AppCore --> EventSys
    end

    %% Plugin Layer
    subgraph Plugins
        PluginMgr["Plugin Manager"]:::plugin
        AudioSys["Audio System"]:::plugin

        subgraph BuiltInPlugins["Built-in Plugins"]
            AlarmPlugin["Alarm Plugin"]:::plugin
            TickingPlugin["Ticking Plugin"]:::plugin
            NotifyPlugin["Notify Plugin"]:::plugin
            ScriptPlugin["Script Plugin"]:::plugin
            BreakPlugin["Break Screen Plugin"]:::plugin
            AutoPausePlugin["Auto Pause Plugin"]:::plugin
        end

        PluginMgr --> BuiltInPlugins
        AudioSys --> AlarmPlugin
        AudioSys --> TickingPlugin
    end

    %% UI Layer
    subgraph UserInterface
        MainWindow["Main Window"]:::ui
        SysTray["System Tray"]:::ui
        
        subgraph Widgets
            CountdownWidget["Countdown Widget"]:::ui
            HeaderBar["Header Bar"]:::ui
            SessionBtn["Session Button"]:::ui
        end
        
        subgraph Dialogs
            PrefDialog["Preference Dialog"]:::ui
            AboutDialog["About Dialog"]:::ui
        end

        MainWindow --> Widgets
        MainWindow --> Dialogs
        MainWindow --> SysTray
    end

    %% Media Resources
    AlarmSound["Alarm Sound"]:::media
    ClockSound["Clock Sound"]:::media
    
    %% Cross-layer connections
    EventSys --> PluginMgr
    PluginMgr --> MainWindow
    EventSys --> MainWindow
    AudioSys --> AlarmSound
    AudioSys --> ClockSound

    %% Click events for component mapping
    click TimerCore "https://github.com/eliostvs/tomate-gtk/blob/master/tomate/pomodoro/timer.py"
    click SessionMgr "https://github.com/eliostvs/tomate-gtk/blob/master/tomate/pomodoro/session.py"
    click EventSys "https://github.com/eliostvs/tomate-gtk/blob/master/tomate/pomodoro/event.py"
    click ConfigMgr "https://github.com/eliostvs/tomate-gtk/blob/master/tomate/pomodoro/config.py"
    click StateMachine "https://github.com/eliostvs/tomate-gtk/blob/master/tomate/pomodoro/fsm.py"
    click PluginMgr "https://github.com/eliostvs/tomate-gtk/blob/master/tomate/pomodoro/plugin.py"
    click AudioSys "https://github.com/eliostvs/tomate-gtk/blob/master/tomate/audio/player.py"
    click AlarmPlugin "https://github.com/eliostvs/tomate-gtk/blob/master/data/plugins/alarm.py"
    click TickingPlugin "https://github.com/eliostvs/tomate-gtk/blob/master/data/plugins/ticking.py"
    click NotifyPlugin "https://github.com/eliostvs/tomate-gtk/blob/master/data/plugins/notify.py"
    click ScriptPlugin "https://github.com/eliostvs/tomate-gtk/blob/master/data/plugins/script.py"
    click BreakPlugin "https://github.com/eliostvs/tomate-gtk/blob/master/data/plugins/breakscreen.py"
    click AutoPausePlugin "https://github.com/eliostvs/tomate-gtk/blob/master/data/plugins/autopause.py"
    click MainWindow "https://github.com/eliostvs/tomate-gtk/blob/master/tomate/ui/window.py"
    click SysTray "https://github.com/eliostvs/tomate-gtk/blob/master/tomate/ui/systray.py"
    click CountdownWidget "https://github.com/eliostvs/tomate-gtk/blob/master/tomate/ui/widgets/countdown.py"
    click HeaderBar "https://github.com/eliostvs/tomate-gtk/blob/master/tomate/ui/widgets/headerbar.py"
    click SessionBtn "https://github.com/eliostvs/tomate-gtk/blob/master/tomate/ui/widgets/session_button.py"
    click PrefDialog "https://github.com/eliostvs/tomate-gtk/blob/master/tomate/ui/dialogs/preference.py"
    click AboutDialog "https://github.com/eliostvs/tomate-gtk/blob/master/tomate/ui/dialogs/about.py"
    click AppCore "https://github.com/eliostvs/tomate-gtk/blob/master/tomate/pomodoro/app.py"
    click AlarmSound "https://github.com/eliostvs/tomate-gtk/blob/master/data/media/alarm.ogg"
    click ClockSound "https://github.com/eliostvs/tomate-gtk/blob/master/data/media/clock.ogg"
```
