# joshgermon/cubby architecture

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

- Interactive diagram: https://gitdiagram.com/joshgermon/cubby
- Repository: https://github.com/joshgermon/cubby

## Overview

##### Main Components

a) Core Components:
- Monitor Module (monitor.c/h): Handles device event listening using systemd/udev
- Backup Module (backup.c/h): Manages rsync backup operations
- Notifier Module (notifier.c/h): Handles status notifications
- CLI Interface (cli.c/h): Manages user interactions
- Utils Module (utils.c/h): Contains shared utilities

b) External Dependencies:
- systemd/udev (for device monitoring)
- rsync (for backup operations)
- Linux filesystem (for mounting operations)

- CLI Interface     |

- ↓

- Monitor Service     |

- ↓

- Backup Service      |

- ↓

- Notification Service  |

##### Data Flow Representation

- CLI → Monitor: Configuration and commands
- Monitor → Backup: Device event triggers
- Backup → Notifier: Progress updates
- System Events → Monitor: USB/SD card events

##### Component Details

Monitor Service:

- Monitor Service  |

- SD-Device API   |
- Event Listening |
- Device Mounting |

Backup Service:

- Backup Service   |

- rsync Interface |
- Path Management |
- Timestamp Dirs  |

##### Implementation Notes

- The event-driven nature of the system
- Clear separation between monitoring and backup operations
- Security boundaries (root permissions)
- File system interaction points

Keep the focus on the core functionality: device monitoring → mounting → backup, while showing the supporting components that make this possible.

Remember to highlight the specific Linux dependencies (systemd, udev) as they are crucial to the system's operation and represent important platform constraints.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph User
        CLI["CLI Interface"]
    end

    subgraph Core["Core Components"]
        Monitor["Monitor Service"]
        Backup["Backup Service"]
        Notifier["Notification Service"]
        Utils["Utilities"]
        Main["Main Program"]
    end

    subgraph System["System Dependencies"]
        Systemd["systemd/udev"]
        Rsync["rsync"]
        FileSystem["Linux Filesystem"]
    end

    %% Core Component Relationships
    CLI --> Main
    Main --> Monitor
    Monitor --> Backup
    Backup --> Notifier
    Utils --> Monitor
    Utils --> Backup
    Utils --> Notifier

    %% System Dependencies
    Systemd --> Monitor
    FileSystem --> Monitor
    Rsync --> Backup
    FileSystem --> Backup

    %% Click Events
    click CLI "https://github.com/joshgermon/cubby/blob/master/src/cli.c"
    click Monitor "https://github.com/joshgermon/cubby/blob/master/src/monitor.c"
    click Backup "https://github.com/joshgermon/cubby/blob/master/src/backup.c"
    click Notifier "https://github.com/joshgermon/cubby/blob/master/src/notifier.c"
    click Utils "https://github.com/joshgermon/cubby/blob/master/src/utils.c"
    click Main "https://github.com/joshgermon/cubby/blob/master/src/main.c"

    classDef default fill:#f9f,stroke:#333,stroke-width:2px
    classDef system fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef user fill:#FFD700,stroke:#333,stroke-width:2px

    class Systemd,Rsync,FileSystem system
    class Monitor,Backup,Notifier,Utils,Main core
    class CLI user

    %% Legend
    subgraph Legend
        L1[User Interface]:::user
        L2[Core Component]:::core
        L3[System Dependency]:::system
    end
```
