# elzai/memora architecture

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

- Interactive diagram: https://gitdiagram.com/elzai/memora
- Repository: https://github.com/elzai/memora

## Overview

##### Main Components

a) Core Components:
- Memora Core Service
- Vector Database (Qdrant)
- Graph Database (Neo4j)
- LLM Provider Services (OpenAI, Azure OpenAI, Together AI, Groq)

b) Key Modules:
- Agent Module
- Graph DB Module
- Vector DB Module
- LLM Backends Module
- Prompts Module
- Schema Module

**┌─ Client Applications ─────────────────────────────────────┐**

- ┬───────────────────────────────────┘
- ↓
**┌─ Memora Core ────────────────────────────────────────────┐**
- ┌─ Agent Layer ─┐  ┌─ Memory Management ─┐             │
- ←┼──┤                     │             │
- ┘  └─────────┬───────────┘             │
- ↓                          │
- ┌─ Database Abstraction Layer ─────────────────────┐   │
- ┌─ Vector DB ─┐    ┌─ Graph DB ─┐             │   │
- Module    │    │   Module   │             │   │
- ┘    └───────────┘             │   │
- ┘   │

- ┌─ LLM Integration Layer ──────────────────────┐    │
- ┌─ Backend ─┐    ┌─ Prompts ─┐             │    │
- Module   │    │  Module   │             │    │
- ┘  └───────────┘             │    │
- ┘   │
- ┘
- ↓
**┌─ External Services ──────────────────────────────────────┐**
- ┌─ Qdrant ─┐  ┌─ Neo4j ─┐  ┌─ LLM Providers ─┐        │
- OpenAI         │        │
- Azure OpenAI   │        │
- Together AI    │        │
- Groq          │        │
- ┘  └─────────┘  └────────────────┘         │
- ┘

##### Component Details

a) Memory Management:
- Memory Extraction
- Memory Storage
- Memory Search
- Memory Filtering

b) Database Interactions:
- Vector Storage (Qdrant)
- Graph Storage (Neo4j)
- Memory Search Scope

c) LLM Integration:
- Multiple Backend Support
- Prompt Management
- Extraction Schema
- Search Schema

##### Important Relationships to Highlight

- How the Agent Module interfaces with both Vector and Graph databases
- Memory flow from extraction to storage
- Demonstrate how search queries are processed through both databases
- Interaction between LLM backends and memory management

##### Additional Elements

- Version compatibility information
- Scaling capabilities
- Multi-tenancy support through organization/user/agent relationships

##### Technical Details

- Supported Python versions
- Database version requirements
- Supported LLM models
- Async operation support

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        CA[Client Applications]
    end

    subgraph MemoraCore[Memora Core Service]
        click MemoraCore "https://github.com/ELZAI/memora/tree/main//memora/"
        
        subgraph AgentLayer[Agent Layer]
            AM[Agent Module]
            click AM "https://github.com/ELZAI/memora/blob/main//memora/agent/main.py"
            ANI[Agent-Neo4j Integration]
            click ANI "https://github.com/ELZAI/memora/blob/main//memora/graph_db/neo4j/agent.py"
        end

        subgraph MemoryMgmt[Memory Management]
            ME[Memory Extraction]
            click ME "https://github.com/ELZAI/memora/blob/main//memora/prompts/memory_extraction.py"
            MS[Memory Search]
            click MS "https://github.com/ELZAI/memora/blob/main//memora/prompts/memory_search_from_msg.py"
            MF[Memory Filtering]
            click MF "https://github.com/ELZAI/memora/blob/main//memora/prompts/filter_retrieved_memories.py"
        end

        subgraph DBLayer[Database Abstraction Layer]
            VDM[Vector DB Module]
            click VDM "https://github.com/ELZAI/memora/tree/main//memora/vector_db/"
            GDM[Graph DB Module]
            click GDM "https://github.com/ELZAI/memora/tree/main//memora/graph_db/"
        end

        subgraph LLMLayer[LLM Integration Layer]
            LLMB[LLM Backends Module]
            click LLMB "https://github.com/ELZAI/memora/blob/main//memora/llm_backends/base.py"
            PM[Prompts Module]
        end
    end

    subgraph ExternalServices[External Services]
        subgraph VectorDB[Vector Database]
            QD[Qdrant]
            click QD "https://github.com/ELZAI/memora/blob/main//memora/vector_db/qdrant.py"
        end

        subgraph GraphDB[Graph Database]
            Neo4j[Neo4j]
            click Neo4j "https://github.com/ELZAI/memora/blob/main//memora/graph_db/neo4j/interface.py"
        end

        subgraph LLMProviders[LLM Providers]
            OpenAI[OpenAI]
            click OpenAI "https://github.com/ELZAI/memora/blob/main//memora/llm_backends/openai_backend_llm.py"
            AzureOpenAI[Azure OpenAI]
            click AzureOpenAI "https://github.com/ELZAI/memora/blob/main//memora/llm_backends/azure_openai_backend_llm.py"
            TogetherAI[Together AI]
            click TogetherAI "https://github.com/ELZAI/memora/blob/main//memora/llm_backends/together_backend_llm.py"
            Groq[Groq]
            click Groq "https://github.com/ELZAI/memora/blob/main//memora/llm_backends/groq_backend_llm.py"
        end
    end

    CA --> AM
    AM --> ME
    AM --> MS
    AM --> MF
    ME --> VDM
    ME --> GDM
    MS --> VDM
    MS --> GDM
    MF --> VDM
    MF --> GDM
    VDM --> QD
    GDM --> Neo4j
    ME --> LLMB
    MS --> LLMB
    MF --> LLMB
    LLMB --> OpenAI
    LLMB --> AzureOpenAI
    LLMB --> TogetherAI
    LLMB --> Groq
    AM --> ANI
    ANI --> Neo4j

    classDef core fill:#a8d1ff
    classDef agent fill:#e6b3ff
    classDef db fill:#90EE90
    classDef llm fill:#ffb366
    classDef external fill:#f2f2f2

    class MemoraCore,MemoryMgmt,DBLayer,LLMLayer core
    class AgentLayer,AM,ANI agent
    class VDM,GDM,QD,Neo4j db
    class LLMB,OpenAI,AzureOpenAI,TogetherAI,Groq llm
    class ExternalServices,VectorDB,GraphDB,LLMProviders external
```
