# quailyquaily/obsidian-quail architecture

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

- Interactive diagram: https://gitdiagram.com/quailyquaily/obsidian-quail
- Repository: https://github.com/quailyquaily/obsidian-quail

## Overview

##### Main Components
● Plugin Entry Point & Core Logic:
- Main.ts file along with manifest.json, which corresponds to the Obsidian plugin’s entry.
- Integration layer that allows Obsidian to load and run this plugin.
● Action Modules:
- The src/actions folder contains various functions such as aigen, preview, publish, unpublish, etc. Each of these modules encapsulates a specific business logic (e.g., AI summary generation, metadata insertion, etc.) for interacting with Quaily’s endpoints.
● User Interface Components (Modals):
- Under src/modals, there are components for ErrorModal, LoadingModal, MessageModal, PreviewModal, and PublishResultModal. These handle user feedback and status updates.
● Internationalization (i18n):
- The src/i18n directory holds language support files ensuring multilinguistic functionality for users.
● Settings & Configuration:
- The src/setting module manages plugin configuration and user-specific preferences.
● OAuth Integration:
- The src/oauth segment provides code for handling authentication (e.g., token exchange) for secure communication with external services.
● Supporting Modules:
- Directories like src/interface, src/types, src/util, etc., provide shared types and utility functions that underpin the module interactions.

##### Out Relationships and Interactions
● Show the flow starting from the Obsidian client triggering plugin commands (via the command palette).
● Detail how the plugin’s main entry point routes these commands to specific action modules.
● Illustrate the communication between action modules and external components:
- OAuth module’s role in authenticating with external services.
● Indicate how UI feedback is given through various modal dialogs triggered by actions.
● Emphasize the i18n component’s integration across the whole plugin for localization.

##### Architectural Patterns and Principles
● Modular Design: The project is clearly segmented into modules (actions, modals, settings, etc.), which should be represented as discrete yet connected blocks.
● Loose Coupling: Despite separate modules for UI (modals) and business logic (actions and settings), they coordinate via clearly defined interfaces.
● Separation of Concerns: Each folder (actions, i18n, oauth, etc.) serves a distinct role, ensuring clarity in how functionalities are isolated.

##### Specific Technologies
● Node.js with TypeScript (as indicated by files like tsconfig.json, package.json, and global.d.ts).
● Esbuild is used for bundling (esbuild.config.mjs) which is a crucial part of the build and deployment pipeline.
● Linting and style configurations (files like .eslintrc, .editorconfig) denote enforced coding standards.
● GitHub workflows (in .github/workflows) suggest continuous integration and release automation.

##### Essential Elements
● Clear labels for each component (e.g., “Obsidian Plugin Entry”, “Publish Action”, “OAuth Module”, “UI Modals”, “External Quaily API”).

## Diagram (Mermaid)

```mermaid
graph TD
    A["Obsidian Client"]:::clientStyle

    subgraph "Obsidian Plugin Core"
        B["main.ts"]:::coreStyle
        C["manifest.json"]:::coreStyle
    end

    D["Action Modules (src/actions)"]:::actionStyle

    subgraph "UI Components (Modals)"
        E["ErrorModal"]:::uiStyle
        F["LoadingModal"]:::uiStyle
        G["MessageModal"]:::uiStyle
        H["PreviewModal"]:::uiStyle
        I["PublishResultModal"]:::uiStyle
    end

    subgraph "Configuration"
        J["Internationalization (src/i18n)"]:::configStyle
        K["Settings & Configuration (src/setting)"]:::configStyle
        L["OAuth Module (src/oauth)"]:::configStyle
    end

    subgraph "Supporting Modules"
        M1["Interface (index.ts)"]:::supportStyle
        M2["Types (qrcode.d.ts)"]:::supportStyle
        M3["Util (src/util.ts)"]:::supportStyle
    end

    N["External Quaily API"]:::externalStyle

    %% Connections
    A -->|"triggers"| B
    B -->|"routes commands to"| D
    B -->|"loads"| J
    B -->|"loads"| K
    B -->|"loads"| M1
    B --> M2
    B --> M3
    D -->|"publishes to"| N
    D -->|"uses"| L
    D -->|"displays"| E
    D -->|"displays"| F
    D -->|"displays"| G
    D -->|"displays"| H
    D -->|"displays"| I

    %% Click Events
    click B "https://github.com/quailyquaily/obsidian-quail/blob/master/main.ts"
    click C "https://github.com/quailyquaily/obsidian-quail/blob/master/manifest.json"
    click D "https://github.com/quailyquaily/obsidian-quail/tree/master/src/actions"
    click E "https://github.com/quailyquaily/obsidian-quail/blob/master/src/modals/ErrorModal.ts"
    click F "https://github.com/quailyquaily/obsidian-quail/blob/master/src/modals/LoadingModal.ts"
    click G "https://github.com/quailyquaily/obsidian-quail/blob/master/src/modals/MessageModal.ts"
    click H "https://github.com/quailyquaily/obsidian-quail/blob/master/src/modals/PreviewModal.ts"
    click I "https://github.com/quailyquaily/obsidian-quail/blob/master/src/modals/PublishResultModal.ts"
    click J "https://github.com/quailyquaily/obsidian-quail/tree/master/src/i18n"
    click K "https://github.com/quailyquaily/obsidian-quail/blob/master/src/setting/index.ts"
    click L "https://github.com/quailyquaily/obsidian-quail/blob/master/src/oauth/oauth.js"
    click M1 "https://github.com/quailyquaily/obsidian-quail/blob/master/src/interface/index.ts"
    click M2 "https://github.com/quailyquaily/obsidian-quail/blob/master/src/types/qrcode.d.ts"
    click M3 "https://github.com/quailyquaily/obsidian-quail/blob/master/src/util.ts"

    %% Styles
    classDef clientStyle fill:#f9f,stroke:#333,stroke-width:2px;
    classDef coreStyle fill:#ff9,stroke:#333,stroke-width:2px;
    classDef actionStyle fill:#9f9,stroke:#333,stroke-width:2px;
    classDef uiStyle fill:#9ff,stroke:#333,stroke-width:2px;
    classDef configStyle fill:#fc9,stroke:#333,stroke-width:2px;
    classDef supportStyle fill:#ccf,stroke:#333,stroke-width:2px;
    classDef externalStyle fill:#f99,stroke:#333,stroke-width:2px;
```
