# ravvnen/dtaas architecture

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

- Interactive diagram: https://gitdiagram.com/ravvnen/dtaas
- Repository: https://github.com/ravvnen/dtaas

## Overview

##### Project type and purpose
- The repo contains:
- A React/TypeScript web client (`client/`)
- A set of Node/Nest-based microservices (`servers/`), in particular the “library” service (`servers/lib/`) and an authentication service stub (`servers/auth/`)
- Infrastructure definitions (Traefik gateway, Vagrant for VM orchestration, Jupyter/Grafana/InfluxDB scripts)

##### File structure
- Top-level: `client/`, `servers/`, `deploy/`, `docs/`, `script/`, `ssl/`
- `client/`: React app using Redux (slices under `store/`), React Router under `route/`, static assets under `public/`, E2E/unit tests.
- `servers/`:
- `servers/auth/`: an auth microservice (Express/Nest), handles sign-in, user account.
- `servers/lib/`: core “library” microservice exposing GraphQL endpoints, file-service resolver, backed by local filesystem (`files/` module).
- `servers/config/`: Traefik gateway configurations, reverse proxy routes to services.
- Deployment: Vagrant scripts for single- and multi-machine setups. Infrastructure helpers for Jupyter, Grafana, Influx.

##### README for additional insights
- The DTaaS platform sits behind a Traefik API gateway.
- It integrates optional components: JupyterLab via ML Workspace, Grafana, InfluxDB.
- For local development: everything runs inside a Vagrant VM.

##### Main components & their interactions
a. User’s Web Browser (React SPA)
– Requests served by client server or static host
– Interacts with API layer for authentication and data
b. API Gateway (Traefik)
– Routes requests to `auth` and `lib` microservices
– Provides SSL termination (using `ssl/ssl.conf`)
c. Authentication Service (`servers/auth`)
– Sign-in, JWT issuance, user account management
– Talks to no external DB in current version (in-memory or file stub)
d. Library Microservice (`servers/lib`)
– GraphQL server (exposes `schema.gql`, resolvers in `files` module)
– Stores digital-twin assets on disk (`files/` folder)
e. Optional Infrastructure Services
– JupyterLab (ML Workspace container)
– Grafana + InfluxDB for metrics
f. Vagrant VM(s)
– Host the gateway and all containers/microservices
– Optionally multi-node cluster for scale

##### Architectural patterns & design principles
- Microservices behind an API gateway (Traefik)
- React SPA as a consumer of REST/GraphQL APIs
- GraphQL pattern for data access in the library service
- Separation of concerns: UI, auth, business logic, storage
- Infrastructure as code: Vagrant + shell scripts

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    Browser["User’s Browser\nReact SPA\n(client/)"]:::frontend
    click Browser "https://github.com/ravvnen/dtaas/tree/feature/distributed-demo/client/"

    %% API Layer
    Gateway["API Gateway\nTraefik\n(servers/config/)"]:::gateway
    click Gateway "https://github.com/ravvnen/dtaas/tree/feature/distributed-demo/servers/config/gateway/"
    SSL["SSL Termination\n(ssl/ssl.conf)"]:::infra
    click SSL "https://github.com/ravvnen/dtaas/blob/feature/distributed-demo/ssl/ssl.conf"

    %% Service Layer
    Auth["Auth Service\n(servers/auth/)"]:::service
    click Auth "https://github.com/ravvnen/dtaas/tree/feature/distributed-demo/servers/auth/"
    Library["Library Service\n(servers/lib/)"]:::service
    click Library "https://github.com/ravvnen/dtaas/tree/feature/distributed-demo/servers/lib/"
    FileStorage["File Storage Module\n(servers/lib/src/files/)"]:::storage
    click FileStorage "https://github.com/ravvnen/dtaas/tree/feature/distributed-demo/servers/lib/src/files/"

    %% Optional Infrastructure Services
    subgraph "Optional Infrastructure" 
        direction TB
        Jupyter["JupyterLab\n(servers/config/lib-dt/jupyter.conf/)"]:::optional
        click Jupyter "https://github.com/ravvnen/dtaas/tree/feature/distributed-demo/servers/config/lib-dt/jupyter.conf/"
        Influx["InfluxDB\n(script/influx.sh)"]:::optional
        click Influx "https://github.com/ravvnen/dtaas/blob/feature/distributed-demo/script/influx.sh"
        Grafana["Grafana\n(script/grafana.sh)"]:::optional
        click Grafana "https://github.com/ravvnen/dtaas/blob/feature/distributed-demo/script/grafana.sh"
        Influx -->|"metrics data"| Grafana
    end

    %% Infrastructure Layer
    subgraph "Vagrant VM(s)" 
        direction TB
        Gateway
        SSL
        Auth
        Library
        FileStorage
        Jupyter
        Influx
        Grafana
    end

    %% Vagrant Orchestration
    Vagrant["Vagrant VM Orchestration\n(deploy/vagrant/)"]:::infra
    click Vagrant "https://github.com/ravvnen/dtaas/tree/feature/distributed-demo/deploy/vagrant/"

    %% Data Flows
    Browser -->|"HTTPS request"| Gateway
    Gateway -->|"REST /auth\n(JWT token)"| Auth
    Gateway -->|"GraphQL query"| Library
    Library -->|"reads/writes assets"| FileStorage
    Library -->|"push metrics"| Influx
    Browser <-->|"interactive shell"| Jupyter

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1F618D,color:#1B2631;
    classDef gateway fill:#ABEBC6,stroke:#196F3D,color:#1B2631;
    classDef service fill:#F9E79F,stroke:#B9770E,color:#1B2631;
    classDef storage fill:#D5D8DC,stroke:#7B7D7D,color:#1B2631;
    classDef infra fill:#F2F3F4,stroke:#566573,color:#1B2631;
    classDef optional fill:#FDF2E9,stroke-dasharray: 5 5,stroke:#A04000,color:#1B2631;
```
