# benji300/joplin-note-tabs architecture

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

- Interactive diagram: https://gitdiagram.com/benji300/joplin-note-tabs
- Repository: https://github.com/benji300/joplin-note-tabs

## Overview

##### Main Components of the Plugin
a. Plugin Interface/Integration Layer:
- Represented by the “api” directory which includes TypeScript declaration files (e.g. Joplin.d.ts, JoplinClipboard.d.ts, etc.). These files define how the plugin interacts with core Joplin APIs such as commands, settings, UI elements, and data storage.
b. Core Business Logic:
- The “src” directory holds the core TypeScript files (index.ts, noteTabs.ts, panel.ts, settings.ts, lastActiveNote.ts). These files encapsulate the functionality for managing note tabs, handling user actions (like pinning/unpinning), and interfacing with Joplin’s commands.
c. User Interface and Styling:
- UI elements for the panels are handled in “src/webview.js” and its accompanying CSS files (webview.css, webview_auto.css, webview_vertical.css). This part covers the visual representation and responsive behaviors (horizontal or vertical layouts) of the note tabs.
d. Configuration and Manifest:
- Files such as “src/manifest.json” and “plugin.config.json” provide the metadata and configuration needed by Joplin to load and execute the plugin. They include required version information and define how the plugin is registered.
e. Assets:
- The “assets” directory contains supporting media (like screencast.mp4) and screenshots, which illustrate the UI and can be referenced in the design documentation.
f. Build and Development Tools:
- Tools like “webpack.config.js” and “tsconfig.json” indicate that the project is built using TypeScript and bundled with Webpack. The package.json and accompanying scripts (e.g., “npm run dist” for building the plugin) show standard Node.js tooling.

##### Relationships and Interactions Between Components
- The plugin integration layer (API declarations) allows the “src” business logic to call proper Joplin APIs which, in turn, affect the UI.
- UI components (webviews) are rendered using the output generated from the business logic. For example, note selections and tab management logic in “noteTabs.ts” or “panel.ts” trigger UI updates.
- Configuration files (manifest.json, plugin.config.json) serve as entry points that tell Joplin how to load and initialize the plugin, which then bootstraps the entire business logic sequence.
- Build scripts (webpack.config.js) compile and bundle all the TypeScript sources, ensuring the API integration, business logic, and UI components are packaged into the correct format for distribution.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The clear division between API definitions, business logic, UI components, and configuration indicates a modular design.
- Plugin Architecture: The design leverages Joplin’s plugin system, requiring clear interfaces (through API declarations) and adherence to Joplin’s command, settings, and view integration models.
- Event-Driven Interactions: The use of commands (such as tabsPinNote, tabsSwitchRight, etc.) suggests event-based communication where user actions trigger events that flow from the UI to the business logic and back to modify the UI.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Nodes
    BUILD["Build and Development Tools"]:::build
    CONFIG["Configuration & Manifest"]:::config
    CORE["Core Business Logic"]:::logic
    API["API Integration Layer"]:::api
    subgraph "User Interface & Styling"
        WEBJS["Webview JS"]:::ui
        CSS["Webview CSS"]:::ui
        CSS_AUTO["Webview Auto CSS"]:::ui
        CSS_VERT["Webview Vertical CSS"]:::ui
    end
    ASSETS["Assets"]:::assets
    JOPL["Joplin Desktop"]:::external

    %% Relationships
    BUILD -->|"builds"| CONFIG
    CONFIG -->|"loads plugin"| CORE
    CORE -->|"invokes"| API
    CORE <-->|"handles events"| WEBJS
    WEBJS -->|"updates based on logic"| CORE
    API -->|"calls Joplin APIs"| JOPL
    ASSETS -->|"support UI"| WEBJS

    %% Click Events for Build and Development Tools
    click BUILD "https://github.com/benji300/joplin-note-tabs/blob/master/webpack.config.js"
    click BUILD "https://github.com/benji300/joplin-note-tabs/blob/master/tsconfig.json"
    click BUILD "https://github.com/benji300/joplin-note-tabs/blob/master/package.json"

    %% Click Events for Configuration and Manifest
    click CONFIG "https://github.com/benji300/joplin-note-tabs/blob/master/src/manifest.json"
    click CONFIG "https://github.com/benji300/joplin-note-tabs/blob/master/plugin.config.json"

    %% Click Event for Core Business Logic
    click CORE "https://github.com/benji300/joplin-note-tabs/tree/master/src/"

    %% Click Event for API Integration Layer
    click API "https://github.com/benji300/joplin-note-tabs/tree/master/api/"

    %% Click Events for User Interface and Styling components
    click WEBJS "https://github.com/benji300/joplin-note-tabs/blob/master/src/webview.js"
    click CSS "https://github.com/benji300/joplin-note-tabs/blob/master/src/webview.css"
    click CSS_AUTO "https://github.com/benji300/joplin-note-tabs/blob/master/src/webview_auto.css"
    click CSS_VERT "https://github.com/benji300/joplin-note-tabs/blob/master/src/webview_vertical.css"

    %% Click Event for Assets
    click ASSETS "https://github.com/benji300/joplin-note-tabs/tree/master/assets/"

    %% Styles
    classDef build fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef config fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef logic fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef api fill:#AED6F1,stroke:#2874A6,stroke-width:2px;
    classDef ui fill:#82E0AA,stroke:#239B56,stroke-width:2px;
    classDef assets fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef external fill:#EEEEEE,stroke:#7F8C8D,stroke-width:2px;
```
