# oriserveai/orichain architecture

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

- Interactive diagram: https://gitdiagram.com/oriserveai/orichain
- Repository: https://github.com/oriserveai/orichain

## Overview

##### Project type and purpose
- **Type**: This is an open-source Python library (not a full-stack app) designed to simplify Retrieval-Augmented Generation (RAG) workflows.
- **Purpose**: Provide a unified, asynchronous, and hot-swappable interface for:
- Embedding creation across multiple cloud and local providers
- Vector-database knowledge-base interactions
- Invocation of various LLM endpoints
- Optional language detection

##### File structure
- **Top-level**
- `.github/workflows/publish.yml` – CI/CD pipeline for publishing to PyPI
- `docs/` – Sphinx documentation source
- `src/orichain/` – Core library code
- `pyproject.toml` – Build and dependency configuration
- **Core modules under `src/orichain/`**
- `embeddings/` – Provider-specific embedding clients (OpenAI, AWS Bedrock, GCP Vertex, etc.)
- `knowledge_base/` – Vector DB adapters (ChromaDB, Pinecone)
- `lang_detect/` – Language‐detection adapter(s)
- `llm/` – Provider-specific LLM clients (OpenAI, Anthropic, AWS Bedrock, GCP, Azure)
- **Patterns**
- Each subpackage implements a common interface (e.g., AsyncEmbeddingModel delegates to `openai_embeddings.py` when `provider="OpenAI"`)
- Entire codebase is asynchronous and threaded

##### README for additional insights
- Confirms support matrix (providers & features)
- Shows typical usage: a FastAPI app instantiates three high-level classes: `AsyncEmbeddingModel`, `AsyncKnowledgeBase`, `AsyncLLM`
- Emphasizes hot-swappable components and async/threaded design

##### Detailed component breakdown (suggested grouping)
- Layer 1: Client App
- Layer 2: Orichain Core
- Embeddings
– AWSBedrockEmbeddings
– OpenAIEmbeddings
– …
- KnowledgeBase
– PineconeKnowledgeBase
– ChromaDBKnowledgeBase
- LLM
– OpenAI_LLM
– AWSBedrock_LLM
– …
- LangDetect (if used)
- Layer 3: External
- AWS Bedrock API
- OpenAI API
- GCP Vertex/Gemini
- Pinecone DB
- ChromaDB

##### Essentials
- **all** RAG stages as separate components

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    ClientApp["Client Application"]:::external

    %% Orichain Core
    subgraph "Orichain Core"
        subgraph "Embedding Layer"
            AE["AsyncEmbeddingModel"]:::internal
            AWE["AWSBedrockEmbeddings"]:::adapter
            AZE["AzureOpenAIEmbeddings"]:::adapter
            GCG["GCP_GeminiEmbeddings"]:::adapter
            GCV["GCP_VertexEmbeddings"]:::adapter
            OPE["OpenAIEmbeddings"]:::adapter
            STE["STransformersEmbeddings"]:::adapter
        end

        subgraph "Knowledge-Base Layer"
            AKB["AsyncKnowledgeBase"]:::internal
            PKB["PineconeKnowledgeBase"]:::adapter
            CKB["ChromaDBKnowledgeBase"]:::adapter
        end

        subgraph "LLM Layer"
            ALLM["AsyncLLM"]:::internal
            ANP["AnthropicLLM"]:::adapter
            ANB["AnthropicBedrockLLM"]:::adapter
            AWL["AWSBedrockLLM"]:::adapter
            AZL["AzureOpenAI_LLM"]:::adapter
            GGL["GCP_GeminiLLM"]:::adapter
            GVL["GCP_VertexLLM"]:::adapter
            OPL["OpenAILLM"]:::adapter
        end

        subgraph "Language Detection Layer"
            ALD["AsyncLangDetectModel"]:::internal
        end

        subgraph "Documentation"
            ED["orichain.embeddings.rst"]:::documentation
            KD["orichain.knowledge_base.rst"]:::documentation
            LD["orichain.llm.rst"]:::documentation
            MD["orichain.lang_detect.rst"]:::documentation
        end
    end

    %% External Services
    subgraph "External Services"
        OpenAIAPI["OpenAI API"]:::external
        AWSBedrockAPI["AWS Bedrock API"]:::external
        GCPVertexAPI["GCP Vertex API"]:::external
        STAPI["SentenceTransformers"]:::external
        PineconeDB["Pinecone DB"]:::external
        ChromaDB["ChromaDB"]:::external
        AnthropicAPI["Anthropic API"]:::external
        GCPGeminiAPI["GCP Gemini API"]:::external
        AzureOpenAIAPI["Azure OpenAI API"]:::external
        LangDetectSvc["Language Detection Engine"]:::external
    end

    %% Data Flows
    ClientApp -->|"request embedding"| AE
    AE -->|"calls adapter"| AWE
    AE -->|"calls adapter"| AZE
    AE -->|"calls adapter"| GCG
    AE -->|"calls adapter"| GCV
    AE -->|"calls adapter"| OPE
    AE -->|"calls adapter"| STE

    AWE -->|"async I/O"| AWSBedrockAPI
    AZE -->|"async I/O"| OpenAIAPI
    GCG -->|"async I/O"| GCPGeminiAPI
    GCV -->|"async I/O"| GCPVertexAPI
    OPE -->|"async I/O"| OpenAIAPI
    STE -->|"async I/O"| STAPI

    AE -->|"vector output"| AKB
    AKB -->|"calls adapter"| PKB
    AKB -->|"calls adapter"| CKB
    PKB -->|"upsert/query"| PineconeDB
    CKB -->|"upsert/query"| ChromaDB

    AKB -->|"retrieved vectors"| ALLM
    ALLM -->|"calls adapter"| ANP
    ALLM -->|"calls adapter"| ANB
    ALLM -->|"calls adapter"| AWL
    ALLM -->|"calls adapter"| AZL
    ALLM -->|"calls adapter"| GGL
    ALLM -->|"calls adapter"| GVL
    ALLM -->|"calls adapter"| OPL

    ANP -->|"completion/stream"| AnthropicAPI
    ANB -->|"completion/stream"| AWSBedrockAPI
    AWL -->|"completion/stream"| AWSBedrockAPI
    AZL -->|"completion/stream"| AzureOpenAIAPI
    GGL -->|"completion/stream"| GCPGeminiAPI
    GVL -->|"completion/stream"| GCPVertexAPI
    OPL -->|"completion/stream"| OpenAIAPI

    ClientApp -->|"optional detect"| ALD
    ALD -->|"detect"| LangDetectSvc

    %% Click Events - Embedding Layer
    click AE "https://github.com/oriserveai/orichain/blob/main/src/orichain/embeddings/__init__.py"
    click AWE "https://github.com/oriserveai/orichain/blob/main/src/orichain/embeddings/awsbedrock_embeddings.py"
    click AZE "https://github.com/oriserveai/orichain/blob/main/src/orichain/embeddings/azureopenai_embeddings.py"
    click GCG "https://github.com/oriserveai/orichain/blob/main/src/orichain/embeddings/gcp_gemini_embeddings.py"
    click GCV "https://github.com/oriserveai/orichain/blob/main/src/orichain/embeddings/gcp_vertex_embeddings.py"
    click OPE "https://github.com/oriserveai/orichain/blob/main/src/orichain/embeddings/openai_embeddings.py"
    click STE "https://github.com/oriserveai/orichain/blob/main/src/orichain/embeddings/stransformers_embeddings.py"
    click AWE "https://github.com/oriserveai/orichain/tree/main/src/orichain/embeddings/"
    
    %% Click Events - Knowledge Base Layer
    click AKB "https://github.com/oriserveai/orichain/blob/main/src/orichain/knowledge_base/__init__.py"
    click PKB "https://github.com/oriserveai/orichain/blob/main/src/orichain/knowledge_base/pinecone_knowledgbase.py"
    click CKB "https://github.com/oriserveai/orichain/blob/main/src/orichain/knowledge_base/chromadb_knowledgebase.py"
    click AKB "https://github.com/oriserveai/orichain/tree/main/src/orichain/knowledge_base/"

    %% Click Events - LLM Layer
    click ALLM "https://github.com/oriserveai/orichain/blob/main/src/orichain/llm/__init__.py"
    click ANP "https://github.com/oriserveai/orichain/blob/main/src/orichain/llm/anthropic_llm.py"
    click ANB "https://github.com/oriserveai/orichain/blob/main/src/orichain/llm/anthropicbedrock_llm.py"
    click AWL "https://github.com/oriserveai/orichain/blob/main/src/orichain/llm/awsbedrock_llm.py"
    click AZL "https://github.com/oriserveai/orichain/blob/main/src/orichain/llm/azureopenai_llm.py"
    click GGL "https://github.com/oriserveai/orichain/blob/main/src/orichain/llm/gcp_gemini_llm.py"
    click GVL "https://github.com/oriserveai/orichain/blob/main/src/orichain/llm/gcp_vertex_llm.py"
    click OPL "https://github.com/oriserveai/orichain/blob/main/src/orichain/llm/openai_llm.py"
    click ALLM "https://github.com/oriserveai/orichain/tree/main/src/orichain/llm/"

    %% Click Events - Language Detection Layer
    click ALD "https://github.com/oriserveai/orichain/blob/main/src/orichain/lang_detect/__init__.py"
    click ALD "https://github.com/oriserveai/orichain/tree/main/src/orichain/lang_detect/"

    %% Click Events - Core Entry Points
    click CoreInit "https://github.com/oriserveai/orichain/blob/main/src/orichain/__init__.py"

    %% Click Events - Documentation
    click ED "https://github.com/oriserveai/orichain/blob/main/docs/source/orichain.embeddings.rst"
    click KD "https://github.com/oriserveai/orichain/blob/main/docs/source/orichain.knowledge_base.rst"
    click LD "https://github.com/oriserveai/orichain/blob/main/docs/source/orichain.llm.rst"
    click MD "https://github.com/oriserveai/orichain/blob/main/docs/source/orichain.lang_detect.rst"

    %% Styles
    classDef internal fill:#E8F1FC,stroke:#0366d6
    classDef external fill:#E9F7EF,stroke:#2E7D32
    classDef adapter fill:#FFF3CD,stroke:#FF8F00,stroke-dasharray:5,5
    classDef documentation fill:#F3E5F5,stroke:#6A1B9A
```
