# microservices-jdvpl/auth-ms architecture

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

- Interactive diagram: https://gitdiagram.com/microservices-jdvpl/auth-ms
- Repository: https://github.com/microservices-jdvpl/auth-ms

## Overview

##### Project Type Analysis
This is a NestJS backend application with a focus on authentication, using Prisma as an ORM and following a modular architecture pattern. The project appears to be containerized (Docker) and has cloud deployment capabilities (cloudbuild.yml).

##### Main Components

A. Core Application Layer:
- NestJS Application Container
- Auth Module
- App Module (root module)
- Environment Configuration

B. Database Layer:
- Prisma ORM
- Database (likely PostgreSQL/MySQL based on Prisma usage)

C. Authentication Components:
- JWT Service (implied by jwt-payload.interface.ts)
- Auth Controllers
- Auth Services

D. Infrastructure Layer:
- Docker Container
- Cloud Build Pipeline

**1. Client Layer (External)**
- HTTP/HTTPS Requests

**2. Application Layer (Container)**
- NestJS Server
- Auth Module
- Controllers (auth.controller.ts)
- Services (auth.service.ts)
- DTOs (login/register)
- App Module

- Middleware Layer
- Environment Configuration

**3. Data Layer**
- Prisma ORM
- Database

**4. Infrastructure Layer**
- Docker Container
- Cloud Build Pipeline

##### Specific Elements

a. Component Representations:
- Use rectangles for modules
- Use hexagons for external services
- Use containers for dockerized components

- Blue: Core NestJS components
- Green: Database components
- Yellow: Authentication components
- Gray: Infrastructure components

c. Connections:
- Double lines for database connections

##### Important Details to Highlight

- Authentication flow:
- Client → Auth Controller → Auth Service → Prisma → Database
- Modular structure of NestJS
- JWT authentication flow
- Environment configuration integration

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        CL[Client]
    end

    subgraph "Application Container"
        subgraph "NestJS Server"
            MAIN["Main Entry Point"]:::core
            click MAIN "https://github.com/microservices-jdvpl/auth-ms/blob/main/src/main.ts"
            
            subgraph "App Module"
                AM["App Module"]:::core
                click AM "https://github.com/microservices-jdvpl/auth-ms/blob/main/src/app.module.ts"
            end
            
            subgraph "Auth Module"
                AUTH["Auth Module"]:::auth
                click AUTH "https://github.com/microservices-jdvpl/auth-ms/blob/main/src/auth/auth.module.ts"
                
                CTRL["Auth Controller"]:::auth
                click CTRL "https://github.com/microservices-jdvpl/auth-ms/blob/main/src/auth/auth.controller.ts"
                
                SVC["Auth Service"]:::auth
                click SVC "https://github.com/microservices-jdvpl/auth-ms/blob/main/src/auth/auth.service.ts"
                
                JWT["JWT Payload"]:::auth
                click JWT "https://github.com/microservices-jdvpl/auth-ms/blob/main/src/auth/interfaces/jwt-payload.interface.ts"
                
                subgraph "DTOs"
                    LOGIN["Login DTO"]:::dto
                    click LOGIN "https://github.com/microservices-jdvpl/auth-ms/blob/main/src/auth/dto/login-user.dto.ts"
                    REG["Register DTO"]:::dto
                    click REG "https://github.com/microservices-jdvpl/auth-ms/blob/main/src/auth/dto/register-user.dto.ts"
                end
            end
            
            ENV["Environment Config"]:::config
            click ENV "https://github.com/microservices-jdvpl/auth-ms/blob/main/src/shared/env/envs.ts"
        end
    end
    
    subgraph "Data Layer"
        PRISMA[(Prisma ORM)]:::database
        click PRISMA "https://github.com/microservices-jdvpl/auth-ms/blob/main/prisma/schema.prisma"
        DB[(Database)]:::database
    end
    
    subgraph "Infrastructure Layer"
        DOCKER["Docker Container"]:::infra
        click DOCKER "https://github.com/microservices-jdvpl/auth-ms/tree/main/dockerfile"
        CLOUD["Cloud Build"]:::infra
        click CLOUD "https://github.com/microservices-jdvpl/auth-ms/blob/main/cloudbuild.yml"
    end
    
    %% Connections
    CL --> CTRL
    MAIN --> AM
    AM --> AUTH
    AUTH --> CTRL
    CTRL --> SVC
    SVC --> JWT
    CTRL --> LOGIN
    CTRL --> REG
    SVC --> PRISMA
    PRISMA --> DB
    ENV -.-> AM
    ENV -.-> AUTH
    
    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef auth fill:#FFA726,stroke:#F57C00,color:white
    classDef dto fill:#81C784,stroke:#388E3C,color:white
    classDef database fill:#7E57C2,stroke:#4527A0,color:white
    classDef config fill:#90A4AE,stroke:#546E7A,color:white
    classDef infra fill:#E57373,stroke:#D32F2F,color:white
    
    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Auth Components"]:::auth
        L3["DTOs"]:::dto
        L4["Database"]:::database
        L5["Configuration"]:::config
        L6["Infrastructure"]:::infra
    end
```
