# chemiguel23/memorymesh architecture

> Architecture diagram of the GitHub repository chemiguel23/memorymesh, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chemiguel23/memorymesh
- Repository: https://github.com/chemiguel23/memorymesh

## Overview

##### Main Components Overview
First, let's identify the key architectural layers based on the src directory structure:

a) Core Components:
- Application Layer
- Core Layer
- Infrastructure Layer
- Integration Layer
- Shared Layer

##### Detailed Component Breakdown

a) Top Level (Client Interaction):
- Claude Desktop AI Client
- Memory Viewer Interface
- Schema Manager Interface

b) Integration Layer:
- Tool Registry System
- Dynamic Schema Tools
- Tool Handlers (Base, Dynamic, Graph, Metadata, Search)

c) Application Layer:
- Manager Components:
- ApplicationManager
- GraphManager
- NodeManager
- EdgeManager
- MetadataManager
- SearchManager
- TransactionManager

d) Core Layer:
- Graph Engine:
- Node Management
- Edge Management
- Graph Validation
- Schema System:
- Schema Builder
- Schema Loader
- Schema Processor
- Metadata System:
- Metadata Processor

e) Infrastructure Layer:
- Storage System:
- JSON Line Storage
- Event System:
- Event Emitter
- Event Types

##### Key Relationships to Highlight

a) Data Flow:
- Client requests → Tool Registry → Appropriate Manager → Core Components → Storage
- Schema definitions → Dynamic Tool Generation → Tool Registry
- Event propagation through the system

b) Critical Interactions:
- Schema Manager → Schema System → Dynamic Tool Generation
- Graph Operations → Event System
- Storage System → Memory Viewer

##### Additional Notes

- Version information (v0.2.8)
- File storage locations (dist/data/memory.json, dist/data/schemas)
- Integration points with Claude Desktop
- Relationship with the Memory Viewer and Schema Manager tools

Remember to emphasize the dynamic nature of the tool generation system, as this is a key feature of MemoryMesh that sets it apart from other knowledge graph servers.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph Clients
        Claude["Claude Desktop AI Client"]
        MemViewer["Memory Viewer Interface"]:::client
        SchemaManager["Schema Manager Interface"]:::client
    end

    %% Integration Layer
    subgraph Integration
        ToolRegistry["Tool Registry System"]:::integration
        DynamicTools["Dynamic Schema Tools"]:::integration
        StaticTools["Static Tools"]:::integration
        ToolHandlers["Tool Handlers"]:::integration
    end

    %% Application Layer
    subgraph Application
        AppManager["Application Manager"]:::application
        GraphManager["Graph Manager"]:::application
        NodeManager["Node Manager"]:::application
        EdgeManager["Edge Manager"]:::application
        MetadataManager["Metadata Manager"]:::application
        SearchManager["Search Manager"]:::application
        TransManager["Transaction Manager"]:::application
    end

    %% Core Layer
    subgraph Core
        subgraph GraphEngine
            NodeMgmt["Node Management"]:::core
            EdgeMgmt["Edge Management"]:::core
            GraphValid["Graph Validation"]:::core
            MainGraph["Main Graph"]:::core
        end

        subgraph SchemaSystem
            SchemaBuilder["Schema Builder"]:::core
            SchemaLoader["Schema Loader"]:::core
            SchemaProcessor["Schema Processor"]:::core
        end

        subgraph MetadataSystem
            MetadataComp["Metadata Component"]:::core
            MetadataProc["Metadata Processor"]:::core
        end
    end

    %% Infrastructure Layer
    subgraph Infrastructure
        subgraph Storage
            JsonStorage["JSON Line Storage"]:::infra
            StorageInterface["Storage Interface"]:::infra
        end

        subgraph EventSystem
            EventEmitter["Event Emitter"]:::infra
            EventTypes["Event Types"]:::infra
        end
    end

    %% Relationships
    Claude --> MemViewer & SchemaManager
    MemViewer & SchemaManager --> ToolRegistry
    ToolRegistry --> DynamicTools & StaticTools
    DynamicTools & StaticTools --> ToolHandlers
    ToolHandlers --> AppManager

    AppManager --> |manages| GraphManager & NodeManager & EdgeManager & MetadataManager & SearchManager & TransManager
    GraphManager --> GraphEngine
    NodeManager --> NodeMgmt
    EdgeManager --> EdgeMgmt
    MetadataManager --> MetadataSystem
    SearchManager --> MainGraph
    TransManager --> EventSystem

    SchemaManager --> SchemaSystem
    SchemaSystem --> DynamicTools

    GraphEngine --> Storage
    MetadataSystem --> Storage
    Storage --> EventSystem

    %% Styles
    classDef client fill:#3498db
    classDef integration fill:#2ecc71
    classDef application fill:#e67e22
    classDef core fill:#9b59b6
    classDef infra fill:#95a5a6

    %% Click Events
    click MemViewer "https://github.com/CheMiguel23/MemoryMesh/blob/main/MemoryViewer.html"
    click SchemaManager "https://github.com/CheMiguel23/MemoryMesh/blob/main/SchemaManager.html"
    click ToolRegistry "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/integration/tools/DynamicSchemaToolRegistry.ts"
    click DynamicTools "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/integration/tools/registry/dynamicTools.ts"
    click StaticTools "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/integration/tools/registry/staticTools.ts"
    click ToolHandlers "https://github.com/CheMiguel23/MemoryMesh/tree/main/src/integration/tools/handlers"
    click AppManager "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/application/managers/ApplicationManager.ts"
    click GraphManager "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/application/managers/GraphManager.ts"
    click NodeManager "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/application/managers/NodeManager.ts"
    click EdgeManager "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/application/managers/EdgeManager.ts"
    click MetadataManager "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/application/managers/MetadataManager.ts"
    click SearchManager "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/application/managers/SearchManager.ts"
    click TransManager "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/application/managers/TransactionManager.ts"
    click NodeMgmt "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/core/graph/Node.ts"
    click EdgeMgmt "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/core/graph/Edge.ts"
    click GraphValid "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/core/graph/GraphValidator.ts"
    click MainGraph "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/core/graph/Graph.ts"
    click SchemaBuilder "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/core/schema/SchemaBuilder.ts"
    click SchemaLoader "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/core/schema/SchemaLoader.ts"
    click SchemaProcessor "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/core/schema/SchemaProcessor.ts"
    click MetadataComp "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/core/metadata/Metadata.ts"
    click MetadataProc "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/core/metadata/MetadataProcessor.ts"
    click JsonStorage "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/infrastructure/storage/JsonLineStorage.ts"
    click StorageInterface "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/infrastructure/storage/IStorage.ts"
    click EventEmitter "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/infrastructure/events/EventEmitter.ts"
    click EventTypes "https://github.com/CheMiguel23/MemoryMesh/blob/main/src/infrastructure/events/EventTypes.ts"
```
