# kmzk-dev/disc-post architecture

> Architecture diagram of the GitHub repository kmzk-dev/disc-post, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kmzk-dev/disc-post
- Repository: https://github.com/kmzk-dev/disc-post

## Overview

##### Project type and purpose
- DiscPost is a single-extension full-client Chrome browser extension (Manifest V3).
- Its purpose is to let users send quick messages to Discord channels via Webhook URLs without leaving the browser.

##### File structure
- Top-level files:
- manifest.json (in dist/) – Chrome extension manifest
- popup.html, setting.html – UI entry points
- statics/js/{background.js, popup.js, setting.js} – background service worker and UI scripts
- statics/css/root.css, statics/img – styling and assets
- No server-side code: all logic runs in the browser extension context.
- chrome.storage.local is the persistent datastore.

##### README for additional insights
- Technical stack: Manifest V3, chrome.storage.local.
- UI flow: popup for message input, settings page for Webhook management.
- Network flow: extension → Discord Webhook endpoint (external HTTP POST).

##### Main components
a. Chrome Browser (host environment)
b. Extension Package
– manifest.json
– Popup UI (popup.html + popup.js)
– Settings UI (setting.html + setting.js)
– Background Service Worker (background.js)
– Static assets (CSS, images)
c. Local Data Store
– chrome.storage.local
d. External Service
– Discord Webhook endpoints (HTTPS)

##### Relationships and interactions
- Popup UI reads registered Webhooks from chrome.storage.local.
- User types message and selects Webhook → popup.js sends a message to background.js.
- Background Service Worker receives the payload → reads any additional config from chrome.storage.local → issues HTTPS POST to the selected Discord Webhook URL.
- Settings UI reads/writes webhook entries to chrome.storage.local.
- (Optional) Background worker can send status back to popup.js to show success/failure.

##### Architectural patterns and design principles
- MV*-style separation between UI pages and background logic.
- Single source of truth in chrome.storage.local.
- Event-driven messaging between UI scripts and background service worker.
- Clear separation of concerns:
- Popup UI – transient user input
- Settings UI – configuration management
- Background – network I/O and storage orchestration

##### Relevant technologies
- Google Chrome Extension Manifest V3
- chrome.storage.local API
- Fetch API or XHR for Webhook calls
- HTML/CSS/Vanilla JS for popup and settings

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Chrome Browser Environment"
        subgraph "Extension Package"
            M["Manifest: manifest.json"]:::manifest
            subgraph "UI Pages"
                PU["Popup UI: popup.html"]:::ui
                SU["Settings UI: setting.html"]:::ui
            end
            subgraph "UI Scripts"
                PJS["Popup Script: popup.js"]:::ui
                SJS["Settings Script: setting.js"]:::ui
            end
            BSW["Background SW: background.js"]:::background
            CSS["Stylesheet: root.css"]:::assets
            IMG["Image Assets"]:::assets
            DB["chrome.storage.local"]:::db
        end
    end

    EXT["Discord Webhook Endpoint"]:::external

    %% Relationships
    M --> PU
    M --> SU
    M --> BSW

    PU --> PJS
    SU --> SJS

    PJS -->|send message| BSW
    SJS -->|read/write config| DB
    BSW -->|read/write config| DB
    BSW -->|HTTP POST| EXT
    BSW -->|status update| PJS

    %% Click Events
    click M "https://github.com/kmzk-dev/disc-post/blob/main/dist/manifest.json"
    click PU "https://github.com/kmzk-dev/disc-post/blob/main/dist/popup.html"
    click PJS "https://github.com/kmzk-dev/disc-post/blob/main/dist/statics/js/popup.js"
    click SU "https://github.com/kmzk-dev/disc-post/blob/main/dist/setting.html"
    click SJS "https://github.com/kmzk-dev/disc-post/blob/main/dist/statics/js/setting.js"
    click BSW "https://github.com/kmzk-dev/disc-post/blob/main/dist/statics/js/background.js"
    click CSS "https://github.com/kmzk-dev/disc-post/blob/main/dist/statics/css/root.css"
    click IMG "https://github.com/kmzk-dev/disc-post/tree/main/dist/statics/img/"

    %% Styles
    classDef ui fill:#D0E7FF,stroke:#0366d6,stroke-width:1px
    classDef background fill:#D6F5D6,stroke:#2c662d,stroke-width:1px
    classDef db fill:#FFE2B3,stroke:#a66c00,stroke-width:1px
    classDef external fill:#FFC2C2,stroke:#a52a2a,stroke-width:1px
    classDef manifest fill:#E0E0E0,stroke:#696969,stroke-width:1px
    classDef assets fill:#F0F0F0,stroke:#999999,stroke-width:1px
```
