# centiverse-solutions/centiverse-desktop architecture

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

- Interactive diagram: https://gitdiagram.com/centiverse-solutions/centiverse-desktop
- Repository: https://github.com/centiverse-solutions/centiverse-desktop

## Overview

##### Project Type and Purpose
- This project is a hybrid desktop/web application utilizing a React-based frontend bootstrapped with Create React App and a Tauri-based backend written in Rust.
- The purpose is to create a desktop application with a modern UI (React) while taking advantage of native capabilities through Tauri. The backend handles REST-like routes, database migrations, entity management, and business logic.

##### File Structure
- The top-level directory shows typical React project files including "src", "public", and build configuration files (package.json, etc.).
- The presence of the "src-tauri" directory indicates that the native part of the application is implemented in Rust. Within this directory, key directories include:
- /src-tauri/src: Contains main Rust code with controllers, entity definitions, models, routes, and custom errors.
- /src-tauri/migration: Contains database migration scripts in Rust indicating an evolving database schema.
- /src-tauri/gen: Holds generated schema files for various components (e.g., ACL manifests, desktop-schema, etc.).
- Configurations and environment files (e.g., tauri.conf.json, .env) that control native application behavior.
- The projects clearly separate concerns between the UI (React) and the business logic and system access layer (Rust/Tauri).

##### Insights from the README
- The README primarily focuses on the Create React App side, explaining build and deployment steps for the UI. While it doesn’t cover backend specifics, the front-end instructions imply that the React code interacts with the backend via APIs or Tauri commands.

##### Elements
- Clear Labels: Each component should be clearly labeled (e.g., “React Frontend”, “Tauri Backend – Controllers”, “Database”, etc.).
- Frontend and Tauri API layer,
- Controllers handling specific routes,
- Models/Entities interacting with the Database,
- Auxiliary modules dealing with authentication and error handling.

##### Final Advice
- Drill down into the backend layer by showcasing the key modules (controllers, migrations, models/entities, utilities).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        A("React Frontend"):::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        B("Controllers"):::backend
        C("Models"):::backend
        D("Entities"):::backend
        E("Request Verifiers"):::backend
        F("Custom Errors"):::backend
        G("JWT Utility"):::backend
        H("Database Migrations"):::backend
        I("Tauri Config & Native Integration"):::backend
        J("Generated Schemas"):::backend
    end

    %% Persistence Layer (Database)
    subgraph "Persistence Layer"
        K(("Database")):::database
    end

    %% Connections between layers
    A -->|"Tauri_API"| B
    B -->|"handles"| C
    B -->|"handles"| D
    B -->|"validates"| E
    B -->|"manages"| F
    B -->|"uses"| G
    B -->|"utilizes"| I
    B -->|"references"| J
    C -->|"performs CRUD"| K
    D -->|"performs CRUD"| K
    H -->|"migrates"| K

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef database fill:#FFB6C1,stroke:#000,stroke-width:2px;

    %% Click Events
    click A "https://github.com/centiverse-solutions/centiverse-desktop/tree/main//src"
    click A "https://github.com/centiverse-solutions/centiverse-desktop/tree/main//public"
    click B "https://github.com/centiverse-solutions/centiverse-desktop/tree/main//src-tauri/src/controllers"
    click C "https://github.com/centiverse-solutions/centiverse-desktop/tree/main//src-tauri/src/models"
    click D "https://github.com/centiverse-solutions/centiverse-desktop/tree/main//src-tauri/src/entities"
    click E "https://github.com/centiverse-solutions/centiverse-desktop/tree/main//src-tauri/src/request_verifier"
    click F "https://github.com/centiverse-solutions/centiverse-desktop/tree/main//src-tauri/src/custom_errors"
    click G "https://github.com/centiverse-solutions/centiverse-desktop/blob/main//src-tauri/src/utils/jwt_token.rs"
    click H "https://github.com/centiverse-solutions/centiverse-desktop/tree/main//src-tauri/migration"
    click I "https://github.com/centiverse-solutions/centiverse-desktop/blob/main//src-tauri/tauri.conf.json"
    click I "https://github.com/centiverse-solutions/centiverse-desktop/blob/main//src-tauri/.env"
    click J "https://github.com/centiverse-solutions/centiverse-desktop/tree/main//src-tauri/gen/schemas"
```
