# vnoi-admin/utilities-v2 architecture

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

- Interactive diagram: https://gitdiagram.com/vnoi-admin/utilities-v2
- Repository: https://github.com/vnoi-admin/utilities-v2

## Overview

##### Main Components
- Frontend: The “admin-panel” app in the apps directory, which is a Vue-based interface (includes App.vue, router, components, layouts, etc.) and is accessible at port 8000.
- Backend Microservices: There are several, each residing in its own subdirectory under apps:
– Auth Service: Handles authentication logic and related API endpoints (port 8002 as per README).
– User Service: Manages user-related operations, including groups, tasks, and VPN configurations.
– Internal Service: Likely used for internal application support (includes modules for group, overlay, and user).
– Printing Service: Responsible for managing printing functionalities and tasks.
- Shared Libraries: These provide cross-cutting features:
– libs/api: Likely offers API definitions or helper functions for communication between services.
– libs/common-db: Contains database modules and schemas for MongoDB models (group, overlay, printClient, printJob, user).
– libs/common: Implements decorators, DTOs, guards, helpers, etc., to be reused across services.
– libs/utils: Provides utility functions such as cryptography (key generation, etc.).

##### Additional Components and Infrastructure
- Database: MongoDB (as per Requirements) that is accessed by many backend microservices, likely through the common-db library.
- Configurations and Deployment:
– The config folder contains Nginx configuration files which could be acting as a reverse proxy or load balancer.
– Docker files in services and docker-compose.yaml are used to containerize and deploy the different applications.
– Yarn and Turbo (via turbo.json) are used for dependency management and workspaces, indicating a monorepo management strategy.

##### Relationships and Interactions
- The frontend admin-panel communicates with one or more backend microservices (auth, user, etc.) over HTTP/REST APIs (for example, the admin panel’s API endpoints may be consumed from these services).
- The microservices interact with a central MongoDB database (either directly or indirectly via the common-db library).
- Shared libraries form an underlying layer of common functionality and data structures that service modules leverage to standardize communication, validation, and business logic.
- Docker and Nginx configurations indicate orchestration between services, where Nginx might be directing traffic between the frontend and individual backend services.

##### Architectural Patterns and Design Principles
- Microservices Architecture: Each service is modularized (auth, user, printing, internal) and is potentially containerized for independent deployment.
- Separation of Concerns: There is a clear separation between the frontend (admin-panel) and various backend services.
- Shared Libraries: Encourage DRY (Don’t Repeat Yourself) principles by centralizing common features like database interaction (schemas, services) and authentication logic.
- Use of Docker and Nginx for container orchestration and traffic routing.

- Use of Docker for containerizing services and the role of Nginx in dispatching client requests appropriately.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client / End-User
    client("User/Client"):::clientStyle

    %% Infrastructure
    subgraph "Infrastructure"
        nginx("Nginx (Reverse Proxy)")
        docker("Docker Containers & Orchestration")
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        admin("Admin Panel (Vue + Vite + Vuetify) [Port:8000]")
    end

    %% Backend Microservices
    subgraph "Backend Microservices"
        auth("Auth Service [Port:8002]")
        user("User Service")
        internal("Internal Service")
        printing("Printing Service")
    end

    %% Shared Libraries
    subgraph "Shared Libraries"
        apiLib("API Library")
        commonDB("Common-DB Library")
        commonLib("Common Library")
        utilsLib("Utils Library")
    end

    %% Database
    db("MongoDB"):::database

    %% Connections
    client -->|"HTTPRequest"| nginx
    nginx -->|"RoutesTo"| admin
    nginx -->|"RoutesTo"| auth
    nginx -->|"RoutesTo"| user
    nginx -->|"RoutesTo"| internal
    nginx -->|"RoutesTo"| printing

    admin -->|"APICalls"| auth
    admin -->|"APICalls"| user
    admin -->|"APICalls"| internal
    admin -->|"APICalls"| printing

    auth -->|"PersistsData"| db
    user -->|"PersistsData"| db
    internal -->|"PersistsData"| db
    printing -->|"PersistsData"| db

    auth -->|"Uses"| apiLib
    auth -->|"Uses"| commonDB
    auth -->|"Uses"| commonLib
    auth -->|"Uses"| utilsLib

    user -->|"Uses"| apiLib
    user -->|"Uses"| commonDB
    user -->|"Uses"| commonLib
    user -->|"Uses"| utilsLib

    internal -->|"Uses"| apiLib
    internal -->|"Uses"| commonDB
    internal -->|"Uses"| commonLib
    internal -->|"Uses"| utilsLib

    printing -->|"Uses"| apiLib
    printing -->|"Uses"| commonDB
    printing -->|"Uses"| commonLib
    printing -->|"Uses"| utilsLib

    docker -.-> admin
    docker -.-> auth
    docker -.-> user
    docker -.-> internal
    docker -.-> printing
    docker -.-> nginx

    %% Click Events
    click admin "https://github.com/vnoi-admin/utilities-v2/tree/master/apps/admin-panel"
    click auth "https://github.com/vnoi-admin/utilities-v2/tree/master/apps/auth"
    click user "https://github.com/vnoi-admin/utilities-v2/tree/master/apps/user"
    click internal "https://github.com/vnoi-admin/utilities-v2/tree/master/apps/internal"
    click printing "https://github.com/vnoi-admin/utilities-v2/tree/master/apps/printing"
    click apiLib "https://github.com/vnoi-admin/utilities-v2/tree/master/libs/api"
    click commonDB "https://github.com/vnoi-admin/utilities-v2/tree/master/libs/common-db"
    click commonLib "https://github.com/vnoi-admin/utilities-v2/tree/master/libs/common"
    click utilsLib "https://github.com/vnoi-admin/utilities-v2/tree/master/libs/utils"
    click nginx "https://github.com/vnoi-admin/utilities-v2/tree/master/config/nginx"
    click docker "https://github.com/vnoi-admin/utilities-v2/blob/master/docker-compose.yaml"

    %% Styles
    classDef clientStyle fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef infra fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef frontend fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef backend fill:#F5B7B1,stroke:#CB4335,stroke-width:2px;
    classDef lib fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;
    classDef database fill:#FAD7A0,stroke:#D35400,stroke-width:2px;

    %% Apply classes to nodes
    class nginx,docker infra;
    class admin frontend;
    class auth,user,internal,printing backend;
    class apiLib,commonDB,commonLib,utilsLib lib;
    class db database;
```
