# llmware-ai/llmware architecture

> Architecture diagram of the GitHub repository llmware-ai/llmware, 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/llmware-ai/llmware
- Repository: https://github.com/llmware-ai/llmware

## Overview

##### Main System Components

a) Core Components (Primary Layer):
- Library Management System
- Model Catalog & Management
- Embedding System
- Retrieval System
- Prompt Management
- Agent System

b) Data Store Layer:
- Text Collection Databases (MongoDB, PostgreSQL, SQLite)
- Vector Databases (Multiple options including Milvus, PGVector, Neo4j, etc.)
- File Storage System

c) Model Layer:
- SLIM Models (Specialized function-calling models)
- DRAGON Models (RAG-optimized 6-9B parameter models)
- BLING Models (Small CPU-based RAG models)
- Industry BERT Models (Domain-specific embedding models)
- External Model Integrations (HuggingFace, OpenAI, etc.)

##### Component Relationships

a) Data Flow:
**Documents → Parser → Library → Embedding System → Vector Database**
- ↓
- Text Database

b) Query Flow:
**Query → Retrieval System → Vector DB + Text DB → Prompt Management → Models → Response**

c) Agent Workflow:
**Agent → Function Calls → SLIM Models → Data Sources → Response Assembly**

##### Architectural Patterns

Key architectural patterns:
- Modular Component Design
- Plugin Architecture for Databases
- Model Registry Pattern
- Pipeline Processing Pattern
- Agent-based Architecture

##### Key Technical Elements

a) Infrastructure Layer:
- Docker Container Support
- GPU/CPU Processing Options
- File System Integration
- API Services

b) Integration Points:
- Vector Database Connectors
- Model API Integrations
- External Service Connections
- File System Interfaces

##### Deployment Options

Multiple deployment configurations:
- Local Development (SQLite + ChromaDB)
- Production Scale (MongoDB + Milvus)
- Enterprise (PostgreSQL + PGVector)

##### The agent-based architecture

Remember to:
- Use consistent naming conventions
- Version information
- Document key decision points

This system design should capture both the current state and the extensibility of the llmware framework, showing how it can be adapted for different use cases while maintaining its core RAG pipeline functionality.

## Diagram (Mermaid)

```mermaid
%%{init: {'theme': 'neutral', 'themeVariables': { 'fontSize': '16px'}}}%%
flowchart TB
    subgraph Legend
        A[Core Component]:::core
        B[(Data Store)]:::data
        C{Model Component}:::model
        D[[External Integration]]:::external
        E[/Critical Component/]:::critical
    end

    subgraph Core["Core Processing Layer"]
        LIB[Library Management]:::core
        MOD[Model Catalog]:::core
        EMB[Embedding System]:::core
        RET[Retrieval System]:::core
        PRM[Prompt Management]:::core
        AGT[Agent System]:::core
        PRS[Parser System]:::core
    end

    subgraph Data["Data Store Layer"]
        direction TB
        MONGO[(MongoDB)]:::data
        PSQL[(PostgreSQL)]:::data
        SQLITE[(SQLite)]:::data
        VECT[(Vector DBs)]:::data
        FILES[(File Storage)]:::data
    end

    subgraph Models["Model Layer"]
        SLIM{SLIM Models}:::model
        DRAGON{DRAGON Models}:::model
        BLING{BLING Models}:::model
        BERT{Industry BERT}:::model
        EXT[[External Models]]:::external
    end

    subgraph Infrastructure["Infrastructure Layer"]
        DOCKER[Docker Support]:::core
        GPU[GPU Processing]:::core
        CPU[CPU Processing]:::core
        API[API Services]:::core
    end

    %% Data Flow Relationships
    PRS --> LIB
    LIB --> EMB
    EMB --> VECT
    EMB --> |Text Storage| MONGO
    EMB --> |Text Storage| PSQL
    EMB --> |Text Storage| SQLITE

    %% Query Flow
    RET --> VECT
    RET --> MONGO
    RET --> PSQL
    RET --> SQLITE
    RET --> PRM
    PRM --> |Model Selection| MOD
    MOD --> |Function Calls| SLIM
    MOD --> DRAGON
    MOD --> BLING
    MOD --> BERT
    MOD --> EXT

    %% Agent Workflow
    AGT --> |Function Execution| SLIM
    AGT --> |Data Access| RET
    AGT --> |Response Generation| PRM

    %% Infrastructure Connections
    DOCKER --- GPU
    DOCKER --- CPU
    API --- AGT

    %% Styling
    classDef core fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef data fill:#90EE90,stroke:#333,stroke-width:2px
    classDef model fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef critical fill:#FFB6C1,stroke:#333,stroke-width:2px

    %% Click Events
    click LIB "https://github.com/llmware-ai/llmware/blob/main/llmware/library.py"
    click MOD "https://github.com/llmware-ai/llmware/blob/main/llmware/models.py"
    click EMB "https://github.com/llmware-ai/llmware/blob/main/llmware/embeddings.py"
    click RET "https://github.com/llmware-ai/llmware/blob/main/llmware/retrieval.py"
    click PRM "https://github.com/llmware-ai/llmware/blob/main/llmware/prompts.py"
    click AGT "https://github.com/llmware-ai/llmware/blob/main/llmware/agents.py"
    click PRS "https://github.com/llmware-ai/llmware/blob/main/llmware/parsers.py"
    click SLIM "https://github.com/llmware-ai/llmware/tree/main/examples/SLIM-Agents/"
    click VECT "https://github.com/llmware-ai/llmware/tree/main/examples/Embedding/"
    click API "https://github.com/llmware-ai/llmware/blob/main/llmware/web_services.py"
```
