# tfthacker/obsidian42-brat architecture

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

- Interactive diagram: https://gitdiagram.com/tfthacker/obsidian42-brat
- Repository: https://github.com/tfthacker/obsidian42-brat

## Overview

##### Project type and purpose
- This is an Obsidian plugin (full-stack in the sense of UI + background logic) whose sole purpose is to let beta-testers add GitHub repositories to a list and auto-update those plugins/themes inside Obsidian.

##### File structure
- Top-level config/build files:
- manifest.json – Obsidian plugin metadata (ID, version, main entry)
- biome.json, esbuild.config.mjs, tsconfig.json – build & linting config
- version-bump.mjs, version-github-action.mjs – release automation
- Source code under src/
- src/main.ts – plugin entry point, hooks into Obsidian lifecycle (onload/unload)
- src/settings.ts – defines settings schema & load/save logic
- src/features/ – core capabilities (theme install, plugin commands, GitHub utilities)
- src/ui/ – user-facing components (modals, settings tab, fuzz y search)
- src/utils/ – shared helpers (BratAPI for GitHub calls, networking, logging, notifications, general utility functions)
- Other: styles.css for UI styling; media/ for images; workflows for CI/CD and release.

##### README for additional insights
- Confirms the plugin’s purpose: maintain a list of GitHub repos for Obsidian beta plugins/themes, check for updates, download and reload automatically.

## Diagram (Mermaid)

```mermaid
flowchart TD
    OH["Obsidian Host"]:::obsidian
    PC["Plugin Core"]:::plugin
    OH -->|"load plugin"| PC

    subgraph "Plugin Core"
        entry["Entry & Lifecycle Hooks"]:::plugin
        settings["Settings Schema & Persistence"]:::plugin
    end
    click entry "https://github.com/tfthacker/obsidian42-brat/blob/main/src/main.ts"
    click settings "https://github.com/tfthacker/obsidian42-brat/blob/main/src/settings.ts"
    PC --> entry
    PC --> settings

    entry -->|initialize| UI_LAUNCH["UI Layer"]:::plugin
    entry -->|initialize| FL_LAUNCH["Feature Layer"]:::plugin
    entry -->|initialize| UL_LAUNCH["Utility Layer"]:::plugin

    subgraph "UI Layer"
        APM["Add Plugin Modal"]:::plugin
        ATM["Add Theme Modal"]:::plugin
        VSM["Version Suggestion Modal"]:::plugin
        ST["Settings Tab"]:::plugin
        PCM["Plugin Commands Menu"]:::plugin
        GFS["Generic Fuzzy Search"]:::plugin
        PRM["Promotional/About"]:::plugin
        ICON["Icon Definitions"]:::plugin
    end
    click APM "https://github.com/tfthacker/obsidian42-brat/blob/main/src/ui/AddNewPluginModal.ts"
    click ATM "https://github.com/tfthacker/obsidian42-brat/blob/main/src/ui/AddNewTheme.ts"
    click VSM "https://github.com/tfthacker/obsidian42-brat/blob/main/src/ui/VersionSuggestModal.ts"
    click ST "https://github.com/tfthacker/obsidian42-brat/blob/main/src/ui/SettingsTab.ts"
    click PCM "https://github.com/tfthacker/obsidian42-brat/blob/main/src/ui/PluginCommands.ts"
    click GFS "https://github.com/tfthacker/obsidian42-brat/blob/main/src/ui/GenericFuzzySuggester.ts"
    click PRM "https://github.com/tfthacker/obsidian42-brat/blob/main/src/ui/Promotional.ts"
    click ICON "https://github.com/tfthacker/obsidian42-brat/blob/main/src/ui/icons.ts"
    UI_LAUNCH --> APM
    UI_LAUNCH --> ATM
    UI_LAUNCH --> VSM
    UI_LAUNCH --> ST
    UI_LAUNCH --> PCM
    UI_LAUNCH --> GFS
    UI_LAUNCH --> PRM
    UI_LAUNCH --> ICON

    subgraph "Feature Layer"
        BPM["Beta Plugins Management"]:::plugin
        TM["Themes Management"]:::plugin
        GHU["GitHub Utilities"]:::plugin
    end
    click BPM "https://github.com/tfthacker/obsidian42-brat/blob/main/src/features/BetaPlugins.ts"
    click TM "https://github.com/tfthacker/obsidian42-brat/blob/main/src/features/themes.ts"
    click GHU "https://github.com/tfthacker/obsidian42-brat/blob/main/src/features/githubUtils.ts"
    APM -->|"user action"| BPM
    ATM -->|"user action"| TM
    VSM -->|"user action"| BPM
    PCM -->|"command"| BPM
    PCM -->|"command"| TM

    subgraph "Utility Layer"
        APIW["GitHub API Wrapper"]:::plugin
        APIE["GitHub API Error Handling"]:::plugin
        IC["Internet Connection Checker"]:::plugin
        LOG["Logging Utilities"]:::plugin
        NOTIF["User Notifications"]:::plugin
        GHUTIL["General Helpers"]:::plugin
    end
    click APIW "https://github.com/tfthacker/obsidian42-brat/blob/main/src/utils/BratAPI.ts"
    click APIE "https://github.com/tfthacker/obsidian42-brat/blob/main/src/utils/GitHubAPIErrors.ts"
    click IC "https://github.com/tfthacker/obsidian42-brat/blob/main/src/utils/internetconnection.ts"
    click LOG "https://github.com/tfthacker/obsidian42-brat/blob/main/src/utils/logging.ts"
    click NOTIF "https://github.com/tfthacker/obsidian42-brat/blob/main/src/utils/notifications.ts"
    click GHUTIL "https://github.com/tfthacker/obsidian42-brat/blob/main/src/utils/utils.ts"
    BPM -->|"fetch release"| GHU
    TM -->|"fetch release"| GHU
    GHU -->|"uses"| APIW
    GHU -->|"handles errors"| APIE
    GHU -->|"checks connection"| IC
    GHU -->|"logs"| LOG
    GHU -->|"notify"| NOTIF
    GHU -->|"helpers"| GHUTIL

    subgraph "External Services & Resources"
        GHAPI((GitHub API)):::external
        FSYS[(Local File System)]:::external
    end
    click GHAPI "https://github.com/tfthacker/obsidian42-brat/blob/main/src/utils/BratAPI.ts"
    BPM -->|"request release"| GHAPI
    TM -->|"request release"| GHAPI
    GHU -->|"Release asset JSON"| GHAPI
    GHU -->|"Plugin zip blob"| FSYS
    GHU -->|"reload plugin"| OH

    subgraph "Build & CI Pipeline"
        TS["TypeScript Compiler"]:::pipeline
        ESBUILD["esbuild"]:::pipeline
        BIOME["biome"]:::pipeline
        RELEASEWF[".github/workflows/release.yml"]:::pipeline
        VBN["version-bump.mjs"]:::pipeline
        VGH["version-github-action.mjs"]:::pipeline
        TS --> ESBUILD
        ESBUILD --> BIOME
        BIOME --> RELEASEWF
        RELEASEWF --> VBN
        RELEASEWF --> VGH
    end

    classDef obsidian fill:#ADD8E6,stroke:#000
    classDef plugin fill:#90EE90,stroke:#000
    classDef external fill:#FFA500,stroke:#000
    classDef pipeline fill:#D3D3D3,stroke:#000
```
