# clidey/whodb architecture

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

- Interactive diagram: https://gitdiagram.com/clidey/whodb
- Repository: https://github.com/clidey/whodb

## Overview

##### Main Components Overview
The system should be represented as a three-tier architecture with these main components:

a. Frontend Layer (React Application)
- As a single block with subcomponents:
- UI Components (/frontend/src/components)
- Pages (/frontend/src/pages)
- State Management (/frontend/src/store)
- GraphQL Client Integration

b. Backend Core (Go Service)
- Following key components:
- GraphQL Server (core/graph)
- Authentication System (core/src/auth)
- LLM Integration Layer (core/src/llm)
- Plugin System (core/src/plugins)
- Router (core/src/router)

c. Database Connectors
- Supported databases as separate components:
- PostgreSQL
- MySQL
- SQLite3
- MongoDB
- Redis
- ElasticSearch
- ClickHouse

##### Component Relationships and Data Flow

- Backend → Database Connectors: Database-specific protocols
- LLM Integration → External Services (Ollama, ChatGPT, Anthropic)

##### Detailed Component Breakdown

Frontend (Blue Section):
**┌─ Frontend Layer ─────────────────┐**
- ┌─ Components ─┐ ┌─ Pages ────┐  │
- Graph      │ │ - Chat     │  │
- Editor     │ │ - Graph    │  │
- Sidebar    │ │ - Storage  │  │
- ┘ └────────────┘  │
- ┌─ Store ──────┐ ┌─ Config ───┐ │
- Auth       │ │ - GraphQL  │ │
- Database   │ │ - Routes   │ │
- ┘ └────────────┘ │
- ┘

Backend (Green Section):
**┌─ Backend Core ──────────────────┐**
- ┌─ GraphQL API ┐ ┌─ Auth ────┐ │
- Resolvers  │ │ - Login   │ │
- Schema     │ │ - Logout  │ │
- ┘ └──────────┘ │
- ┌─ LLM Engine ─┐ ┌─ Router ─┐ │
- Ollama     │ │ - Routes │ │
- ChatGPT    │ │ - Middle │ │
- Anthropic  │ │   ware   │ │
- ┘ └──────────┘ │
- ┘

Database Layer (Yellow Section):
**┌─ Database Connectors ───────────┐**
- ┌─ SQL ───────┐ ┌─ NoSQL ────┐ │
- PostgreSQL│ │ - MongoDB  │ │
- MySQL     │ │ - Redis    │ │
- SQLite3   │ │           │ │
- ┘ └──────────┘ │
- ┌─ Search ────┐              │
- Elastic   │              │
- ClickHouse│              │
- ┘              │
- ┘

##### Technical Details

- GraphQL endpoint (/graphql)
- WebSocket connections for real-time features
- Authentication flow
- Database connection pooling
- LLM integration points

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef frontend fill:#e1f5fe,stroke:#01579b
    classDef backend fill:#e8f5e9,stroke:#1b5e20
    classDef database fill:#fff3e0,stroke:#e65100
    classDef external fill:#f5f5f5,stroke:#424242
    
    %% Frontend Layer
    subgraph Frontend
        UI["UI Components"]
        Pages["Pages"]
        Store["State Management"]
        GraphQLClient["GraphQL Client"]
        
        subgraph FrontendComponents
            Graph["Graph Component"]
            Editor["Editor Component"]
            Sidebar["Sidebar Component"]
        end
        
        subgraph FrontendPages
            Chat["Chat Interface"]
            Storage["Storage Management"]
        end
    end
    
    %% Backend Layer
    subgraph Backend
        GraphQLServer["GraphQL Server"]
        Auth["Authentication System"]
        Router["Router System"]
        
        subgraph LLMIntegration["LLM Integration"]
            ChatGPT["ChatGPT Client"]
            Anthropic["Anthropic Client"]
            Ollama["Ollama Client"]
        end
    end
    
    %% Database Layer
    subgraph Databases
        subgraph SQLDatabases["SQL Databases"]
            Postgres[("PostgreSQL")]
            MySQL[("MySQL")]
            SQLite[("SQLite3")]
        end
        
        subgraph NoSQLDatabases["NoSQL Databases"]
            MongoDB[("MongoDB")]
            Redis[("Redis")]
        end
        
        subgraph SearchDatabases["Search Engines"]
            Elastic[("ElasticSearch")]
            ClickHouse[("ClickHouse")]
        end
    end
    
    %% External Services
    ExternalLLM["External LLM Services"]
    
    %% Relationships
    UI --> GraphQLClient
    Pages --> GraphQLClient
    Store --> GraphQLClient
    GraphQLClient <--> GraphQLServer
    GraphQLServer --> Auth
    GraphQLServer --> Router
    GraphQLServer --> LLMIntegration
    LLMIntegration --> ExternalLLM
    Router --> SQLDatabases
    Router --> NoSQLDatabases
    Router --> SearchDatabases
    
    %% Styling
    class UI,Pages,Store,GraphQLClient,FrontendComponents,FrontendPages,Graph,Editor,Sidebar,Chat,Storage frontend
    class GraphQLServer,Auth,Router,LLMIntegration,ChatGPT,Anthropic,Ollama backend
    class SQLDatabases,NoSQLDatabases,SearchDatabases,Postgres,MySQL,SQLite,MongoDB,Redis,Elastic,ClickHouse database
    class ExternalLLM external
    
    %% Click Events
    click UI "https://github.com/clidey/whodb/tree/main/frontend/src/components"
    click Pages "https://github.com/clidey/whodb/tree/main/frontend/src/pages"
    click Store "https://github.com/clidey/whodb/tree/main/frontend/src/store"
    click GraphQLClient "https://github.com/clidey/whodb/blob/main/frontend/src/config/graphql-client.ts"
    click GraphQLServer "https://github.com/clidey/whodb/tree/main/core/graph"
    click Auth "https://github.com/clidey/whodb/tree/main/core/src/auth"
    click Router "https://github.com/clidey/whodb/tree/main/core/src/router"
    click Graph "https://github.com/clidey/whodb/tree/main/frontend/src/components/graph"
    click Chat "https://github.com/clidey/whodb/tree/main/frontend/src/pages/chat"
    click Storage "https://github.com/clidey/whodb/tree/main/frontend/src/pages/storage-unit"
    click ChatGPT "https://github.com/clidey/whodb/blob/main/core/src/llm/chatgpt_client.go"
    click Anthropic "https://github.com/clidey/whodb/blob/main/core/src/llm/anthropic_client.go"
    click Ollama "https://github.com/clidey/whodb/blob/main/core/src/llm/ollama_client.go"
    click Postgres "https://github.com/clidey/whodb/tree/main/core/src/plugins/postgres"
    click MySQL "https://github.com/clidey/whodb/tree/main/core/src/plugins/mysql"
    click SQLite "https://github.com/clidey/whodb/tree/main/core/src/plugins/sqlite3"
    click MongoDB "https://github.com/clidey/whodb/tree/main/core/src/plugins/mongodb"
    click Redis "https://github.com/clidey/whodb/tree/main/core/src/plugins/redis"
    click Elastic "https://github.com/clidey/whodb/tree/main/core/src/plugins/elasticsearch"
    click ClickHouse "https://github.com/clidey/whodb/tree/main/core/src/plugins/clickhouse"
```
