# voodooentity/gits architecture

> Architecture diagram of the GitHub repository voodooentity/gits, 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/voodooentity/gits
- Repository: https://github.com/voodooentity/gits

## Overview

##### Main Components

a) Core Storage Layer:
- Entity Storage (for storing nodes/vertices)
- Relation Storage (for storing edges)
- Index Management
- Mutex Handler (for thread safety)

b) API Layers (represent as separate layers):
- High-level Query Interface
- Storage API (direct access)
- Data Mapping Interface

##### Key Architectural Elements

**[Client Application]**
- ↓
**[GITS Instance Factory]**
- ↓
**┌─────────────────────┐**
- Query Builder     │
- Interface        │
- ┘
- ↓
**┌─────────────────────┐**
- Storage Engine    │
- ┤
- Entity Storage    │
- Relation Storage  │
- Indexes           │
- Mutex Handler     │
- ┘

##### Important Relationships

a) Instance Management:
- How multiple instances can be created
- Default instance relationship

b) Data Flow:
- Flow from query builder to storage engine
- Mutex handling points
- Relationship mapping paths

##### Technical Details

- Transport Entity structure
- Relation structure
- Query builder flow
- Storage API access points

##### Implementation Notes

- The in-memory nature of the storage
- Thread-safe access patterns
- The graph structure (nodes/edges)
- Multiple instance capability
- Query builder pattern
- Direct storage API access

##### Key Architectural Patterns to Highlight

- Factory pattern for instance creation
- Builder pattern for queries
- Graph data structure
- Thread-safe access patterns

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        CA[Client Application]
        IF[GITS Instance Factory]:::factory
    end

    subgraph "Query Layer"
        QB[Query Builder Interface]:::query
        SA["Storage API"]:::api
    end

    subgraph "Core Storage"
        SE[Storage Engine]:::storage
        subgraph "Storage Components"
            ES[Entity Storage]:::storage
            RS[Relation Storage]:::storage
            IM[Index Management]:::storage
        end
        MH[Mutex Handler]:::mutex
    end

    subgraph "Data Layer"
        TE[Transport Entity]:::data
        DM[Data Mapping]:::data
        DS[Data Structures]:::data
    end

    %% Relationships
    CA --> IF
    IF --> QB
    IF --> SA
    QB --> SE
    SA --> SE
    SE --> ES
    SE --> RS
    SE --> IM
    SE <--> MH
    ES --> TE
    RS --> TE
    TE --> DM
    DM --> DS

    %% Click Events
    click SE "https://github.com/voodooEntity/gits/blob/main/src/storage/storage.go"
    click MH "https://github.com/voodooEntity/gits/blob/main/src/mutexhandler/mutexhandler.go"
    click QB "https://github.com/voodooEntity/gits/blob/main/src/query/query.go"
    click TE "https://github.com/voodooEntity/gits/blob/main/src/transport/transport.go"
    click DS "https://github.com/voodooEntity/gits/blob/main/src/types/types.go"
    click DM "https://github.com/voodooEntity/gits/blob/main/DOCS/DATA_MAPPING.md"
    click SA "https://github.com/voodooEntity/gits/blob/main/DOCS/STORAGE_API.md"
    click IF "https://github.com/voodooEntity/gits/blob/main/DOCS/INSTANCES.md"
    click CA "https://github.com/voodooEntity/gits/blob/main/cmd/examples/examples.go"

    %% Styling
    classDef storage fill:#90EE90,stroke:#333,stroke-width:2px
    classDef mutex fill:#FFD700,stroke:#333,stroke-width:2px
    classDef query fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef api fill:#FF6B6B,stroke:#333,stroke-width:2px
    classDef data fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef factory fill:#F0E68C,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1[Storage Component]:::storage
        L2[Mutex Handler]:::mutex
        L3[Query Interface]:::query
        L4[API Component]:::api
        L5[Data Component]:::data
        L6[Factory Component]:::factory
    end
```
