# kevboh/longform architecture

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

- Interactive diagram: https://gitdiagram.com/kevboh/longform
- Repository: https://github.com/kevboh/longform

## Overview

##### Project type and purpose
- Longform is an Obsidian community plugin that helps users organize, edit, and compile multi-scene or single-scene writing projects (novels, screenplays, essays) stored in an Obsidian vault.
- It integrates deeply with Obsidian’s plugin API, providing a custom sidebar pane, commands, modals, and a compile‐pipeline to assemble manuscripts from Markdown notes.

##### File structure
- Top‐level config: manifest.json, package.json, rollup.config.js, tsconfig.json, vitest.config.ts.
- src/api: external HTTP integration (LongformAPI).
- src/commands: Command handlers (registering Obsidian commands for UI actions).
- src/compile: The compile‐pipeline and compile steps (Strategy pattern).
- src/model: In‐memory stores, vault synchronization, scene navigation, migration logic.
- src/view: Svelte components for the sidebar pane, modals, compile UI, explorer view, settings.
- src/utils: File I/O helpers.
- src/main.ts: Plugin entrypoint—initializes UI, commands, event listeners.

##### Key insights from the README
- The plugin watches vault files with a `longform` frontmatter, builds an in‐memory model of projects/drafts/scenes, and syncs changes back to disk only to the project index file.
- Users interact via the Obsidian sidebar (Scenes, Project, Compile tabs) and context‐menu commands.
- The Compile tab drives a customizable sequence of compile steps that transform scene Markdown into a final manuscript.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Obsidian Host Environment
    subgraph "Obsidian Host"
        direction TB
        HostPluginAPI["Plugin Loader / Workspace API"]:::host
    end

    %% Plugin Extension
    subgraph "Longform Plugin Extension"
        direction TB

        EntryPoint["Entry Point"]:::logic
        click EntryPoint "https://github.com/kevboh/longform/blob/main/src/main.ts"

        subgraph "View Layer"
            direction TB
            ViewUI["Svelte UI Components"]:::ui
            click ViewUI "https://github.com/kevboh/longform/blob/main/src/view/CompileView.svelte"
        end

        subgraph "Command Controller"
            direction TB
            Commands["Command Handlers"]:::logic
            click Commands "https://github.com/kevboh/longform/blob/main/src/commands/index.ts"
        end

        subgraph "Model Layer"
            direction TB
            ModelStores["In-memory Stores & Vault Sync"]:::logic
            click ModelStores "https://github.com/kevboh/longform/blob/main/src/model/stores.ts"
        end

        subgraph "Compile Pipeline"
            direction TB
            CompilePipeline["Compile Orchestrator & Steps"]:::logic
            click CompilePipeline "https://github.com/kevboh/longform/blob/main/src/compile/index.ts"
        end

        subgraph "API Layer"
            direction TB
            LongformAPI["LongformAPI"]:::external
            click LongformAPI "https://github.com/kevboh/longform/blob/main/src/api/LongformAPI.ts"
        end

        subgraph "Utils"
            direction TB
            FileUtils["File I/O Helpers"]:::io
            click FileUtils "https://github.com/kevboh/longform/blob/main/src/utils/file-utils.ts"
        end
    end

    %% Vault and External
    Vault["Vault File System"]:::io
    External["External Services (e.g., screen.garden)"]:::external

    %% Data Flows
    HostPluginAPI -->|"initialize plugin"| EntryPoint
    EntryPoint -->|"mount sidebar, register commands"| ViewUI
    ViewUI -->|"emit UI events"| Commands
    Commands -->|"update stores"| ModelStores
    Commands -->|"write frontmatter"| FileUtils
    FileUtils -->|"persist to disk"| Vault
    Vault -->|"file change events"| ModelStores
    ViewUI -->|"invoke compile"| CompilePipeline
    CompilePipeline -->|"load project data"| ModelStores
    CompilePipeline -->|"run compile steps"| CompilePipeline
    CompilePipeline -->|"write output"| FileUtils
    FileUtils -->|"persist manuscript"| Vault
    CompilePipeline -->|"optional sync/share"| LongformAPI
    LongformAPI -->|"HTTP calls"| External

    %% Styles
    classDef ui fill:#bbdefb,stroke:#333,stroke-width:1px
    classDef logic fill:#c8e6c9,stroke:#333,stroke-width:1px
    classDef io fill:#ffe0b2,stroke:#333,stroke-width:1px
    classDef external fill:#d1c4e9,stroke:#333,stroke-width:1px
    classDef host fill:#e0e0e0,stroke:#333,stroke-width:1px
```
