# andeskjerf/waybar-module-pomodoro architecture

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

- Interactive diagram: https://gitdiagram.com/andeskjerf/waybar-module-pomodoro
- Repository: https://github.com/andeskjerf/waybar-module-pomodoro

## Overview

##### Main Components

a) Core Components:
- Timer Service (src/services/timer.rs)
- Server Service (src/services/server.rs)
- Cache Service (src/services/cache.rs)
- Configuration System (src/models/config.rs)
- Message Handler (src/models/message.rs)

b) External Interfaces:
- Waybar Integration
- File System (for persistence)
- System Status Bar

##### Component Relationships

**┌─────────────────────────────────────────────────────────────┐**
- Waybar Module Pomodoro                   │
- ┤

- ┌─────────────┐        ┌───────────────┐                  │

- Server    ◄────────┤    Waybar     │                  │
- Service   │        │  Integration  │                  │

- ┬───────┘        └───────────────┘                  │

- ▼                                                    │
- ┌─────────────┐        ┌───────────────┐                  │
- Timer    │◄───────┤Configuration  │                  │
- Service   │        │    System     │                  │
- ┬───────┘        └───────────────┘                  │

- ▼                                                    │
- ┌─────────────┐        ┌───────────────┐                  │
- Cache    │◄───────┤   Message     │                  │
- Service   │        │   Handler     │                  │
- ┘        └───────────────┘                  │

- ┘

##### Important Details

a) Service Interactions:
- How the Server Service receives commands from Waybar
- Timer Service state management
- Cache Service persistence flow
- Configuration System influence on all components

b) Data Flow:
- Command flow (toggle, start, stop, reset)
- State updates to Waybar
- Configuration changes
- Persistence operations

##### Technical Details to Note

- JSON communication points with Waybar
- File system interaction points for persistence
- Where timer configurations are applied

##### The integration points with the system bar

Remember to include a note about the project's primary purpose as a Waybar module, which influences its architecture and integration patterns.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Main
        Entry["Application Entry Point"]
    end

    subgraph Services
        Server["Server Service"]
        Timer["Timer Service"]
        Cache["Cache Service"]
        ServicesModule["Services Module"]
    end

    subgraph Models
        Config["Configuration System"]
        Message["Message Handler"]
        ModelsModule["Models Module"]
    end

    subgraph Utils
        Constants["Utility Constants"]
        Helpers["Helper Functions"]
        UtilsModule["Utils Module"]
    end

    subgraph External
        Waybar["Waybar Integration"]
        FileSystem["File System"]
        StatusBar["System Status Bar"]
    end

    %% Relationships
    Entry --> Server
    Entry --> Timer
    Entry --> Cache

    Server --> Timer
    Server --> Cache
    Server --> Message
    Waybar --> Server

    Timer --> Cache
    Timer --> Config
    Timer --> Message

    Cache --> FileSystem
    Cache --> Message

    Config --> Constants
    Message --> Helpers

    Server --> StatusBar

    %% Click Events
    click Entry "https://github.com/andeskjerf/waybar-module-pomodoro/blob/main/src/main.rs"
    click Server "https://github.com/andeskjerf/waybar-module-pomodoro/blob/main/src/services/server.rs"
    click Timer "https://github.com/andeskjerf/waybar-module-pomodoro/blob/main/src/services/timer.rs"
    click Cache "https://github.com/andeskjerf/waybar-module-pomodoro/blob/main/src/services/cache.rs"
    click ServicesModule "https://github.com/andeskjerf/waybar-module-pomodoro/blob/main/src/services/mod.rs"
    click Config "https://github.com/andeskjerf/waybar-module-pomodoro/blob/main/src/models/config.rs"
    click Message "https://github.com/andeskjerf/waybar-module-pomodoro/blob/main/src/models/message.rs"
    click ModelsModule "https://github.com/andeskjerf/waybar-module-pomodoro/blob/main/src/models/mod.rs"
    click Constants "https://github.com/andeskjerf/waybar-module-pomodoro/blob/main/src/utils/consts.rs"
    click Helpers "https://github.com/andeskjerf/waybar-module-pomodoro/blob/main/src/utils/helper.rs"
    click UtilsModule "https://github.com/andeskjerf/waybar-module-pomodoro/blob/main/src/utils/mod.rs"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef service fill:#ddf,stroke:#333,stroke-width:2px
    classDef model fill:#ffd,stroke:#333,stroke-width:2px
    classDef util fill:#dfd,stroke:#333,stroke-width:2px
    classDef external fill:#fdd,stroke:#333,stroke-width:2px
    classDef module fill:#eee,stroke:#333,stroke-width:2px

    class Server,Timer,Cache service
    class Config,Message model
    class Constants,Helpers util
    class Waybar,FileSystem,StatusBar external
    class ServicesModule,ModelsModule,UtilsModule module
    class Entry default
```
