# patterns-ai-core/langchainrb architecture

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

- Interactive diagram: https://gitdiagram.com/patterns-ai-core/langchainrb
- Repository: https://github.com/patterns-ai-core/langchainrb

## Overview

##### Core Components Layer
- Create distinct sections for the following major components:
a. LLM Interface (lib/langchain/llm/)
b. Prompt Management (lib/langchain/prompt/)
c. Vector Search (lib/langchain/vectorsearch/)
d. Assistant Framework (lib/langchain/assistant/)
e. Tools System (lib/langchain/tool/)
f. Evaluation System (lib/langchain/evals/)

##### LLM Providers Layer
- OpenAI
- Anthropic
- Google Gemini
- Mistral AI
- Ollama
- AWS Bedrock
- And others
- To the LLM Interface with standardized interfaces

##### Vector Search Databases Layer
- Chroma
- Pinecone
- Weaviate
- Qdrant
- PGVector
- Others
- To the Vector Search component

##### Tools Integration Layer
- Available tools:
- Calculator
- Database
- File System
- News Retriever
- Weather
- Wikipedia
- Custom Tools Interface

##### Data Processing Pipeline
- Following components:
- Chunkers (lib/langchain/chunker/)
- Processors (lib/langchain/processors/)
- Output Parsers (lib/langchain/output_parsers/)

##### Key Workflows
a. RAG Pipeline:
- Document Input → Processors → Chunkers → Vector Storage → Retrieval → LLM
b. Assistant Pipeline:
- User Input → Assistant → Tools → LLM → Response
c. Evaluation Pipeline:
- Results → Evals → Metrics

##### Integration Points
- External API connections
- File system interactions
- Database connections

Use the following visual elements:
- Rectangles for core modules
- Hexagons for LLM providers
- Rounded rectangles for tools
- Blue for core components
- Green for external integrations
- Yellow for processing components
- Purple for evaluation components

Important Implementation Details to Include:
##### Demonstrate how the evaluation system integrates with other components

- Version information and key dependencies
- Required external services

Remember to include notes about:
- Configuration requirements
- Key dependencies
- Extension points
- Error handling flows
- Logging system integration

This will provide a complete picture of how the various components interact while maintaining clarity about the system's architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        L1[Core Component]:::core
        L2[LLM Provider]:::llm
        L3[(Vector Database)]:::db
        L4([Tool]):::tool
        L5[Processing Component]:::processing
        L6[Evaluation Component]:::eval
        style Legend fill:#f5f5f5,stroke:#333
    end

    subgraph "LLM Providers"
        OpenAI[OpenAI]:::llm
        Anthropic[Anthropic]:::llm
        Gemini[Google Gemini]:::llm
        Mistral[Mistral AI]:::llm
        Ollama[Ollama]:::llm
        Bedrock[AWS Bedrock]:::llm
    end

    subgraph "Core System"
        LLMInterface[LLM Interface]:::core
        click LLMInterface "https://github.com/patterns-ai-core/langchainrb/tree/main/lib/langchain/llm/"
        
        PromptMgmt[Prompt Management]:::core
        click PromptMgmt "https://github.com/patterns-ai-core/langchainrb/tree/main/lib/langchain/prompt/"
        
        VectorSearch[Vector Search]:::core
        click VectorSearch "https://github.com/patterns-ai-core/langchainrb/tree/main/lib/langchain/vectorsearch/"
        
        Assistant[Assistant Framework]:::core
        click Assistant "https://github.com/patterns-ai-core/langchainrb/tree/main/lib/langchain/assistant/"
        
        Tools[Tools System]:::core
        click Tools "https://github.com/patterns-ai-core/langchainrb/tree/main/lib/langchain/tool/"
        
        Evals[Evaluation System]:::core
        click Evals "https://github.com/patterns-ai-core/langchainrb/tree/main/lib/langchain/evals/"
        
        Config[Core Configuration]:::core
        click Config "https://github.com/patterns-ai-core/langchainrb/blob/main/lib/langchain.rb"
    end

    subgraph "Vector Databases"
        Chroma[(Chroma)]:::db
        Pinecone[(Pinecone)]:::db
        Weaviate[(Weaviate)]:::db
        Qdrant[(Qdrant)]:::db
        PGVector[(PGVector)]:::db
    end

    subgraph "Tools"
        Calculator([Calculator]):::tool
        Database([Database]):::tool
        FileSystem([File System]):::tool
        Weather([Weather]):::tool
        Wikipedia([Wikipedia]):::tool
    end

    subgraph "Data Processing"
        Chunkers[Chunkers]:::processing
        click Chunkers "https://github.com/patterns-ai-core/langchainrb/tree/main/lib/langchain/chunker/"
        
        Processors[Processors]:::processing
        click Processors "https://github.com/patterns-ai-core/langchainrb/tree/main/lib/langchain/processors/"
        
        OutputParsers[Output Parsers]:::processing
        click OutputParsers "https://github.com/patterns-ai-core/langchainrb/tree/main/lib/langchain/output_parsers/"
        
        ResponseHandlers[Response Handlers]:::processing
        click ResponseHandlers "https://github.com/patterns-ai-core/langchainrb/tree/main/lib/langchain/llm/response/"
        
        Utils[Utilities]:::processing
        click Utils "https://github.com/patterns-ai-core/langchainrb/tree/main/lib/langchain/utils/"
    end

    OpenAI & Anthropic & Gemini & Mistral & Ollama & Bedrock --> LLMInterface
    LLMInterface --> Config
    PromptMgmt --> Config
    VectorSearch --> Config
    Assistant --> Config
    Tools --> Config
    Evals --> Config

    Chroma & Pinecone & Weaviate & Qdrant & PGVector --> VectorSearch
    Calculator & Database & FileSystem & Weather & Wikipedia --> Tools

    Chunkers --> VectorSearch
    Processors --> VectorSearch
    OutputParsers --> LLMInterface
    ResponseHandlers --> LLMInterface
    Utils --> Config

    classDef core fill:#4a90e2,stroke:#2e5b99,color:white
    classDef llm fill:#50C878,stroke:#2e8b57,color:white
    classDef db fill:#c7b42c,stroke:#8b7355,color:white
    classDef tool fill:#ff8c00,stroke:#cd6600,color:white
    classDef processing fill:#ba55d3,stroke:#8b2252,color:white
    classDef eval fill:#ff69b4,stroke:#cd3278,color:white
```
