# fardust/echo-memory-weaver architecture

> Architecture diagram of the GitHub repository fardust/echo-memory-weaver, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fardust/echo-memory-weaver
- Repository: https://github.com/fardust/echo-memory-weaver

## Overview

##### Main Components Identification
- API Server: Represented by the “app/server.py” file. This is the entry point that ties together incoming requests, routes them to dynamic components, and serves as the orchestration layer.
- Chat Models Module: Under “app/chat_models” you have modules such as “base.py”. This component is responsible for abstracting or controlling the different language models (e.g., handling chat functionality).
- Embeddings Module: Located under “app/embeddings”, it includes logic to create or manage text embeddings.
- Prompts Module: Found in “app/prompts”. It contains several subdirectories – notably “notes” with “sentiments” and “summarization” scripts – to define and process various prompt templates, sentiment analysis, evaluation, and parsing workflows.
- Tools Module: Within “app/tools”, crucial files such as “light_rag.py”, “nano_graph_rag.py”, and “sentiments_parser” exist. They implement additional functionalities (for example, different Retrieval-Augmented Generation techniques and parsing logic).
- VectorStores Module: Under “app/vectorstores”, this encapsulates different vector store implementations (e.g., the “nano_graphrag” integration with LangChain).
- External Integration: Although not part of internal code, the README highlights the use of LangChain CLI, LangSmith for tracing/debugging, and environment variables (like OPENAI_API_KEY) which indicate integration with external APIs or cloud-based services.
- Deployment Components: Include Dockerfile and docker-compose.yml – these represent containerization and deployment configurations.

##### Relationships and Interactions
- The API Server serves as the central hub that receives client requests. From here, messages flow:
- To the Chat Models module for processing language-based queries.
- To the Prompts module where request-specific instructions (sentiment analysis, summarization) are prepared.
- To the Embeddings module to convert text into vectors when performing similarity searches.
- To the Tools module, which might perform additional functionality (e.g., leveraging different RAG techniques).
- To the VectorStores module wherein responses are supplemented with stored vector data.
- External integrations (via environment variables and LangChain CLI commands) allow dynamic addition of packages and real-time tracing/debugging using LangSmith.
- Docker configurations encapsulate the entire application, illustrating how it can be deployed in a containerized environment.

##### Architectural Patterns & Design Principles
- Modularity: Each folder (chat_models, embeddings, prompts, tools, vectorstores) represents a distinct module or layer. This separation of concerns should be visually indicated.
- Containerization: The Dockerfile and docker-compose indicate that deployment is encapsulated in Docker, which should be shown as a deployment boundary.
- Integration with External Services: Environment variables and LangSmith indicate connectivity and data flow to/from external endpoints (APIs for language models or monitoring).

## Diagram (Mermaid)

```mermaid
graph TD
  subgraph "Docker Container"
    client("Client Request/Interface"):::internal
    api_server("API Server (app/server.py)"):::internal
    chat_models("Chat Models (app/chat_models)"):::internal
    embeddings("Embeddings (app/embeddings)"):::internal
    prompts("Prompts (app/prompts)"):::internal
    tools("Tools (app/tools)"):::internal
    vectorstores("VectorStores (app/vectorstores/nano_graphrag)"):::internal
    dockerfile("Dockerfile"):::deployment
    docker_compose("docker-compose.yml"):::deployment

    client -->|"request"| api_server
    api_server -->|"routesTo"| chat_models
    api_server -->|"routesTo"| embeddings
    api_server -->|"routesTo"| prompts
    api_server -->|"routesTo"| tools
    api_server -->|"routesTo"| vectorstores

    embeddings -->|"vectorSearch"| vectorstores

    subgraph "Prompts Module"
      sentiments("Sentiments (app/prompts/notes/sentiments)"):::internal
      summarization("Summarization (app/prompts/notes/summarization.py)"):::internal
    end
    prompts --> sentiments
    prompts --> summarization

    subgraph "Tools Module"
      light_rag("Light RAG (app/tools/light_rag.py)"):::internal
      nano_graph_rag("Nano Graph RAG (app/tools/nano_graph_rag.py)"):::internal
      sentiments_parser("Sentiments Parser (app/tools/sentiments_parser)"):::internal
      text_ingestor("Text Ingestor (app/tools/text_ingestor.py)"):::internal
    end
    tools --> light_rag
    tools --> nano_graph_rag
    tools --> sentiments_parser
    tools --> text_ingestor
  end

  langchain_cli("LangChain CLI"):::external
  langsmith("LangSmith"):::external
  openai_api("OpenAI API"):::external

  api_server -->|"managePackages"| langchain_cli
  api_server -->|"trace"| langsmith
  api_server -->|"call"| openai_api

  classDef internal fill:#ADD8E6,stroke:#000,stroke-width:1px;
  classDef deployment fill:#D3D3D3,stroke:#000,stroke-width:1px;
  classDef external fill:#FFB6C1,stroke:#000,stroke-width:1px;

  click api_server "https://github.com/fardust/echo-memory-weaver/blob/main/app/server.py"
  click chat_models "https://github.com/fardust/echo-memory-weaver/blob/main/app/chat_models/base.py"
  click embeddings "https://github.com/fardust/echo-memory-weaver/blob/main/app/embeddings/base.py"
  click prompts "https://github.com/fardust/echo-memory-weaver/tree/main/app/prompts"
  click sentiments "https://github.com/fardust/echo-memory-weaver/tree/main/app/prompts/notes/sentiments"
  click summarization "https://github.com/fardust/echo-memory-weaver/blob/main/app/prompts/notes/summarization.py"
  click light_rag "https://github.com/fardust/echo-memory-weaver/blob/main/app/tools/light_rag.py"
  click nano_graph_rag "https://github.com/fardust/echo-memory-weaver/blob/main/app/tools/nano_graph_rag.py"
  click sentiments_parser "https://github.com/fardust/echo-memory-weaver/tree/main/app/tools/sentiments_parser"
  click text_ingestor "https://github.com/fardust/echo-memory-weaver/blob/main/app/tools/text_ingestor.py"
  click vectorstores "https://github.com/fardust/echo-memory-weaver/tree/main/app/vectorstores/nano_graphrag"
  click dockerfile "https://github.com/fardust/echo-memory-weaver/tree/main/Dockerfile"
  click docker_compose "https://github.com/fardust/echo-memory-weaver/blob/main/docker-compose.yml"
```
