# jonocarroll/ntfy architecture

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

- Interactive diagram: https://gitdiagram.com/jonocarroll/ntfy
- Repository: https://github.com/jonocarroll/ntfy

## Overview

Based on our detailed review of the file structure and README, this project is an R package that acts as a lightweight wrapper around a simple HTTP-based pub‐sub notification service (ntfy). The package exposes functions that perform RESTful (POST/GET) calls to the external ntfy server (defaulting to ntfy.sh) while adding R-friendly capabilities and extra features (such as sending ggplot2 images, emojis, and timing details).

##### Main Components
- R Package Core – This encompasses the core R scripts found in the “R” directory. Key functions include:
– ntfy_send: Sends notifications through HTTP calls.
– ntfy_done & ntfy_done_with_timing: Wrap processes to notify when completed.
– tags & show_emoji functions: Manage and display supported emoji tags.
- Data & Supporting Assets – This includes:
– Data files (like emoji and tags data in the “data” directory) that support the emoji functionality.
– Installation resources and scripts in “inst” (e.g. emojis.js).
- Documentation & Man Pages – Modules providing user guidance and help (from “man”, README files, and pkgdown configuration).
- Testing Framework – The “tests” directory with testthat files confirming the behavior of notifications, server interactions and more.
- CI/CD Infrastructure – GitHub workflows inside “.github/workflows” (e.g. pkgdown.yaml, rhub.yaml) that automate package checks, builds, and deployment (documentation generation via pkgdown).
- External ntfy Service – The external HTTP server (by default https://ntfy.sh) that the package communicates with. This represents an external system boundary.
- Environment Configuration – Environment files and variables (e.g., environment variable settings in “R/env.R” and instructions to set NTFY_TOPIC, NTFY_AUTH, etc.) which are critical for the proper functioning of the package.

##### Relationships and Interactions
- Client-to-Server Flow: Illustrate how the client (functions in the R package) makes HTTP POST/GET requests to the external notification server.
- Data Flow: Show how emoji and tag data (from the “data” directory) is loaded and then used by functions such as show_emoji() to support auto-completion and enriched notifications.

##### Architectural Patterns and Design Principles
- Modular Design: The clear separation between core logic (R functions), data (emoji/tag resources), and the external service client.
- Separation of Concerns: Distinguish between notification sending logic, data manipulation (emoji handling), and environment configuration.
- Use of External Integrations: Highlight the integration with external HTTP APIs (i.e. ntfy service) and image creation (support for ggplot2 output).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Internal Components"
        EC["Environment Configuration (R/env.R)"]:::internal
        subgraph "Data & Supporting Assets"
            ED["Emoji Data (data/emoji.rda)"]:::data
            TD["Tags Data (data/tags.rda)"]:::data
            IA["Installation Assets (inst/emojis/emojis.js)"]:::data
        end
        CORE["R Package Core Functions (R)"]:::internal
        subgraph "Documentation & Man Pages"
            DOC1["Documentation Files (README.Rmd, README.md)"]:::doc
            DOC2["Pkgdown Config (_pkgdown.yml)"]:::doc
            DOC3["Manual Pages (man)"]:::doc
        end
        TEST["Testing Framework (tests)"]:::test
    end
    CI["CI/CD Infrastructure (.github/workflows)"]:::ci
    EXT["External ntfy Service (ntfy.sh API)"]:::external

    EC -->|"configures"| CORE
    ED -->|"provides"| CORE
    TD -->|"provides"| CORE
    IA -->|"supports"| CORE
    CORE -->|"HTTP calls"| EXT
    TEST -->|"validates"| CORE
    CI -->|"triggers"| TEST
    CI -->|"generates"| DOC1

    click EC "https://github.com/jonocarroll/ntfy/blob/main/R/env.R"
    click CORE "https://github.com/jonocarroll/ntfy/tree/main/R"
    click ED "https://github.com/jonocarroll/ntfy/blob/main/data/emoji.rda"
    click TD "https://github.com/jonocarroll/ntfy/blob/main/data/tags.rda"
    click IA "https://github.com/jonocarroll/ntfy/blob/main/inst/emojis/emojis.js"
    click DOC1 "https://github.com/jonocarroll/ntfy/blob/main/README.Rmd"
    click DOC2 "https://github.com/jonocarroll/ntfy/blob/main/_pkgdown.yml"
    click DOC3 "https://github.com/jonocarroll/ntfy/tree/main/man"
    click TEST "https://github.com/jonocarroll/ntfy/tree/main/tests"
    click CI "https://github.com/jonocarroll/ntfy/tree/main/.github/workflows"

    classDef internal fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef data fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef doc fill:#ABEBC6,stroke:#239B56,stroke-width:2px;
    classDef test fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef ci fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef external fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
```
