# mikevetkin/obsidian-tengwar architecture

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

- Interactive diagram: https://gitdiagram.com/mikevetkin/obsidian-tengwar
- Repository: https://github.com/mikevetkin/obsidian-tengwar

## Overview

#### Purpose and Host Integration
This is an Obsidian plugin that renders fenced Markdown code blocks containing Tengwar text. It supports configurable block keywords, per-block font variants, and ISO 8859-1 or ConScript Unicode Registry (CSUR) encodings. The plugin entry point is `main.ts`; Obsidian loads it according to `manifest.json`.

#### Plugin Lifecycle and Rendering Registration
`main.ts` owns plugin startup, settings loading, registration of the settings tab, and registration/refresh of Tengwar Markdown code-block processors. Processor registration is separated so changes to settings can replace active language handlers without restarting the app:
- `main.ts`
- `feature/tengwar/domain/lib/refresh-processors.ts`
- `feature/tengwar/domain/lib/teng-processor.ts`

#### Tengwar Code-Block Processing
The rendering pipeline receives code-block source text and its declared language identifier (for example, `teng` or `teng-artano`). It identifies the base keyword and optional font suffix, resolves rendering behavior, preserves intended line breaks, and emits rendered Tengwar content into Obsidian’s preview DOM. This boundary is preview rendering; editing-mode rendering is explicitly not the primary supported path.
- `feature/tengwar/domain/lib/teng-processor.ts`
- `feature/tengwar/domain/lib/get-text-with-breaks.ts`
- `feature/tengwar/domain/lib/get-tengwar-font-class.ts`

#### Encoding Resolution
The domain model supports two character representations: ASCII/ISO 8859-1-oriented Tengwar text and CSUR Unicode text. Encoding selection is centralized rather than embedded in UI or processor registration, allowing rendering to select the appropriate font/class treatment from detected or configured text characteristics.
- `feature/tengwar/domain/entity/encoding.ts`
- `feature/tengwar/domain/lib/get-encoding.ts`
- `feature/tengwar/domain/entity/csur-tengwar.ts`

#### Language/Keyword Routing
Configured processor languages determine which fenced-block identifiers Obsidian recognizes. The system builds a list from the user-selected primary keyword plus supported font suffix variants, then registers processors for that list. This lets users rename the base keyword (such as from `teng` to `elfish`) while retaining per-font syntax.
- `feature/tengwar/domain/entity/processor-languages.ts`
- `feature/tengwar/domain/lib/make-processor-languages-list.ts`
- `feature/tengwar/domain/lib/refresh-processors.ts`

#### Settings Domain and UI
Settings are modeled as a domain entity with defaults and font option entities, then exposed through an Obsidian settings tab. Settings govern the default font and processor keyword; updates feed back into processor refresh/registration.
- `feature/settings/domain/entity/plugin-settings.ts`
- `feature/settings/domain/entity/default-plugin-settings.ts`
- `feature/settings/ui/settings-tab.ts`

#### Font Taxonomy and Styling Boundary
Font choices are represented as separate entities for ASCII, CSUR, and Tengwar font definitions. Runtime code maps a chosen/inferred font to CSS classes; stylesheet assets provide the actual visual rendering. This keeps font selection logic distinct from DOM styling and browser font rendering.
- `feature/settings/domain/entity/ascii-font.ts`
- `feature/settings/domain/entity/csur-font.ts`
- `feature/settings/domain/entity/tengwar-font.ts`
- `styles.css`

#### Runtime and Delivery
The plugin is TypeScript compiled/bundled with esbuild for the Obsidian desktop/mobile runtime. It depends on Obsidian’s plugin API for lifecycle, settings persistence, and Markdown post-processing; no backend or external runtime service is indicated. Release automation publishes versioned plugin artifacts through GitHub Actions.
- `esbuild.config.mjs`
- `package.json`
- `.github/workflows/release.yml`

Main entry points: [`main.ts`](https://github.com/mikevetkin/obsidian-tengwar/blob/main/main.ts) (Plugin entry point), [`feature/tengwar/domain/lib/refresh-processors.ts`](https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/lib/refresh-processors.ts) (Processor refresh), [`feature/tengwar/domain/lib/teng-processor.ts`](https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/lib/teng-processor.ts) (Tengwar processor), [`feature/tengwar/domain/lib/get-tengwar-font-class.ts`](https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/lib/get-tengwar-font-class.ts) (Font class resolver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Obsidian host"]
  node_manifest["Plugin manifest<br/>Obsidian metadata<br/>[manifest.json]"]
  node_obsidian{{"Obsidian API<br/>host API"}}
end

subgraph group_plugin["Plugin runtime"]
  node_main["Plugin entry point<br/>plugin lifecycle<br/>[main.ts]"]
end

subgraph group_tengwar["Tengwar rendering"]
  node_refresh["Processor refresh<br/>registration coordinator"]
  node_languages["Processor languages<br/>keyword routing"]
  node_language_model["Processor language model<br/>domain entity"]
  node_processor["Tengwar processor<br/>Markdown block renderer<br/>[teng-processor.ts]"]
  node_text_breaks["Line break preservation<br/>text preparation"]
  node_font_class["Font class resolver<br/>rendering policy"]
  node_encoding["Encoding resolver<br/>encoding policy<br/>[get-encoding.ts]"]
  node_encoding_model["Encoding and CSUR model<br/>domain entities<br/>[encoding.ts]"]
end

subgraph group_settings["Settings and fonts"]
  node_settings_tab["Settings tab<br/>Obsidian UI<br/>[settings-tab.ts]"]
  node_settings_model["Plugin settings<br/>settings domain<br/>[plugin-settings.ts]"]
  node_font_models["Font taxonomy<br/>font entities<br/>[tengwar-font.ts]"]
  node_styles["Tengwar styles<br/>CSS assets<br/>[styles.css]"]
end

subgraph group_delivery["Build and release"]
  node_build["esbuild bundle<br/>TypeScript build<br/>[esbuild.config.mjs]"]
  node_package["Package definition<br/>npm metadata<br/>[package.json]"]
  node_release["Release workflow<br/>GitHub Actions<br/>[release.yml]"]
end

node_manifest -->|"loads"| node_main
node_obsidian -->|"hosts"| node_main
node_main -->|"loads and saves"| node_settings_model
node_main -->|"registers"| node_settings_tab
node_main -->|"refreshes"| node_refresh
node_settings_tab -->|"edits"| node_settings_model
node_settings_tab -->|"on update"| node_refresh
node_refresh -->|"gets handlers for"| node_languages
node_languages -->|"uses"| node_language_model
node_refresh -->|"registers processors"| node_obsidian
node_refresh -->|"installs"| node_processor
node_processor -->|"preserves"| node_text_breaks
node_processor -->|"resolves"| node_encoding
node_processor -->|"applies"| node_font_class
node_encoding -->|"uses"| node_encoding_model
node_font_class -->|"selects from"| node_font_models
node_font_class -->|"emits classes for"| node_styles
node_package -->|"configures"| node_build
node_build -->|"bundles"| node_main
node_release -->|"versions and publishes"| node_package

click node_manifest "https://github.com/mikevetkin/obsidian-tengwar/blob/main/manifest.json"
click node_main "https://github.com/mikevetkin/obsidian-tengwar/blob/main/main.ts"
click node_refresh "https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/lib/refresh-processors.ts"
click node_languages "https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/lib/make-processor-languages-list.ts"
click node_language_model "https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/entity/processor-languages.ts"
click node_processor "https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/lib/teng-processor.ts"
click node_text_breaks "https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/lib/get-text-with-breaks.ts"
click node_font_class "https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/lib/get-tengwar-font-class.ts"
click node_encoding "https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/lib/get-encoding.ts"
click node_encoding_model "https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/entity/encoding.ts"
click node_settings_tab "https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/settings/ui/settings-tab.ts"
click node_settings_model "https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/settings/domain/entity/plugin-settings.ts"
click node_font_models "https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/settings/domain/entity/tengwar-font.ts"
click node_styles "https://github.com/mikevetkin/obsidian-tengwar/blob/main/styles.css"
click node_build "https://github.com/mikevetkin/obsidian-tengwar/blob/main/esbuild.config.mjs"
click node_package "https://github.com/mikevetkin/obsidian-tengwar/blob/main/package.json"
click node_release "https://github.com/mikevetkin/obsidian-tengwar/blob/main/.github/workflows/release.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_manifest,node_obsidian toneBlue
class node_main toneAmber
class node_refresh,node_languages,node_language_model,node_processor,node_text_breaks,node_font_class,node_encoding,node_encoding_model toneMint
class node_settings_tab,node_settings_model,node_font_models,node_styles toneRose
class node_build,node_package,node_release toneIndigo
```

## Components

### Obsidian host

- [Plugin manifest](https://github.com/mikevetkin/obsidian-tengwar/blob/main/manifest.json): Obsidian metadata · `manifest.json`
- **Obsidian API**: host API · Provides lifecycle, persistence, settings UI, and Markdown processors.

### Plugin runtime

- [Plugin entry point](https://github.com/mikevetkin/obsidian-tengwar/blob/main/main.ts): plugin lifecycle · Loads settings, registers the tab, and refreshes processors. · `main.ts`

### Tengwar rendering

- [Processor refresh](https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/lib/refresh-processors.ts): registration coordinator · Replaces active language handlers when settings change. · `feature/tengwar/domain/lib/refresh-processors.ts`
- [Processor languages](https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/lib/make-processor-languages-list.ts): keyword routing · Builds base keyword and per-font language variants. · `feature/tengwar/domain/lib/make-processor-languages-list.ts`
- [Processor language model](https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/entity/processor-languages.ts): domain entity · `feature/tengwar/domain/entity/processor-languages.ts`
- [Tengwar processor](https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/lib/teng-processor.ts): Markdown block renderer · Processes preview-mode fenced Tengwar blocks. · `feature/tengwar/domain/lib/teng-processor.ts`
- [Line break preservation](https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/lib/get-text-with-breaks.ts): text preparation · `feature/tengwar/domain/lib/get-text-with-breaks.ts`
- [Font class resolver](https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/lib/get-tengwar-font-class.ts): rendering policy · Maps selected encoding and font to DOM CSS classes. · `feature/tengwar/domain/lib/get-tengwar-font-class.ts`
- [Encoding resolver](https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/lib/get-encoding.ts): encoding policy · Selects ISO 8859-1-oriented or CSUR treatment. · `feature/tengwar/domain/lib/get-encoding.ts`
- [Encoding and CSUR model](https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/tengwar/domain/entity/encoding.ts): domain entities · `feature/tengwar/domain/entity/encoding.ts`

### Settings and fonts

- [Settings tab](https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/settings/ui/settings-tab.ts): Obsidian UI · Edits the default font and processor keyword. · `feature/settings/ui/settings-tab.ts`
- [Plugin settings](https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/settings/domain/entity/plugin-settings.ts): settings domain · Defines persisted settings and defaults. · `feature/settings/domain/entity/plugin-settings.ts`
- [Font taxonomy](https://github.com/mikevetkin/obsidian-tengwar/blob/main/feature/settings/domain/entity/tengwar-font.ts): font entities · Defines ASCII, CSUR, and Tengwar font choices. · `feature/settings/domain/entity/tengwar-font.ts`
- [Tengwar styles](https://github.com/mikevetkin/obsidian-tengwar/blob/main/styles.css): CSS assets · Supplies font classes and visual rendering. · `styles.css`

### Build and release

- [esbuild bundle](https://github.com/mikevetkin/obsidian-tengwar/blob/main/esbuild.config.mjs): TypeScript build · Bundles the plugin for Obsidian desktop and mobile. · `esbuild.config.mjs`
- [Package definition](https://github.com/mikevetkin/obsidian-tengwar/blob/main/package.json): npm metadata · `package.json`
- [Release workflow](https://github.com/mikevetkin/obsidian-tengwar/blob/main/.github/workflows/release.yml): GitHub Actions · Publishes versioned plugin artifacts. · `.github/workflows/release.yml`

## Connections

- Plugin manifest → Plugin entry point: loads
- Obsidian API → Plugin entry point: hosts
- Plugin entry point → Plugin settings: loads and saves
- Plugin entry point → Settings tab: registers
- Plugin entry point → Processor refresh: refreshes
- Settings tab → Plugin settings: edits
- Settings tab → Processor refresh: on update
- Processor refresh → Processor languages: gets handlers for
- Processor languages → Processor language model: uses
- Processor refresh → Obsidian API: registers processors
- Processor refresh → Tengwar processor: installs
- Tengwar processor → Line break preservation: preserves
- Tengwar processor → Encoding resolver: resolves
- Tengwar processor → Font class resolver: applies
- Encoding resolver → Encoding and CSUR model: uses
- Font class resolver → Font taxonomy: selects from
- Font class resolver → Tengwar styles: emits classes for
- Package definition → esbuild bundle: configures
- esbuild bundle → Plugin entry point: bundles
- Release workflow → Package definition: versions and publishes
