# carvilsi/gruphst architecture

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

- Interactive diagram: https://gitdiagram.com/carvilsi/gruphst
- Repository: https://github.com/carvilsi/gruphst

## Overview

##### Main Components

a) Core Components:
- Graph Storage Engine (in-memory)
- Persistence Layer
- Query Engine
- Import/Export System
- Configuration Manager
- Logging System
- Cryptography Module

b) Data Structures:
- Vertices
- Edges
- Attributes
- Graphs Collection

**┌─ Client Interface Layer ─────────────────────────────────┐**

- Public API (lib.rs)                                    │

- Core Processing Layer ──────────────────────────────────┤

- ┌─ Graph Engine ─┐  ┌─ Query Engine ┐  ┌─ Stats ─┐    │
- Vertex Management│ │ Edge Queries  │  │ Memory  │    │
- Edge Management │ │ Vertex Queries│  │ Metrics │    │
- ┘  └──────────────┘  └────────┘     │

- Storage Layer ───────────────────────────────────────┤

- ┌─ In-Memory Store ┐  ┌─ Persistence ┐               │
- Graphs Vault    │  │ File Storage │               │
- Index Manager   │  │ CSV Handler  │               │
- ┘  └─────────────┘               │

- Support Services Layer ─────────────────────────────────┤

- ┌─ Configuration ┐  ┌─ Logging ┐  ┌─ Cryptography ┐   │
- ENV Variables  │  │ Levels   │  │ Argon2 Hash   │   │
- Memory Limits  │  │ Output   │  │ Verification  │   │
- ┘  └─────────┘  └──────────────┘   │

- ┘

##### Important Relationships to Highlight

- How the Graph Engine interacts with the In-Memory Store
- Relationship between Query Engine and Graph Engine
- Demonstrate how Persistence Layer connects to both In-Memory Store and File Storage
- Configuration Manager's influence on all components
- How Logging System monitors all operations

##### Implementation Details

- src/graphs/ - Core graph operations
- src/vertex/ - Vertex management
- src/edge/ - Edge management
- src/config/ - Configuration handling
- src/logger/ - Logging functionality
- src/exporter_importer/ - Data import/export

##### Additional Notes

- Notes about configurable elements (CSV delimiter, log levels, memory limits)
- Error handling paths
- Test coverage points

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Interface Layer
    subgraph ClientLayer
        API["Public API"]:::api
    end

    %% Core Processing Layer
    subgraph CoreLayer
        subgraph GraphEngine
            VM["Vertex Management"]:::core
            EM["Edge Management"]:::core
        end

        subgraph QueryEngine
            EQ["Edge Queries"]:::core
            VQ["Vertex Queries"]:::core
        end

        subgraph Stats
            MM["Memory Metrics"]:::core
            PM["Performance Stats"]:::core
        end
    end

    %% Storage Layer
    subgraph StorageLayer
        subgraph InMemoryStore
            GV["Graphs Vault"]:::storage
            IM["Index Manager"]:::storage
        end

        subgraph Persistence
            FS["File Storage"]:::storage
            CSV["CSV Handler"]:::storage
        end
    end

    %% Support Services Layer
    subgraph SupportLayer
        subgraph Config
            ENV["ENV Variables"]:::support
            ML["Memory Limits"]:::support
        end

        subgraph Logging
            LL["Log Levels"]:::support
            LO["Log Output"]:::support
        end

        subgraph Crypto
            AH["Argon2 Hash"]:::support
            VF["Verification"]:::support
        end
    end

    %% Relationships
    API --> GraphEngine
    API --> QueryEngine
    GraphEngine <--> InMemoryStore
    QueryEngine --> GraphEngine
    InMemoryStore <--> Persistence
    Stats -.-> InMemoryStore
    Config --> InMemoryStore
    Logging -.-> GraphEngine
    Logging -.-> QueryEngine
    Logging -.-> InMemoryStore
    Crypto --> VM

    %% Click Events
    click API "https://github.com/carvilsi/gruphst/blob/main/src/lib.rs"
    click VM "https://github.com/carvilsi/gruphst/blob/main/src/vertex/mod.rs"
    click EM "https://github.com/carvilsi/gruphst/blob/main/src/edge/mod.rs"
    click EQ "https://github.com/carvilsi/gruphst/tree/main/src/edge/queries"
    click VQ "https://github.com/carvilsi/gruphst/blob/main/src/vertex/query.rs"
    click GV "https://github.com/carvilsi/gruphst/blob/main/src/graphs/mod.rs"
    click FS "https://github.com/carvilsi/gruphst/blob/main/src/graphs/persistence.rs"
    click CSV "https://github.com/carvilsi/gruphst/blob/main/src/exporter_importer/csv/csv_handlers.rs"
    click Config "https://github.com/carvilsi/gruphst/blob/main/src/config/mod.rs"
    click Logging "https://github.com/carvilsi/gruphst/blob/main/src/logger/mod.rs"
    click Crypto "https://github.com/carvilsi/gruphst/blob/main/src/vertex/cryptography.rs"
    click Stats "https://github.com/carvilsi/gruphst/blob/main/src/graphs/stats.rs"

    %% Styles
    classDef api fill:#9932CC,stroke:#333,stroke-width:2px
    classDef core fill:#3498DB,stroke:#333,stroke-width:2px
    classDef storage fill:#2ECC71,stroke:#333,stroke-width:2px
    classDef support fill:#F1C40F,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["Client Interface"]:::api
        L2["Core Processing"]:::core
        L3["Storage"]:::storage
        L4["Support Services"]:::support
    end
```
