# iosonntag/obsidian-plugin-treefocus architecture

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

- Interactive diagram: https://gitdiagram.com/iosonntag/obsidian-plugin-treefocus
- Repository: https://github.com/iosonntag/obsidian-plugin-treefocus

## Overview

TreeFocus is an Obsidian plugin that assigns each file-explorer item a focus mode, then applies a selected visual preset. The main workflow starts with Obsidian lifecycle and file events, continues through refresh and mode evaluation, and ends by tagging explorer elements for styling. Users configure rules and presets in settings or set per-item overrides from the context menu. The README documents these capabilities; unsampled implementation details are represented only where the tree supports a path, and edges are limited to shown calls or documented behavior.

Main entry points: [`src/core/tree-focus.ts`](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/core/tree-focus.ts) (Refresh coordinator), [`src/views/settings-view.ts`](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/views/settings-view.ts) (Settings editor), [`src/services/mode-evaluation-service.ts`](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/services/mode-evaluation-service.ts) (Mode evaluation), [`src/core/plugin-settings.ts`](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/core/plugin-settings.ts) (Plugin settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Plugin entry"]
  node_plugin["Plugin events<br/>[main.ts]"]
end

subgraph group_focus["Focus workflow"]
  node_treefocus["Refresh coordinator<br/>[tree-focus.ts]"]
  node_explorer["Explorer traversal"]
  node_evaluation["Mode evaluation"]
  node_render["Element styling<br/>[css-tool.ts]"]
end

subgraph group_configuration["Settings and rules"]
  node_settingsview["Settings editor<br/>[settings-view.ts]"]
  node_settingstab["Settings tab UI"]
  node_settings["Plugin settings<br/>[plugin-settings.ts]"]
  node_store[("Settings persistence")]
  node_initial["Default settings"]
  node_rules["Rule matching<br/>[rules-helper.ts]"]
  node_ruletypes["Rule definitions<br/>[matching-rules.ts]"]
  node_modes["Focus modes<br/>[general.ts]"]
end

subgraph group_support["Shared utilities"]
  node_logger["Logging<br/>[logger.ts]"]
  node_errors["Plugin errors<br/>[error-helper.ts]"]
  node_strings["Error details<br/>[plugin-strings.ts]"]
  node_info["Plugin metadata<br/>[plugin-info.ts]"]
end

node_obsidian(("Obsidian"))

node_obsidian -->|"fires lifecycle events"| node_plugin
node_plugin -->|"initializes and dispatches"| node_treefocus
node_plugin -->|"registers settings tab"| node_settingsview
node_treefocus -->|"initializes with defaults"| node_store
node_treefocus -->|"supplies defaults"| node_initial
node_treefocus -->|"creates settings view"| node_settingsview
node_treefocus -->|"traverses items"| node_explorer
node_treefocus -->|"evaluates each item"| node_evaluation
node_treefocus -->|"applies mode attributes"| node_render
node_treefocus -->|"reads overrides and preset"| node_settings
node_settingsview -->|"extends settings UI"| node_settingstab
node_settingsview -->|"updates rules and presets"| node_settings
node_treefocus -->|"writes item overrides"| node_settings
node_evaluation -->|"reads overrides and rules"| node_settings
node_evaluation -->|"validates and matches"| node_rules
node_rules -->|"uses rule shape"| node_ruletypes
node_evaluation -->|"returns focus mode"| node_modes
node_settingsview -->|"edits matching rules"| node_ruletypes
node_settingsview -->|"edits focus modes"| node_modes
node_treefocus -->|"logs refresh activity"| node_logger
node_errors -->|"appends bug details"| node_strings
node_errors -->|"logs appendix failure"| node_logger
node_strings -->|"reads plugin metadata"| node_info
node_info -->|"uses error helper"| node_errors

click node_plugin "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/main.ts"
click node_treefocus "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/core/tree-focus.ts"
click node_explorer "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/util/file-explorer-helper.ts"
click node_evaluation "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/services/mode-evaluation-service.ts"
click node_render "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/util/css-tool.ts"
click node_settingsview "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/views/settings-view.ts"
click node_settingstab "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/enhanced-obsidian-components/obsidian-settings-tab.ts"
click node_settings "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/core/plugin-settings.ts"
click node_store "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/services/plugin-data-store.ts"
click node_initial "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/_config/initial-settings.ts"
click node_rules "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/util/rules-helper.ts"
click node_ruletypes "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/types/matching-rules.ts"
click node_modes "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/types/general.ts"
click node_logger "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/util/logger.ts"
click node_errors "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/util/error-helper.ts"
click node_strings "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/core/plugin-strings.ts"
click node_info "https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/core/plugin-info.ts"

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_plugin toneBlue
class node_treefocus,node_explorer,node_evaluation,node_render toneAmber
class node_settingsview,node_settingstab,node_settings,node_store,node_initial,node_rules,node_ruletypes,node_modes toneMint
class node_logger,node_errors,node_strings,node_info toneRose
class node_obsidian toneIndigo
```

## Components

### Plugin entry

- [Plugin events](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/main.ts): `main.ts`

### Focus workflow

- [Refresh coordinator](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/core/tree-focus.ts): `src/core/tree-focus.ts`
- [Explorer traversal](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/util/file-explorer-helper.ts): `src/util/file-explorer-helper.ts`
- [Mode evaluation](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/services/mode-evaluation-service.ts): `src/services/mode-evaluation-service.ts`
- [Element styling](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/util/css-tool.ts): `src/util/css-tool.ts`

### Settings and rules

- [Settings editor](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/views/settings-view.ts): `src/views/settings-view.ts`
- [Settings tab UI](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/enhanced-obsidian-components/obsidian-settings-tab.ts): `src/enhanced-obsidian-components/obsidian-settings-tab.ts`
- [Plugin settings](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/core/plugin-settings.ts): `src/core/plugin-settings.ts`
- [Settings persistence](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/services/plugin-data-store.ts): `src/services/plugin-data-store.ts`
- [Default settings](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/_config/initial-settings.ts): `src/_config/initial-settings.ts`
- [Rule matching](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/util/rules-helper.ts): `src/util/rules-helper.ts`
- [Rule definitions](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/types/matching-rules.ts): `src/types/matching-rules.ts`
- [Focus modes](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/types/general.ts): `src/types/general.ts`

### Shared utilities

- [Logging](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/util/logger.ts): `src/util/logger.ts`
- [Plugin errors](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/util/error-helper.ts): `src/util/error-helper.ts`
- [Error details](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/core/plugin-strings.ts): `src/core/plugin-strings.ts`
- [Plugin metadata](https://github.com/iosonntag/obsidian-plugin-treefocus/blob/master/src/core/plugin-info.ts): `src/core/plugin-info.ts`

### Other components

- **Obsidian**

## Connections

- Obsidian → Plugin events: fires lifecycle events (evidence: `main.ts`)
- Plugin events → Refresh coordinator: initializes and dispatches (evidence: `main.ts`)
- Plugin events → Settings editor: registers settings tab (evidence: `main.ts`)
- Refresh coordinator → Settings persistence: initializes with defaults (evidence: `src/core/tree-focus.ts`)
- Refresh coordinator → Default settings: supplies defaults (evidence: `src/core/tree-focus.ts`)
- Refresh coordinator → Settings editor: creates settings view (evidence: `src/core/tree-focus.ts`)
- Refresh coordinator → Explorer traversal: traverses items (evidence: `src/core/tree-focus.ts`)
- Refresh coordinator → Mode evaluation: evaluates each item (evidence: `src/core/tree-focus.ts`)
- Refresh coordinator → Element styling: applies mode attributes (evidence: `src/core/tree-focus.ts`)
- Refresh coordinator → Plugin settings: reads overrides and preset (evidence: `src/core/tree-focus.ts`)
- Settings editor → Settings tab UI: extends settings UI (evidence: `src/views/settings-view.ts`)
- Settings editor → Plugin settings: updates rules and presets (evidence: `src/views/settings-view.ts`)
- Refresh coordinator → Plugin settings: writes item overrides (evidence: `src/core/tree-focus.ts`)
- Mode evaluation → Plugin settings: reads overrides and rules (evidence: `src/services/mode-evaluation-service.ts`)
- Mode evaluation → Rule matching: validates and matches (evidence: `src/services/mode-evaluation-service.ts`)
- Rule matching → Rule definitions: uses rule shape
- Mode evaluation → Focus modes: returns focus mode (evidence: `src/services/mode-evaluation-service.ts`)
- Settings editor → Rule definitions: edits matching rules (evidence: `src/views/settings-view.ts`)
- Settings editor → Focus modes: edits focus modes (evidence: `src/views/settings-view.ts`)
- Refresh coordinator → Logging: logs refresh activity (evidence: `src/core/tree-focus.ts`)
- Plugin errors → Error details: appends bug details (evidence: `src/util/error-helper.ts`)
- Plugin errors → Logging: logs appendix failure (evidence: `src/util/error-helper.ts`)
- Error details → Plugin metadata: reads plugin metadata (evidence: `src/core/plugin-strings.ts`)
- Plugin metadata → Plugin errors: uses error helper (evidence: `src/core/plugin-info.ts`)
