# nodetool-ai/nodetool architecture

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

- Interactive diagram: https://gitdiagram.com/nodetool-ai/nodetool
- Repository: https://github.com/nodetool-ai/nodetool

## Overview

##### Main Components (Top Level)

a) Frontend Layer
- ReactJS Editor (web-based interface)
- Electron Wrapper (for desktop application)
- Asset Management UI
- Model Manager Interface
- Workflow Editor

b) API Layer
- HTTP API Server
- WebSocket Server
- Authentication Service
- Job Management Service

c) Execution Layer
- WebSocket Runner
- Worker System
- Model Integration Layer
- Storage System

d) External Services Integration
- Cloud AI Services (OpenAI, Anthropic, etc.)
- Hugging Face Integration
- Ollama Integration
- Replicate Integration

##### Data Flow Connections
- WebSocket connections (bidirectional, real-time)
- HTTP API calls (request/response)
- Internal communication channels
- File system interactions

##### Storage Systems
Dedicated sections for:
- Asset Storage
- Model Cache
- Workflow Storage
- User Data Storage

##### Processing Pipeline
Detail the workflow execution path:
- Job Submission
- Task Distribution
- Node Execution
- Result Aggregation
- Real-time Updates

##### Security Layer
Security components:
- Authentication
- Authorization
- API Key Management
- Session Management

##### Integration Points
Integration points for:
- External AI Services
- Local Model Execution
- File System Access
- Database Interactions

##### Legends and Notes
Include:
- Component type indicators
- Connection type explanations
- Version information
- System requirements

- The modular architecture allowing for easy extension
- The real-time nature of the system
- The separation between local and cloud execution
- The flexible node system
- The asset management capabilities
- The model management system

Remember to include key features like:
- WebSocket-based real-time communication
- Local and remote model execution paths
- Asset management flow
- Model caching and management
- Workflow execution pipeline
- Node system architecture

This will provide a clear understanding of how NodeTool's components interact while maintaining the flexibility to add new features and integrations.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        WI[Web Interface]
        DA[Desktop App]
        AM[Asset Management]
        MM[Model Manager]
        WE[Workflow Editor]
    end

    subgraph API
        HS[HTTP Server]
        WS[WebSocket Server]
        AS[Authentication Service]
        JM[Job Management]
    end

    subgraph Execution
        WSR[WebSocket Runner]
        WKS[Worker System]
        MIL[Model Integration]
        SS[Storage System]
    end

    subgraph External
        OAI[OpenAI Service]
        ANT[Anthropic Service]
        HF[Hugging Face]
        OLL[Ollama]
        REP[Replicate]
    end

    subgraph Storage
        AStore[Asset Storage]
        MCache[Model Cache]
        WStore[Workflow Storage]
        UStore[User Data]
    end

    %% Frontend to API connections
    WI --> HS
    WI --> WS
    DA --> HS
    DA --> WS
    AM --> HS
    MM --> HS
    WE --> WS

    %% API to Execution connections
    HS --> WSR
    WS --> WSR
    AS --> WSR
    JM --> WKS
    WSR --> WKS
    WKS --> MIL
    WKS --> SS

    %% Execution to External connections
    MIL --> OAI
    MIL --> ANT
    MIL --> HF
    MIL --> OLL
    MIL --> REP

    %% Storage connections
    SS --> AStore
    SS --> MCache
    SS --> WStore
    SS --> UStore

    %% Click events
    click WI "https://github.com/nodetool-ai/nodetool/tree/main/web/src/*"
    click DA "https://github.com/nodetool-ai/nodetool/tree/main/electron/*"
    click AM "https://github.com/nodetool-ai/nodetool/tree/main/web/src/components/assets/*"
    click MM "https://github.com/nodetool-ai/nodetool/tree/main/web/src/components/hugging_face/*"
    click WE "https://github.com/nodetool-ai/nodetool/tree/main/web/src/components/node_editor/*"
    click HS "https://github.com/nodetool-ai/nodetool/blob/main/src/nodetool/api/server.py"
    click AS "https://github.com/nodetool-ai/nodetool/blob/main/src/nodetool/api/auth.py"
    click JM "https://github.com/nodetool-ai/nodetool/blob/main/src/nodetool/api/job.py"
    click WS "https://github.com/nodetool-ai/nodetool/blob/main/src/nodetool/workflows/http_stream_runner.py"
    click WSR "https://github.com/nodetool-ai/nodetool/tree/main/src/nodetool/workflows/*"
    click WKS "https://github.com/nodetool-ai/nodetool/blob/main/src/nodetool/api/worker.py"
    click SS "https://github.com/nodetool-ai/nodetool/tree/main/src/nodetool/storage/*"
    click OAI "https://github.com/nodetool-ai/nodetool/tree/main/src/nodetool/nodes/openai/*"
    click ANT "https://github.com/nodetool-ai/nodetool/tree/main/src/nodetool/nodes/anthropic/*"
    click HF "https://github.com/nodetool-ai/nodetool/tree/main/src/nodetool/nodes/huggingface/*"
    click OLL "https://github.com/nodetool-ai/nodetool/tree/main/src/nodetool/nodes/ollama/*"
    click REP "https://github.com/nodetool-ai/nodetool/tree/main/src/nodetool/nodes/replicate/*"

    %% Styling
    classDef frontend fill:#a8d1ff
    classDef api fill:#90EE90
    classDef execution fill:#FFB6C1
    classDef external fill:#FFD700
    classDef storage fill:#DDA0DD

    class WI,DA,AM,MM,WE frontend
    class HS,WS,AS,JM api
    class WSR,WKS,MIL,SS execution
    class OAI,ANT,HF,OLL,REP external
    class AStore,MCache,WStore,UStore storage
```
