# ebullient/obsidian-show-whitespace-cm6 architecture

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

- Interactive diagram: https://gitdiagram.com/ebullient/obsidian-show-whitespace-cm6
- Repository: https://github.com/ebullient/obsidian-show-whitespace-cm6

## Overview

##### Project Type and Purpose
- Type: Obsidian Community Plugin (Electron‐based, front‐end only)
- Purpose: Highlight leading/trailing whitespace in Markdown editor and live preview via CodeMirror 6 extensions, configurable via a settings tab.

##### File Structure
- Top‐level:
- manifest.json, manifest‐beta.json – plugin metadata
- src/main.ts – plugin entry point
- src/whitespace-Plugin.ts – registers CodeMirror 6 extensions
- src/whitespace-SettingsTab.ts – plugin settings UI
- src/styles.scss – default CSS styling
- src/i18n – internationalization module
- esbuild.config.mjs / biome.json / tsconfig.json – build & lint configs
- Patterns:
- Plugin API → CodeMirror extension registration
- Separate settings UI component
- Build step bundles TS + SCSS into the final plugin.js & style.css

##### Pull Architecture Insights from README
- Core components: whitespace visualization engine, settings interface, CSS injection
- Build & release via GitHub workflows (build.yml, release.yml)
- No external services or databases; settings persist via Obsidian’s plugin API

##### Main Components & Relationships
A. Developer Environment
– Editor & CLI run esbuild (esbuild.config.mjs, biome.json)
– Outputs plugin bundle & CSS
B. Obsidian Host (Electron App)
– Plugin Loader reads manifest.json & plugin bundle
– Storage API persists user settings
– Renders editor area via CodeMirror 6
– Renders Live Preview pane
C. Show-Whitespace Plugin
1. Entry (main.ts)
- onload(): instantiate SettingsTab
- register whitespace Plugin extension
2. whitespace-Plugin.ts
- Defines CodeMirror decorations for leading/trailing whitespace
- Reads plugin settings from Obsidian’s Data API
3. whitespace-SettingsTab.ts
- UI in Obsidian’s Settings → Community Plugins → Show Whitespace
- Provides toggles (leading/trailing/middle, marker outlines)
4. styles.scss → compiled style.css
- CSS variables (--line-end, --line-break)
- Default glyph styles for whitespace markers
5. i18n module (en.ts, index.ts)
- Loads localized labels for settings UI

– Developer Machine
– Build Tools (esbuild, biome)
– Obsidian Host
– CodeMirror 6 Engine
– Show-Whitespace Plugin
· Plugin Entry
· Plugin Runtime (whitespace-Plugin, SettingsTab, i18n)
· CSS Injector (style.css)
– Persistent Settings Store
– Dev → Build Tool: TS/SCSS → bundle.js + style.css
– Build Output → Obsidian Plugin Loader
– Plugin Loader → Plugin Runtime
– Plugin Runtime → CodeMirror 6 (register extensions)
– Plugin Runtime → CSS Injector → Editor DOM
– SettingsTab ↔ Persistent Store (read/write settings)
c. Architectural Patterns
– Plugin-based extension of host application
– Separation of concerns: core functionality (decoration) vs. configuration UI
– Build pipeline compiles TS + SCSS to browser-compatible assets
d. Key Technologies
– TypeScript, SCSS
– CodeMirror 6 Extension API
– Obsidian Plugin API (onload, settings persistence)
– esbuild (bundler), biome (formatter/linter)
– GitHub Actions for CI/CD

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Developer Machine"
        subgraph "Build Tools"
            ESBUILD["esbuild.config.mjs"]:::build
            BIOME["biome.json"]:::build
            TSCONFIG["tsconfig.json"]:::build
        end
        DEV_SRCS["TypeScript & SCSS Source"]:::build
        ESBUILD & BIOME & TSCONFIG & DEV_SRCS --> BUNDLE["bundle.js & style.css"]:::build
    end

    subgraph "CI/CD Workflows"
        BUILDYML[".github/workflows/build.yml"]:::build
        RELEASEYML[".github/workflows/release.yml"]:::build
    end

    subgraph "Obsidian Host"
        HOST["Obsidian Host (Electron)"]:::host
        META1["manifest.json"]:::host
        META2["manifest-beta.json"]:::host
        HOST --> META1
        HOST --> META2
        META1 & META2 & BUNDLE --> PLUGIN_LOADER["Plugin Loader"]:::host
    end

    subgraph "Show-Whitespace Plugin"
        ENTRY["main.ts (Plugin Entry)"]:::plugin
        PLUGIN_MOD["whitespace-Plugin.ts"]:::plugin
        SETTINGS["whitespace-SettingsTab.ts"]:::plugin
        STYLES["styles.scss (CSS Injector)"]:::plugin
        I18NIDX["i18n/index.ts"]:::plugin
        I18NEN["i18n/en.ts"]:::plugin
        TYPES["@types/settings.d.ts"]:::plugin
    end

    PLUGIN_LOADER --> ENTRY
    ENTRY --> PLUGIN_MOD
    ENTRY --> SETTINGS
    ENTRY --> STYLES
    ENTRY --> I18NIDX
    I18NIDX --> I18NEN
    SETTINGS -->|"reads/writes"| STORE["Persistent Settings Store"]:::store
    PLUGIN_MOD --> CODEMIRROR["CodeMirror 6 Engine"]:::engine
    STYLES --> EDITOR_DOM["Editor DOM"]:::host

    click ESBUILD "https://github.com/ebullient/obsidian-show-whitespace-cm6/blob/main/esbuild.config.mjs"
    click BIOME "https://github.com/ebullient/obsidian-show-whitespace-cm6/blob/main/biome.json"
    click TSCONFIG "https://github.com/ebullient/obsidian-show-whitespace-cm6/blob/main/tsconfig.json"
    click BUNDLE "https://github.com/ebullient/obsidian-show-whitespace-cm6/blob/main/src/styles.scss"
    click META1 "https://github.com/ebullient/obsidian-show-whitespace-cm6/blob/main/manifest.json"
    click META2 "https://github.com/ebullient/obsidian-show-whitespace-cm6/blob/main/manifest-beta.json"
    click ENTRY "https://github.com/ebullient/obsidian-show-whitespace-cm6/blob/main/src/main.ts"
    click PLUGIN_MOD "https://github.com/ebullient/obsidian-show-whitespace-cm6/blob/main/src/whitespace-Plugin.ts"
    click SETTINGS "https://github.com/ebullient/obsidian-show-whitespace-cm6/blob/main/src/whitespace-SettingsTab.ts"
    click STYLES "https://github.com/ebullient/obsidian-show-whitespace-cm6/blob/main/src/styles.scss"
    click I18NIDX "https://github.com/ebullient/obsidian-show-whitespace-cm6/blob/main/src/i18n/index.ts"
    click I18NEN "https://github.com/ebullient/obsidian-show-whitespace-cm6/blob/main/src/i18n/en.ts"
    click TYPES "https://github.com/ebullient/obsidian-show-whitespace-cm6/blob/main/src/@types/settings.d.ts"
    click BUILDYML "https://github.com/ebullient/obsidian-show-whitespace-cm6/blob/main/.github/workflows/build.yml"
    click RELEASEYML "https://github.com/ebullient/obsidian-show-whitespace-cm6/blob/main/.github/workflows/release.yml"

    classDef build fill:#aedff7,stroke:#000
    classDef plugin fill:#c2f7a4,stroke:#000
    classDef host fill:#f7d6a4,stroke:#000
    classDef engine fill:#f0e68c,stroke:#000
    classDef store fill:#cccccc,stroke:#000
```
