# bigattichouse/vectorspace architecture

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

- Interactive diagram: https://gitdiagram.com/bigattichouse/vectorspace
- Repository: https://github.com/bigattichouse/vectorspace

## Overview

→ Client requests flow through Network Interface
→ Queries pass through Interpreter to Core
→ Data persists through VS Persist layer

→ Show how components depend on each other
→ Indicate optional components (simulation)

##### Key Architectural Elements

a. Server Components (Rectangle with double border)
- VSDB Daemon (vsdbd.c)
- Socket Handlers
- File Descriptors (vsdb_fd.c)

b. Data Structures (Hexagons)
- Tensors (vs_tensor.c/h)
- Rowsets (vs_rowset.c/h)
- Indices (vs_*index.c/h)

##### Specific features

a. Vector Space Operations
- Normalization
- IDF Calculations
- Clustering

b. Storage Mechanisms
- Disc Interface
- Cache System
- Persistence Layer

##### External Interfaces (Rounded Rectangles)
- PHP API
- Win32 SDK
- Command Line Tools
- Network Protocol

- Core Components: Blue
- Query/Processing: Green
- Clients: Yellow
- Simulation: Purple
- Storage: Orange
- External Interfaces: Gray

- Critical Path Highlights

Keep the abstraction level focused on the major components while showing the key interactions between the vector space database core and its various interfaces and extensions. The simulation component should be shown as an optional extension that integrates with the core system.

##### Storage management

This will provide a clear understanding of how the various components interact while maintaining a clean architectural representation.

## Diagram (Mermaid)

```mermaid
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'primaryColor': '#2b2b2b',
    'primaryTextColor': '#fff',
    'primaryBorderColor': '#7C0000',
    'lineColor': '#F8B229',
    'secondaryColor': '#006100',
    'tertiaryColor': '#fff'
  }
}}%%

flowchart TB
    classDef core fill:#4a90e2,stroke:#2b2b2b,color:white
    classDef query fill:#50C878,stroke:#2b2b2b,color:white
    classDef client fill:#FFD700,stroke:#2b2b2b,color:black
    classDef sim fill:#9370DB,stroke:#2b2b2b,color:white
    classDef storage fill:#FFA500,stroke:#2b2b2b,color:white
    classDef external fill:#808080,stroke:#2b2b2b,color:white
    classDef server fill:#2b2b2b,stroke:#4a90e2,color:white,stroke-width:3px
    classDef data fill:#c0c0c0,stroke:#2b2b2b,color:black,stroke-width:2px

    subgraph Core["Core Database Layer"]
        VSCore["VS Core"]:::core
        VSCluster["VS Cluster"]:::core
        VSCache["VS Cache"]:::core
        VSPersist["VS Persist"]:::core
    end

    subgraph Query["Query & Processing Layer"]
        VSQuery["VS Query"]:::query
        VSInterpreter["VS Interpreter"]:::query
        VSCursor["VS Cursor"]:::query
        VSNormalize["VS Normalize"]:::query
    end

    subgraph Clients["Client Interfaces"]
        PHP["PHP Client"]:::client
        Win32["Win32 DLL"]:::client
        CLI["Command Line Interface"]:::client
        Network["Network Interface"]:::client
    end

    subgraph Sim["Simulation Engine"]
        BlissEngine["Bliss Engine"]:::sim
        EntitySystem["Entity System"]:::sim
        SimAssets["Simulation Assets"]:::sim
    end

    subgraph Server["Server Components"]
        Daemon["VSDB Daemon"]:::server
        SocketHandlers["Socket Handlers"]:::server
        FileDesc["File Descriptors"]:::server
    end

    subgraph Data["Data Structures"]
        Tensors["Tensors"]:::data
        Rowsets["Rowsets"]:::data
        Indices["Indices"]:::data
    end

    %% Relationships
    Clients --> Network
    Network --> Daemon
    Daemon --> VSInterpreter
    VSInterpreter --> VSCore
    VSCore --> VSPersist
    VSCore --> VSCache
    VSCore --> VSCluster
    VSQuery --> VSCursor
    VSCursor --> Indices
    VSCore --> Tensors
    VSCore --> Rowsets
    BlissEngine --> EntitySystem
    EntitySystem --> VSCore
    SimAssets --> BlissEngine

    %% Click Events
    click VSCore "https://github.com/bigattichouse/vectorspace/tree/master/src/vs_core.c/h"
    click VSCluster "https://github.com/bigattichouse/vectorspace/tree/master/src/vs_cluster.c/h"
    click VSCache "https://github.com/bigattichouse/vectorspace/tree/master/src/vs_cache.c/h"
    click VSPersist "https://github.com/bigattichouse/vectorspace/tree/master/src/vs_persist.c/h"
    click VSQuery "https://github.com/bigattichouse/vectorspace/tree/master/src/vs_query.c/h"
    click VSInterpreter "https://github.com/bigattichouse/vectorspace/tree/master/src/vs_interpreter.c/h"
    click VSCursor "https://github.com/bigattichouse/vectorspace/tree/master/src/vs_cursor.c/h"
    click VSNormalize "https://github.com/bigattichouse/vectorspace/tree/master/src/vs_normalize.c/h"
    click PHP "https://github.com/bigattichouse/vectorspace/tree/master/clients/php/"
    click Win32 "https://github.com/bigattichouse/vectorspace/tree/master/clients/win32_dll/"
    click CLI "https://github.com/bigattichouse/vectorspace/tree/master/bin/vsdb_cli"
    click Network "https://github.com/bigattichouse/vectorspace/tree/master/src/vsdb_sockets.c/h"
    click BlissEngine "https://github.com/bigattichouse/vectorspace/tree/master/src/bliss_entity.c/h"
    click SimAssets "https://github.com/bigattichouse/vectorspace/tree/master/simulate/"
    click Daemon "https://github.com/bigattichouse/vectorspace/tree/master/bin/vsdbd"
    click SocketHandlers "https://github.com/bigattichouse/vectorspace/tree/master/src/sockhelp.c/h"
    click FileDesc "https://github.com/bigattichouse/vectorspace/blob/master/src/vsdb_fd.c"
    click Tensors "https://github.com/bigattichouse/vectorspace/tree/master/src/vs_tensor.c/h"
    click Rowsets "https://github.com/bigattichouse/vectorspace/tree/master/src/vs_rowset.c/h"
    click Indices "https://github.com/bigattichouse/vectorspace/tree/master/src/vs_cursorindex.c/h"

    %% Legend
    subgraph Legend
        L1["Core Component"]:::core
        L2["Query/Processing"]:::query
        L3["Client Interface"]:::client
        L4["Simulation"]:::sim
        L5["Data Structure"]:::data
        L6["Server Component"]:::server
    end
```
