# emagood/datavaultledger architecture

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

- Interactive diagram: https://gitdiagram.com/emagood/datavaultledger
- Repository: https://github.com/emagood/datavaultledger

## Overview

##### Project type and purpose
- This is a single‐repository, full‐stack user‐management application built in Godot Engine 4.3.
- It uses GDScript for both client (front‐client) and server (back-sever) logic.
- Networking is handled via ENet (Thot-p2p), plain TCP and WebSocket transports.
- It provides CRUD operations on user records, credential verification, in-memory caching, file‐based persistence and a change‐history log.

##### File structure
- Top level:
- back‐sever/ – server‐side scenes and scripts
- front-client/ – UI scenes for user interaction
- class/ – core domain scripts (User, UserSearcher, UserArrayManager, ChangeHistory, etc.)
- lib/ – third‐party or shared libraries (bit‐wise utilities, compression, ENet/TCP/WebSocket wrappers, NVR file editor, DB tooling)
- data files (users.dat, history.dat, private_key.rsa, public_key.rsa, etc.)
- project.godot & .godot/ – Godot project settings and caches
- Key patterns:
- MVC‐style separation (Scenes in front‐client/back‐sever are View layers; class/ contains Controllers/Models)
- Monolithic server application inside Godot using GDScript modules
- File-based “database” with custom block reader/writer, optional AES encryption and compression

##### README for additional insights
- Confirms feature set: create, modify, delete users, authentication guard, cache sub‐system, history logging.
- Lists main scripts: User, UserSearcher, UserArrayManager, ChangeHistory.
- Mentions ENet, TCP and WebSocket transports under the Thot-p2p umbrella.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        FC1("interfaz.tscn"):::presentation
        FC2("registre.tscn"):::presentation
        FC3("hash_user.gd"):::presentation
        FC4("hash_user.tscn"):::presentation
    end

    %% Network Transport Layer
    subgraph "Network Transport Layer"
        direction TB
        ENetC("ENet Client (ClientCustom.gd)"):::network
        ENetS("ENet Server (ServerCustom.gd)"):::network
        TCP("TCP Transport (client.gd)"):::network
        WS("WebSocket Transport (cliente.gd)"):::network
    end

    %% Server Application
    subgraph "Server Application"
        direction TB
        SS1("elserver.tscn / elserver.gd"):::presentation
        SS2("log.tscn / log.gd"):::presentation
        SS3("dbscript.gd"):::presentation
        SS4("rsas.tscn / rsas.gd"):::presentation
        SS5("thread.gd / time_data_ram.tscn"):::presentation
    end

    %% Business Logic Layer
    subgraph "Business Logic"
        direction TB
        BL1("BlockReaderWrite.gd"):::business
        BL2("dbgodot.gd"):::business
        BL3("aes_class.gd"):::security
        BL4("User_tool.gd"):::business
        BL5("code.gd"):::business
        BL6("server_rcp.gd"):::business
    end

    %% Persistence & Cache Layer
    subgraph "Persistence & Cache"
        direction TB
        DB("Flat-file DB (.dat)"):::persistence
        CACHE("In-Memory Cache (UserArrayManager)"):::business
    end

    %% Logging Layer
    subgraph "Logging & History"
        direction TB
        LOG("history.dat"):::persistence
    end

    %% Security Layer
    subgraph "Security"
        direction TB
        RSA("RSA Keypair"):::security
    end

    %% Data Files
    DATA1("users.dat"):::persistence
    DATA2("history.dat"):::persistence
    DATA3("prueba_completa.dat"):::persistence

    %% Connections
    FC1 -->|uses| ENetC
    FC2 -->|uses| ENetC
    FC3 -->|uses| TCP
    FC4 -->|uses| WS

    ENetC -->|sends requests| ENetS
    TCP -->|sends requests| SS1
    WS -->|sends requests| SS1

    ENetS -->|invokes| BL6
    SS1 -->|invokes| BL6
    SS2 -->|invokes| BL6

    BL6 -->|calls| BL4
    BL4 -->|reads/writes| BL1
    BL1 -->|reads/writes| DB
    DB -->|stores| DATA1
    DB -->|stores| DATA2
    DB -->|stores| DATA3

    BL4 -->|updates| CACHE
    BL4 -->|logs changes| LOG
    LOG -->|writes| DATA2

    BL2 -->|searches| DB
    BL3 -->|encrypts/decrypts| DB
    RSA -->|secures| BL3

    %% Response back to client
    BL6 -->|responds| ENetS
    BL6 -->|responds| SS1
    ENetS -->|sends response| ENetC
    SS1 -->|sends response| FC1

    %% Click Events
    click FC1 "https://github.com/emagood/datavaultledger/blob/main/front-client/interfaz.tscn"
    click FC2 "https://github.com/emagood/datavaultledger/blob/main/front-client/registre.tscn"
    click FC3 "https://github.com/emagood/datavaultledger/blob/main/front-client/hash_user.gd"
    click FC4 "https://github.com/emagood/datavaultledger/blob/main/front-client/hash_user.tscn"
    click ENetC "https://github.com/emagood/datavaultledger/blob/main/lib/thot/e_net/cliente/ClientCustom.gd.gd"
    click ENetS "https://github.com/emagood/datavaultledger/blob/main/lib/thot/e_net/servidor/ServerCustom.gd"
    click TCP "https://github.com/emagood/datavaultledger/blob/main/lib/thot/tcp/client.gd"
    click WS "https://github.com/emagood/datavaultledger/blob/main/lib/thot/websocket/cliente.gd"
    click SS1 "https://github.com/emagood/datavaultledger/blob/main/back-sever/escenas/modo_bin/elserver.tscn"
    click SS2 "https://github.com/emagood/datavaultledger/blob/main/back-sever/escenas/modo_bin/log.tscn"
    click SS3 "https://github.com/emagood/datavaultledger/blob/main/back-sever/escenas/script/dbscript.gd"
    click SS4 "https://github.com/emagood/datavaultledger/blob/main/back-sever/rsas.tscn"
    click SS5 "https://github.com/emagood/datavaultledger/blob/main/back-sever/thread.gd"
    click BL1 "https://github.com/emagood/datavaultledger/blob/main/class/BlockReaderWrite.gd"
    click BL2 "https://github.com/emagood/datavaultledger/blob/main/class/dbgodot.gd"
    click BL3 "https://github.com/emagood/datavaultledger/blob/main/class/aes_class.gd"
    click BL4 "https://github.com/emagood/datavaultledger/blob/main/class/User_tool.gd"
    click BL5 "https://github.com/emagood/datavaultledger/blob/main/class/code.gd"
    click BL6 "https://github.com/emagood/datavaultledger/blob/main/class/server_rcp.gd"

    %% Styles
    classDef presentation fill:#E0F7FA,stroke:#0288D1,color:#000
    classDef network fill:#FFE0B2,stroke:#FB8C00,color:#000
    classDef business fill:#C8E6C9,stroke:#388E3C,color:#000
    classDef persistence fill:#FFF9C4,stroke:#FBC02D,color:#000
    classDef security fill:#FFCDD2,stroke:#D32F2F,color:#000
```
