# shaunabanana/intrigue architecture

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

- Interactive diagram: https://gitdiagram.com/shaunabanana/intrigue
- Repository: https://github.com/shaunabanana/intrigue

## Overview

##### Project Overview and Purpose
- The project, named “Intrigue”, is designed to help users organize literature and their thoughts visually. It’s an application that lets you create and manipulate “notes” on a canvas (with capabilities such as dragging, snapping, and connecting) and includes features like automatic metadata extraction (via DOI/ISBN/BibTeX/web links), WYSIWYG markdown editing (powered by TipTap), and even offline-first distributed collaborative editing.
- Because the README mentions binaries available for Windows, macOS, and Linux alongside files like src/background.js and src/preload.js, it is highly likely that Intrigue is an Electron-based desktop application built with Vue.js as the UI framework.

##### Key Components (Layers)
a. Desktop Application Shell (Electron):
– Main Process: Represented by files such as src/background.js, likely responsible for launching the Electron app, handling system-level events, and managing windows.
– Preload Process: (src/preload.js) that facilitates secure communication (using context bridges, etc.) between the main process and the renderer.

b. Renderer Process / Frontend:
– Vue.js Frontend: Located primarily inside the src directory, with App.vue as the root and various Vue components (e.g., note.vue, editor.vue, literature.vue, node.vue, etc.) that build the interactive UI.
– Script Utilities: In src/scripts, you see modules like api.js and utils.js that likely manage communication with backend APIs or perform client-side logic.

c. State Management:
– Vuex Store: The src/store directory (and index.js) indicates that application state is managed centrally with Vuex.

d. External Libraries and Services:
– Citation.js for metadata extraction.
– TipTap for the rich text / markdown editing in the notes.
– Integration with Zotero through a Quick Copy translator.
– Mention of upcoming P2P collaborative editing suggests networking and distributed data synchronization components.

e. Build and Configuration:
– Build and configuration files include package.json, vue.config.js, and babel.config.js. These are important for understanding how the project is bundled and built.

##### Relationships and Data Flow
– Illustrate how the Electron main process (background.js) and the renderer process (where Vue components reside) communicate via IPC and the preload script.
– Show how user interactions in the Vue components (e.g., creating or editing notes) cause actions that update the Vuex store.
– Represent how utilities in src/scripts (such as api.js) interact with external libraries (Citation.js and TipTap) to process data (metadata extraction, rich text updates).
– Indicate possible interactions for offline-first distributed editing, suggesting that data might be synchronized in a peer-to-peer manner or stored locally and later merged/synchronized.

##### Architectural Patterns and Design Principles
- Clearly a modular architecture that separates concerns:
- UI Layer (Vue components)
- Application Shell and System Integration (Electron’s main and preload processes)
- State Management (Vuex)
- External service integrations (Citation.js, TipTap, Zotero translator)
- The file structure resembles an MVC or component-based pattern where visual nodes (model elements) are rendered and manipulated via Vue components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Electron Layer
    subgraph "Electron Layer"
        EM("Electron Main Process"):::electron
        preload("Preload Script"):::electron
    end

    %% Renderer Layer
    subgraph "Renderer Layer"
        VueApp("Vue App"):::renderer
        subgraph "Vue Components"
            note("Note/Editor/Literature/Node/Edge/Group/Region"):::component
        end
        assets("Assets (Static)"):::static
        html("HTML Shell (index.html)"):::static
        store("Vuex Store"):::state
        scripts("Script Utilities"):::scripts
    end

    %% Build and Configuration
    subgraph "Build & Config"
        pkg("package.json, vue.config.js, babel.config.js"):::build
        buildfolder("Build Folder (Platform Assets)"):::build
    end

    %% External Services and Future Integrations
    subgraph "External Services"
        citation("Citation.js"):::external
        tiptap("TipTap"):::external
        zotero("Zotero Translator"):::external
        p2p("P2P Collaboration (Future)"):::external
    end

    %% Relationships
    EM -->|"IPC"| preload
    preload -->|"BridgeIPC"| VueApp
    VueApp -->|"Renders"| note
    VueApp -->|"Uses"| store
    VueApp -->|"Loads"| assets
    VueApp -->|"Loads"| html
    note -->|"UpdatesState"| store
    scripts -->|"APICalls"| VueApp
    scripts -->|"ExtractsMetadata"| citation
    scripts -->|"Integrates"| tiptap
    scripts -->|"Integrates"| zotero
    store -->|"StateUpdates"| VueApp
    pkg -->|"Configures"| VueApp
    pkg -->|"Configures"| EM
    pkg -->|"Configures"| preload
    buildfolder -->|"SuppliesAssets"| assets
    VueApp -->|"FutureSync"| p2p
    p2p ---|"DataSync"| store

    %% Click Events
    click EM "https://github.com/shaunabanana/intrigue/blob/main/src/background.js"
    click preload "https://github.com/shaunabanana/intrigue/blob/main/src/preload.js"
    click VueApp "https://github.com/shaunabanana/intrigue/blob/main/src/App.vue"
    click note "https://github.com/shaunabanana/intrigue/tree/main/src/components"
    click assets "https://github.com/shaunabanana/intrigue/tree/main/src/assets"
    click html "https://github.com/shaunabanana/intrigue/blob/main/public/index.html"
    click store "https://github.com/shaunabanana/intrigue/blob/main/src/store/index.js"
    click scripts "https://github.com/shaunabanana/intrigue/tree/main/src/scripts"
    click pkg "https://github.com/shaunabanana/intrigue/blob/main/package.json"
    click buildfolder "https://github.com/shaunabanana/intrigue/tree/main/build"

    %% Styles
    classDef electron fill:#FFCC00,stroke:#333,stroke-width:2px;
    classDef renderer fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef component fill:#C3FDB8,stroke:#333,stroke-width:2px;
    classDef static fill:#D1C4E9,stroke:#333,stroke-width:2px;
    classDef state fill:#F8BBD0,stroke:#333,stroke-width:2px;
    classDef scripts fill:#FFE0B2,stroke:#333,stroke-width:2px;
    classDef build fill:#B2EBF2,stroke:#333,stroke-width:2px;
    classDef external fill:#FFCDD2,stroke:#333,stroke-width:2px;
```
