# deven96/ahnlich architecture

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

- Interactive diagram: https://gitdiagram.com/deven96/ahnlich
- Repository: https://github.com/deven96/ahnlich

## Overview

##### Main Components Identification

a) Core Services:
- Ahnlich DB (Vector Store Service)
- Ahnlich AI (AI Proxy Service)
- Client SDKs (Python and Rust)
- CLI Interface

b) Supporting Components:
- gRPC Communication Layer
- Persistence Layer
- Model Cache Storage
- Tracing System (Jaeger)

##### Architectural Layers

a) Client Layer:
- Both Python and Rust SDK clients
- CLI interface
- Web interface (from web/ahnlich-web)

b) Service Layer:
- AI Service (port 1370)
- DB Service (port 1369)

c) Processing Layer:
- Vector Processing
- AI Model Processing
- Similarity Search Algorithms

d) Storage Layer:
- In-memory Vector Store
- Persistence Storage
- Model Cache

##### Component Relationships

- Client-to-Service communication via gRPC
- AI Service to DB Service communication
- Storage interactions
- Tracing flow

##### Specific Implementation Details

Technical details such as:
- Supported similarity algorithms (cosine, euclidean, kdtree)
- AI model support (all-minilm-l6-v2, resnet-50)
- Protocol specifications (gRPC)
- Persistence mechanisms

##### Additional Elements

Include:
- Port numbers
- Supported execution providers (CUDA, CoreML)
- Configuration options
- Persistence paths
- Model cache locations

##### Notes

Important notes regarding:
- Production readiness status
- Required dependencies (CUDA v12, etc.)
- Persistence configuration
- Tracing setup

Remember to indicate the scalability aspects and how the system handles different types of queries (vector similarity search, metadata filtering, AI model processing) through the various components.

This design should reflect both the current implementation and allow for future extensions as indicated by the project's structure and documentation.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph Clients
        PythonSDK["Python SDK"]
        RustSDK["Rust SDK"]
        CLI["CLI Interface"]
        WebUI["Web Interface"]
    end

    %% Service Layer
    subgraph Services
        AIAPI["AI Service (1370)"]:::service
        DBAPI["DB Service (1369)"]:::service
    end

    %% Processing Layer
    subgraph Processing
        VectorProc["Vector Processing"]:::processing
        AIModelProc["AI Model Processing"]:::processing
        SimilarityAlgo["Similarity Algorithms<br/>(cosine, euclidean, kdtree)"]:::processing
    end

    %% Storage Layer
    subgraph Storage
        VectorStore[("In-memory<br/>Vector Store")]:::storage
        PersistStore[("Persistence<br/>Storage")]:::storage
        ModelCache[("Model Cache")]:::storage
    end

    %% Supporting Systems
    subgraph Infrastructure
        gRPC["gRPC Layer"]:::infra
        DSL["Domain Specific<br/>Language"]:::infra
        TaskMgr["Task Manager"]:::infra
        Tracer["Jaeger Tracing"]:::infra
    end

    %% Relationships
    PythonSDK --> gRPC
    RustSDK --> gRPC
    CLI --> gRPC
    WebUI --> gRPC
    
    gRPC --> AIAPI
    gRPC --> DBAPI
    
    AIAPI --> AIModelProc
    DBAPI --> VectorProc
    VectorProc --> SimilarityAlgo
    
    VectorProc --> VectorStore
    AIModelProc --> ModelCache
    VectorStore --> PersistStore
    
    AIAPI -.-> Tracer
    DBAPI -.-> Tracer
    
    TaskMgr --> AIAPI
    TaskMgr --> DBAPI
    
    DSL --> DBAPI
    DSL --> AIAPI

    %% Styles
    classDef service fill:#90EE90,stroke:#333,stroke-width:2px
    classDef processing fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef storage fill:#E6E6FA,stroke:#333,stroke-width:2px
    classDef infra fill:#ADD8E6,stroke:#333,stroke-width:2px

    %% Click Events
    click PythonSDK "https://github.com/deven96/ahnlich/tree/main/sdk/ahnlich-client-py/"
    click RustSDK "https://github.com/deven96/ahnlich/tree/main/ahnlich/client/"
    click CLI "https://github.com/deven96/ahnlich/tree/main/ahnlich/cli/"
    click WebUI "https://github.com/deven96/ahnlich/tree/main/web/ahnlich-web/"
    click AIAPI "https://github.com/deven96/ahnlich/tree/main/ahnlich/ai/"
    click DBAPI "https://github.com/deven96/ahnlich/tree/main/ahnlich/db/"
    click VectorProc "https://github.com/deven96/ahnlich/tree/main/ahnlich/db/src/algorithm/"
    click AIModelProc "https://github.com/deven96/ahnlich/tree/main/ahnlich/ai/src/engine/ai/"
    click SimilarityAlgo "https://github.com/deven96/ahnlich/tree/main/ahnlich/similarity/"
    click gRPC "https://github.com/deven96/ahnlich/tree/main/ahnlich/grpc_types/"
    click DSL "https://github.com/deven96/ahnlich/tree/main/ahnlich/dsl/"
    click TaskMgr "https://github.com/deven96/ahnlich/tree/main/ahnlich/task-manager/"
    click Tracer "https://github.com/deven96/ahnlich/tree/main/ahnlich/tracer/"
    click PersistStore "https://github.com/deven96/ahnlich/blob/main/ahnlich/utils/src/persistence.rs"
```
