# brianpetro/obsidian-smart-connections architecture

> Architecture diagram of the GitHub repository brianpetro/obsidian-smart-connections, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/brianpetro/obsidian-smart-connections
- Repository: https://github.com/brianpetro/obsidian-smart-connections

## Overview

##### High-Level Architecture Components

a. Core Components:
- Embedding System
- Smart View Engine
- Smart Chat System
- File System Interface
- Settings Manager
- UI Components

b. External Services:
- AI Model Providers (OpenAI, Google, Anthropic, etc.)
- Local Model Integration (Ollama, LM Studio)

##### Key Relationships

- Data flow between the Obsidian vault and the embedding system
- Communication patterns between the chat system and AI providers
- Integration points with local models
- User interface interactions

##### Detailed Component Breakdown

Frontend Layer:
**UI Components**
- Smart View
- Smart Chat Interface
- Settings Panel
- Dynamic Code Blocks

Core Processing Layer:
**Processing Engine**
- Embedding Generator
- Note Analyzer
- Search System
- Chat Processor

Storage Layer:
**Data Management**
- .smart-env (embeddings storage)
- Chat History
- Settings Storage

##### Component Details

Smart View Engine:
- Connection to embedding system
- Real-time processing flow
- Relationship with note storage

Chat System:
- Connection to AI providers
- Chat history storage
- Context processing flow

Embedding System:
- Connection to external AI services
- Local model integration
- Caching mechanism

##### Implementation Notes

- The modular nature of the system (src/components structure)
- The separation between core functionality and UI
- The plugin's integration with Obsidian's API
- The flexible model support system

##### Specific Implementation Details

- How src/actions handles API interactions
- How src/components manages UI elements
- Demonstrate how src/views handles different view types
- Relationship with build processes

- Clear layering
- Component grouping
- Relationship visualization
- Export to common formats

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph UI
        SV[Smart View]:::ui
        SCI[Smart Chat Interface]:::ui
        SP[Settings Panel]:::ui
        DCB[Dynamic Code Blocks]:::ui
    end

    subgraph Core
        EmbSys[Embedding System]:::core
        NoteAn[Note Analyzer]:::core
        SearchSys[Search System]:::core
        ChatProc[Chat Processor]:::core
        FSI[File System Interface]:::core
        SetMgr[Settings Manager]:::core
        NotifSys[Notification System]:::core
    end

    subgraph Storage
        SmartEnv[(.smart-env)]:::storage
        ChatHist[(Chat History)]:::storage
        SetStore[(Settings Storage)]:::storage
    end

    subgraph External
        OpenAI[OpenAI API]:::external
        Google[Google API]:::external
        Anthropic[Anthropic API]:::external
        LocalModels[Local Models]:::external
    end

    %% Core Relationships
    EmbSys --> SmartEnv
    EmbSys --> SearchSys
    SearchSys --> NoteAn
    ChatProc --> ChatHist
    SetMgr --> SetStore
    FSI --> NoteAn

    %% UI Relationships
    SV --> SearchSys
    SCI --> ChatProc
    SP --> SetMgr
    DCB --> FSI

    %% External Service Relationships
    EmbSys -.-> OpenAI
    EmbSys -.-> Google
    ChatProc -.-> OpenAI
    ChatProc -.-> Anthropic
    EmbSys -.-> LocalModels
    ChatProc -.-> LocalModels

    %% Notification Flow
    NotifSys --> SV
    NotifSys --> SCI

    %% Click Events
    click SV "https://github.com/brianpetro/obsidian-smart-connections/blob/main/src/views/smart_view2.obsidian.js"
    click SCI "https://github.com/brianpetro/obsidian-smart-connections/blob/main/src/views/smart_chat.js"
    click SP "https://github.com/brianpetro/obsidian-smart-connections/blob/main/src/components/main_settings.js"
    click EmbSys "https://github.com/brianpetro/obsidian-smart-connections/blob/main/src/smart_env.config.js"
    click FSI "https://github.com/brianpetro/obsidian-smart-connections/blob/main/src/open_note.js"
    click SetMgr "https://github.com/brianpetro/obsidian-smart-connections/blob/main/src/sc_settings_tab.js"
    click NotifSys "https://github.com/brianpetro/obsidian-smart-connections/blob/main/src/smart_notices.js"
    click ChatProc "https://github.com/brianpetro/obsidian-smart-connections/blob/main/src/sc_thread.js"

    %% Styling
    classDef core fill:#2374ab
    classDef ui fill:#ff7f50
    classDef storage fill:#9b59b6
    classDef external fill:#2ecc71
    
    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[UI Elements]:::ui
        L3[(Storage Systems)]:::storage
        L4[External Services]:::external
    end
```
