# oasisvee/my-plugins architecture

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

- Interactive diagram: https://gitdiagram.com/oasisvee/my-plugins
- Repository: https://github.com/oasisvee/my-plugins

## Overview

##### Project Type and Purpose
- This is a multi‑module Gradle project targeting the Android‑based Aliucord client. It contains two independent Aliucord plugins:
a. Sed – a port of the original Sed command‑line‑style message replacement plugin, enhanced for case‑insensitive matching.
b. CatUITH – a fork of UITH focused on Catbox (and other hosts) upload functionality, with custom settings, JSON config, theme toggle, and album mode support.

##### File Structure Analysis
- Root Level
- settings.gradle.kts, build.gradle.kts, gradle/ wrapper, gradlew scripts – define a multi‑project Gradle build.
- .github/workflows/build.yml – CI build pipeline.
- Subprojects
- CatUITH/ – Kotlin‑based Aliucord plugin module.
– src/main/AndroidManifest.xml (plugin manifest)
– com.serinova.plugins.UITH.kt (core plugin entry point)
– Settings.kt, Utils.kt – settings UI and helper functions
- Sed/ – Java‑based Aliucord plugin module.
– src/main/AndroidManifest.xml
– Plugin.java (entry point), Command.java (command implementation), ParserState.java (state machine for s///), Settings.java

##### Key Architectural Insights from README
- Both modules adhere to the Aliucord plugin API: each exposes a manifest, an entry‑point class that registers commands or hooks, and a settings screen.
- CatUITH integrates with external HTTP APIs (Catbox and other hosts) for file uploading; it uses JSON‑based plugin configuration.
- Sed plugin focuses purely on text transformation within the host app, no external services.

a. Main Components
1. Android OS / Runtime – hosts the Aliucord client APK.
2. Aliucord Host App – a modified Discord client that loads plugins. Contains:
– Plugin Manager (discovery, lifecycle)
– UI Shell (message input/output areas)
3. Plugin Modules – two separate modules:
- Sed Plugin
– EntryPoint (Plugin.java)
– Command Processor (Command.java)
– ParserState
– Settings UI
- CatUITH Plugin
– EntryPoint (UITH.kt)
– Upload Manager (Utils.kt)
– Settings UI (Settings.kt)
– JSON Config Handler
4. External Services (CatUITH only)
– Catbox API (upload endpoint)
– Other hosts (as preserved from UITH)
5. CI/CD Pipeline
– GitHub Actions (build.yml)

b. Relationships & Interactions
- Android OS loads Aliucord App → App initializes Plugin Manager → Discovers both plugins via their manifests.
- On user action:
- Sed: user types “/sed ...” → Sed Plugin’s Command Processor intercepts → ParserState transforms message → plugin returns edited text to Aliucord UI.
- CatUITH: user invokes “/cuith” commands → CatUITH’s Upload Manager (Utils.kt) reads JSON config → performs HTTP POST to Catbox → returns URL to UI.
- Settings UI in each plugin writes to local storage (SharedPreferences or JSON) and feeds configuration back to the plugin at runtime.

c. Architectural Patterns & Principles
- Plugin Architecture / Inversion of Control: host app defines interfaces/hooks, plugins implement them.
- Single Responsibility: separate entry‑point, command/parser logic, settings UI, and utilities.
- Modularity: two independent Gradle subprojects, share only the Aliucord API.
- External Integration Layer (CatUITH) encapsulates HTTP calls and JSON handling.

d. Key Technologies & Frameworks
- Kotlin (CatUITH), Java (Sed)
- Android SDK (manifests, UI)
- Aliucord Plugin API
- Gradle Kotlin DSL (build scripts)
- GitHub Actions for CI
- JSON for plugin configuration
- HTTP libraries (OkHttp or similar) for uploads

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Title
    title["Aliucord Plugin Architecture – Sed & CatUITH"]

    %% Layers
    subgraph "Android Environment"
        direction TB
        OS["Android OS / Runtime"]:::host
    end

    subgraph "Aliucord Host App"
        direction TB
        APP["Aliucord Host App"]:::host
        PM["Plugin Manager"]:::logic
        UI["UI Shell"]:::ui
    end

    subgraph "Plugins"
        direction TB

        subgraph "Sed Plugin" 
            direction TB
            SED_MANIFEST["AndroidManifest.xml"]:::config
            SED_ENTRY["EntryPoint (Plugin.java)"]:::logic
            SED_CMD["Command Processor (Command.java)"]:::logic
            SED_PSTATE["ParserState"]:::logic
            SED_SETTINGS["Settings UI"]:::ui
        end

        subgraph "CatUITH Plugin"
            direction TB
            CAT_MANIFEST["AndroidManifest.xml"]:::config
            CAT_ENTRY["EntryPoint (UITH.kt)"]:::logic
            CAT_UTILS["Upload Manager & JSON Config"]:::logic
            CAT_SETTINGS["Settings UI"]:::ui
        end
    end

    subgraph "External Services"
        direction TB
        CB["Catbox API"]:::external
        OH["Other Hosts"]:::external
    end

    subgraph "CI/CD Pipeline"
        direction TB
        GHCI["GitHub Actions"]:::ci
    end

    %% Connections
    OS -->|"hosts"| APP
    APP -->|"initialize"| PM
    PM -->|"discover hooks"| SED_MANIFEST
    PM -->|"discover hooks"| CAT_MANIFEST

    UI -->|"user types /sed"| SED_ENTRY
    SED_ENTRY -->|"register hook & execute"| SED_CMD
    SED_CMD -->|"use state machine"| SED_PSTATE
    SED_PSTATE -->|"return edited text"| UI

    UI -->|"user types /cuith"| CAT_ENTRY
    CAT_ENTRY -->|"loads config & call upload"| CAT_UTILS
    CAT_UTILS -->|"HTTP POST"| CB
    CAT_UTILS -->|"HTTP POST"| OH
    CB -->|"response URL"| CAT_ENTRY
    OH -->|"response URL"| CAT_ENTRY
    CAT_ENTRY -->|"return URL"| UI

    SED_SETTINGS -->|"writes prefs"| SED_ENTRY
    CAT_SETTINGS -->|"writes prefs/json"| CAT_ENTRY

    GHCI -->|"builds modules"| SED_ENTRY
    GHCI -->|"builds modules"| CAT_ENTRY

    %% Click Events
    click GHCI "https://github.com/oasisvee/my-plugins/blob/main/.github/workflows/build.yml"
    click SED_MANIFEST "https://github.com/oasisvee/my-plugins/blob/main/Sed/src/main/AndroidManifest.xml"
    click SED_ENTRY "https://github.com/oasisvee/my-plugins/blob/main/Sed/src/main/java/grzesiek11/aliucordplugins/sed/Plugin.java"
    click SED_CMD "https://github.com/oasisvee/my-plugins/blob/main/Sed/src/main/java/grzesiek11/aliucordplugins/sed/Command.java"
    click SED_PSTATE "https://github.com/oasisvee/my-plugins/blob/main/Sed/src/main/java/grzesiek11/aliucordplugins/sed/ParserState.java"
    click SED_SETTINGS "https://github.com/oasisvee/my-plugins/blob/main/Sed/src/main/java/grzesiek11/aliucordplugins/sed/Settings.java"
    click CAT_MANIFEST "https://github.com/oasisvee/my-plugins/blob/main/CatUITH/src/main/AndroidManifest.xml"
    click CAT_ENTRY "https://github.com/oasisvee/my-plugins/blob/main/CatUITH/src/main/java/com/serinova/plugins/UITH.kt"
    click CAT_SETTINGS "https://github.com/oasisvee/my-plugins/blob/main/CatUITH/src/main/java/com/serinova/plugins/Settings.kt"
    click CAT_UTILS "https://github.com/oasisvee/my-plugins/blob/main/CatUITH/src/main/java/com/serinova/plugins/Utils.kt"

    %% Styles
    classDef host fill:#f2f2f2,stroke:#333,stroke-width:2px
    classDef logic fill:#e6f7ff,stroke:#1f78b4,stroke-width:2px
    classDef ui fill:#fff0b3,stroke:#ffb400,stroke-width:2px
    classDef config fill:#e8e8e8,stroke:#555,stroke-width:2px,stroke-dasharray: 5 5
    classDef external fill:#fde2e2,stroke:#d62828,stroke-width:2px
    classDef ci fill:#e2f0cb,stroke:#629460,stroke-width:2px
```
