# gobblergang/cplusplusclient architecture

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

- Interactive diagram: https://gitdiagram.com/gobblergang/cplusplusclient
- Repository: https://github.com/gobblergang/cplusplusclient

## Overview

##### Project type and purpose
- This is a C++-based Qt desktop client for secure vault management. It provides a GUI (Qt 6) through which users authenticate, manage encrypted vaults, store metadata in a local SQLite database, perform cryptographic operations (via OpenSSL, Argon2, Ed25519/X25519, etc.), and communicate with a remote server over HTTPS.

##### File structure
- Top-level:
- CMakeLists.txt, vcpkg files → build and dependency configuration
- main.cpp, UI.cpp → application entry point and Qt UI glue
- templates/FileOperationHandlers.hpp → generic handlers for file-based operations
- include/
- database/ → ORM schema, models.h, db_instance.h (using sqlite_orm)
- nlohmann/json.hpp → JSON parsing
- utils/ → Config, CryptoUtils, key classes (Ed25519Key, X25519Key, MasterKey, VaultManager), plus dataclasses (PAC, Vault)
- src/
- Auth.cpp/h → authentication flows (Argon2 hashing, login requests)
- DataManager.h → orchestration of data requests between UI, DB, crypto, and server
- FileOperations.cpp → low-level file I/O handlers
- Server.h → REST/HTTP client code to talk to remote server
- src/models/ → domain models (user, keys, PAC, KEK, file)

##### Key insights from README
- Dependencies: Qt 6.4+, OpenSSL, SQLite3, Argon2
- Build: Uses CMake + vcpkg for dependency management
- Configuration:
- local_config.cmake for library paths
- config.json (in build dir) for “server-url”

##### Main components
a. Frontend / UI Layer
- Components: Qt widgets, UI.cpp, main.cpp
- Role: Render views, capture user input, forward commands to application logic
b. Application Logic Layer
- Auth module (Argon2 hashing, login/logout flows)
- DataManager (coordinates DB access, crypto, remote calls)
- FileOperations (local file reads/writes)
c. Crypto Utilities
- Config, CryptoUtils, key management (Ed25519, X25519, MasterKey)
- VaultManager (encrypt/decrypt vault data)
d. Local Persistence Layer
- SQLite database via sqlite_orm
- Schema and models under include/database and src/models
e. Remote Server / Network Layer
- Server.h (HTTP/HTTPS client)
- External service: Remote vault-management API (configured via config.json)
f. External Dependencies
- Qt 6, OpenSSL, Argon2, SQLite3, nlohmann/json

##### Relationships & interactions
- UI → Application Logic (DataManager, Auth, FileOperations)
- Application Logic ↔ Local DB (ORM calls for CRUD on user, keys, vault metadata)
- Application Logic ↔ Crypto Utils (encrypt/decrypt operations, key generation)
- Application Logic ↔ Remote Server (REST API calls over HTTPS)
- FileOperations ↔ Local file system (storing encrypted payloads)

##### Architectural patterns & design principles
- Layered architecture (Presentation, Business Logic, Data, Infrastructure)
- MVC-style separation:
- View: Qt UI
- Controller: DataManager / Auth
- Model: database models + dataclasses
- Repository pattern: sqlite_orm abstracts persistence
- Dependency Injection via CMake + vcpkg toolchain

##### Final checklist for the principal software engineer
- Call out CMake/vcpkg as the build/configuration boundary
- Config.json → Server URL is represented as an external configuration input
- Be detalied: split “utils” into individual crypto/key components, split “database” into schema + models

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        UI_main["main.cpp"]:::frontend
        UI_UI["UI.cpp"]:::frontend
    end

    subgraph "Business Logic Layer"
        subgraph "Auth Module"
            Auth_h["Auth.h"]:::business
            Auth_cpp["Auth.cpp"]:::business
        end
        DataManager_h["DataManager.h"]:::business
        subgraph "File Operations"
            FileOps_cpp["FileOperations.cpp"]:::business
            FileOps_tpl["FileOperationHandlers.hpp"]:::business
        end
    end

    subgraph "Crypto Utilities (Security Enclave)"
        CryptoUtils_h["CryptoUtils.h"]:::crypto
        CryptoUtils_cpp["CryptoUtils.cpp"]:::crypto
        Ed25519_h["Ed25519Key.h"]:::crypto
        Ed25519_cpp["Ed25519Key.cpp"]:::crypto
        X25519_h["X25519Key.h"]:::crypto
        X25519_cpp["X25519Key.cpp"]:::crypto
        MasterKey_h["MasterKey.h"]:::crypto
        MasterKey_cpp["MasterKey.cpp"]:::crypto
        VaultMgr_h["VaultManager.h"]:::crypto
        VaultMgr_cpp["VaultManager.cpp"]:::crypto
        Config_cpp["Config.cpp"]:::crypto
    end

    subgraph "Local Persistence Layer"
        subgraph "ORM & Schema"
            db_instance["db_instance.h"]:::data
            models_h["models.h"]:::data
            schema_h["schema.hpp"]:::data
            sqlite_orm["sqlite_orm.h"]:::data
        end
        subgraph "Domain Models"
            user_h["user.h"]:::data
            keys_h["keys.h"]:::data
            kek_h["kek.h"]:::data
            pac_h["pac.h"]:::data
            file_h["file.h"]:::data
            PAC_dat_h["PAC.h"]:::data
            PAC_dat_cpp["PAC.cpp"]:::data
            Vault_dat_h["Vault.h"]:::data
            Vault_dat_cpp["Vault.cpp"]:::data
        end
    end

    subgraph "Network Layer"
        Server_h["Server.h"]:::network
    end

    subgraph "External Dependencies"
        CMake["CMakeLists.txt"]:::external
        vcpkg_json["vcpkg.json"]:::external
        vcpkg_cfg["vcpkg-configuration.json"]:::external
        Readme["README.md"]:::external
        Config_json["config.json"]:::external
        Qt["Qt 6"]:::external
        OpenSSL["OpenSSL"]:::external
        Argon2["Argon2"]:::external
        SQLite3["SQLite3"]:::external
        JSON_lib["nlohmann/json"]:::external
        RemoteServer["Remote Vault API"]:::external
        FileSystem["Local File System"]:::external
    end

    UI_main -->|calls| DataManager_h
    UI_UI -->|calls| DataManager_h
    UI_main -->|calls| Auth_h
    UI_UI -->|calls| Auth_h
    UI_main -->|calls| FileOps_cpp
    UI_UI -->|calls| FileOps_cpp

    DataManager_h -->|reads/writes| db_instance
    DataManager_h -->|manages| CryptoUtils_h
    DataManager_h -->|sends requests| Server_h
    DataManager_h -->|uses| FileOps_cpp

    Auth_h -->|uses| CryptoUtils_h

    FileOps_cpp -->|I/O on| FileSystem

    CryptoUtils_h -->|uses| VaultMgr_h
    CryptoUtils_h -->|uses| Ed25519_h
    CryptoUtils_h -->|uses| X25519_h
    CryptoUtils_h -->|uses| MasterKey_h
    CryptoUtils_h -->|reads| Config_cpp

    Server_h -->|connects to| RemoteServer
    Server_h -->|config from| Config_json

    classDef frontend fill:#D6EAF8,stroke:#2980B9,color:#1B4F72
    classDef business fill:#D5F5E3,stroke:#27AE60,color:#1E8449
    classDef crypto fill:#FEF9E7,stroke:#F1C40F,color:#B7950B
    classDef data fill:#FDEBD0,stroke:#EB984E,color:#B03A2E
    classDef network fill:#E8F8F5,stroke:#1ABC9C,color:#117A65
    classDef external fill:#F2F3F4,stroke:#CACFD2,color:#566573

    click UI_main "https://github.com/gobblergang/cplusplusclient/blob/main/main.cpp"
    click UI_UI "https://github.com/gobblergang/cplusplusclient/blob/main/UI.cpp"
    click Auth_h "https://github.com/gobblergang/cplusplusclient/blob/main/src/Auth.h"
    click Auth_cpp "https://github.com/gobblergang/cplusplusclient/blob/main/src/Auth.cpp"
    click DataManager_h "https://github.com/gobblergang/cplusplusclient/blob/main/src/DataManager.h"
    click FileOps_cpp "https://github.com/gobblergang/cplusplusclient/blob/main/src/FileOperations.cpp"
    click FileOps_tpl "https://github.com/gobblergang/cplusplusclient/blob/main/templates/FileOperationHandlers.hpp"
    click CryptoUtils_h "https://github.com/gobblergang/cplusplusclient/blob/main/include/utils/CryptoUtils.h"
    click CryptoUtils_cpp "https://github.com/gobblergang/cplusplusclient/blob/main/include/utils/CryptoUtils.cpp"
    click Ed25519_h "https://github.com/gobblergang/cplusplusclient/blob/main/include/utils/Ed25519Key.h"
    click Ed25519_cpp "https://github.com/gobblergang/cplusplusclient/blob/main/include/utils/Ed25519Key.cpp"
    click X25519_h "https://github.com/gobblergang/cplusplusclient/blob/main/include/utils/X25519Key.h"
    click X25519_cpp "https://github.com/gobblergang/cplusplusclient/blob/main/include/utils/X25519Key.cpp"
    click MasterKey_h "https://github.com/gobblergang/cplusplusclient/blob/main/include/utils/MasterKey.h"
    click MasterKey_cpp "https://github.com/gobblergang/cplusplusclient/blob/main/include/utils/MasterKey.cpp"
    click VaultMgr_h "https://github.com/gobblergang/cplusplusclient/blob/main/include/utils/VaultManager.h"
    click VaultMgr_cpp "https://github.com/gobblergang/cplusplusclient/blob/main/include/utils/VaultManager.cpp"
    click Config_cpp "https://github.com/gobblergang/cplusplusclient/blob/main/include/utils/Config.cpp"
    click db_instance "https://github.com/gobblergang/cplusplusclient/blob/main/include/database/db_instance.h"
    click models_h "https://github.com/gobblergang/cplusplusclient/blob/main/include/database/models.h"
    click schema_h "https://github.com/gobblergang/cplusplusclient/blob/main/include/database/schema.hpp"
    click sqlite_orm "https://github.com/gobblergang/cplusplusclient/blob/main/include/sqlite_orm/sqlite_orm.h"
    click user_h "https://github.com/gobblergang/cplusplusclient/blob/main/src/models/user.h"
    click keys_h "https://github.com/gobblergang/cplusplusclient/blob/main/src/models/keys.h"
    click kek_h "https://github.com/gobblergang/cplusplusclient/blob/main/src/models/kek.h"
    click pac_h "https://github.com/gobblergang/cplusplusclient/blob/main/src/models/pac.h"
    click file_h "https://github.com/gobblergang/cplusplusclient/blob/main/src/models/file.h"
    click PAC_dat_h "https://github.com/gobblergang/cplusplusclient/blob/main/include/utils/dataclasses/PAC.h"
    click PAC_dat_cpp "https://github.com/gobblergang/cplusplusclient/blob/main/include/utils/dataclasses/PAC.cpp"
    click Vault_dat_h "https://github.com/gobblergang/cplusplusclient/blob/main/include/utils/dataclasses/Vault.h"
    click Vault_dat_cpp "https://github.com/gobblergang/cplusplusclient/blob/main/include/utils/dataclasses/Vault.cpp"
    click Server_h "https://github.com/gobblergang/cplusplusclient/blob/main/src/Server.h"
    click CMake "https://github.com/gobblergang/cplusplusclient/blob/main/CMakeLists.txt"
    click vcpkg_json "https://github.com/gobblergang/cplusplusclient/blob/main/vcpkg.json"
    click vcpkg_cfg "https://github.com/gobblergang/cplusplusclient/blob/main/vcpkg-configuration.json"
    click Readme "https://github.com/gobblergang/cplusplusclient/blob/main/README.md"
    click Config_json "https://github.com/gobblergang/cplusplusclient/blob/main/config.json"
```
