# thesobersobber/orvio-backend architecture

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

- Interactive diagram: https://gitdiagram.com/thesobersobber/orvio-backend
- Repository: https://github.com/thesobersobber/orvio-backend

## Overview

##### Project Type & Purpose
- It’s a NestJS-based server-side application that employs a microservices architecture.
- The project hosts several “apps” (or services) – each representing a distinct domain (e.g., authentication, backend API, FCM, FCM token, OTP, and a service component).
- There is also a “shared” area for common entities and utility wrappers used by these services, suggesting reuse of data models (like API keys, devices, sessions, and users).

##### Main Components
a. Individual Microservices:
– Auth Service (apps/auth): Handles authentication logic.
– Backend Service (apps/backend): Provides main business APIs with controllers (including dedicated controllers for auth, root operations, and service endpoints).
– FCM Service (apps/fcm): Likely manages Firebase Cloud Messaging-related operations.
– FCM Token Service (apps/fcmToken): Deals with token management probably related to push notifications.
– OTP Service (apps/otp): Implements one-time password functions.
– Service Component (apps/service): Manages some business service-related operations.
b. Shared Module:
– The “apps/shared” directory holds common entities and the RPC wrapper, used for shared data models and communication logic across microservices.
c. Containerization/Docker:
– Each service directory contains its own Dockerfile. Include a node for Docker deployment and container orchestration.
– There’s a docker-compose.yml at the project root suggesting that services are meant to be deployed as separate containers.
d. Testing and Configurations:
– Each service includes its own test suites and configuration files (e.g., tsconfig.app.json, jest-e2e configs) to emphasize a unit/e2e testing approach.
– This indicates a robust development process and modular deployment.

##### Relationships & Data Flow
– The Auth Service may communicate with the Backend Service to validate authentication requests.
– The OTP service might trigger events to the Auth service during multi-factor authentication.
– FCM and FCM Token services are likely interrelated for managing notifications, with potential callbacks to the Backend for status or logging.
- Additionally, container orchestration (reflecting docker-compose) may be shown at a higher level to denote service deployments and network connectivity.

##### Architectural Patterns and Technologies
- Modularity inherent in the NestJS framework (with separate modules for controllers, services, and guards).
- Microservices pattern – each service being an independent deployable unit.
- Usage of technologies:
– TypeScript for code robustness.
– NestJS for structured modularity.
– Docker for containerization.
– Testing frameworks (Jest e2e, unit test files) to ensure quality.
- If applicable, show potential API gateway or inter-service messaging (hinted by shared rpcWrapper).

– Start with a high-level layer indicating “Deployment/Containers” showing each service’s Docker container.
– Include annotations for the testing frameworks and orchestration layers (e.g., separate testing nodes with e2e tests).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Containerization Node
    DC("Docker Compose (docker-compose.yml)"):::container

    %% Microservices Subgraph
    subgraph "Microservices"
        A("Auth Service"):::service
        B("Backend Service"):::service
        C("FCM Service"):::service
        D("FCM Token Service"):::service
        E("OTP Service"):::service
        F("Service Component"):::service
    end

    %% Shared Module Node
    SM("Shared Module (Entities & RPC Wrapper)"):::shared

    %% Inter-service Communications
    A -->|"calls"| B
    E -->|"triggers"| A
    C -->|"notifies"| B
    D -->|"updates"| B

    %% Dependency on Shared Module
    A -->|"uses"| SM
    B -->|"uses"| SM
    C -->|"uses"| SM
    D -->|"uses"| SM
    E -->|"uses"| SM
    F -->|"uses"| SM

    %% Container Orchestration Relationships
    DC --> A
    DC --> B
    DC --> C
    DC --> D
    DC --> E
    DC --> F

    %% Click Events
    click A "https://github.com/thesobersobber/orvio-backend/tree/main/apps/auth"
    click B "https://github.com/thesobersobber/orvio-backend/tree/main/apps/backend"
    click C "https://github.com/thesobersobber/orvio-backend/tree/main/apps/fcm"
    click D "https://github.com/thesobersobber/orvio-backend/tree/main/apps/fcmToken"
    click E "https://github.com/thesobersobber/orvio-backend/tree/main/apps/otp"
    click F "https://github.com/thesobersobber/orvio-backend/tree/main/apps/service"
    click SM "https://github.com/thesobersobber/orvio-backend/tree/main/apps/shared"
    click DC "https://github.com/thesobersobber/orvio-backend/blob/main/docker-compose.yml"

    %% Styles
    classDef service fill:#cce5ff,stroke:#007bff,stroke-width:2px;
    classDef shared fill:#d4edda,stroke:#28a745,stroke-width:2px;
    classDef container fill:#f8d7da,stroke:#dc3545,stroke-width:2px;
```
