# federico-osandon/auth-mongo-skeleton-nestjs architecture

> Architecture diagram of the GitHub repository federico-osandon/auth-mongo-skeleton-nestjs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/federico-osandon/auth-mongo-skeleton-nestjs
- Repository: https://github.com/federico-osandon/auth-mongo-skeleton-nestjs

## Overview

##### Project type and purpose
- This is a monolithic backend application built with NestJS (a TypeScript Node.js framework).
- It exposes a RESTful API, handles user authentication (JWT + Prisma ORM), and persists data in a relational database (configured by Prisma).

##### File structure
- Top-level config:
- `.env.template` + `src/config/*` → environment variables and service-specific config.
- `dockerfile` / `dockerfile.prod` + `cloudbuild.yml` → container images and CI/CD pipeline.
- Source code under `src`:
- `app.module.ts` → root Nest module wiring sub-modules.
- `src/auth` → the authentication module (controller, service, DTOs, interfaces).
- `main.ts` → Nest application bootstrap.
- ORM config:
- `prisma/schema.prisma` → database schema and client generation.
- Testing:
- `test/app.e2e-spec.ts` → end-to-end tests.
- Build & linting:
- TypeScript configs (`tsconfig*.json`), ESLint, Prettier, npm scripts.

##### README for additional insights
- It’s a starter project for NestJS, listing standard npm scripts, test commands, and CI badges.

##### Detailed capture of essential architectural elements
- Root `AppModule` and its imports of `AuthModule` and `ConfigModule`.
- Injection of `PrismaService` into other services.
- How `.env` values flow through `ConfigModule` into services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Actors
    subgraph "Clients & Testing"
        Client["Client (Web/Mobile)"]:::external
        E2E["E2E Tests (Jest)"]:::external
    end

    %% CI/CD and Container Layers
    CloudBuild["CI/CD Pipeline"]:::pipeline
    DockerfileDev["Dockerfile (Dev)"]:::container
    DockerfileProd["Dockerfile (Prod)"]:::container
    DockerRegistry["Docker Registry"]:::container

    %% Application Container
    subgraph "Docker Container"
        NestApp["NestJS Application"]:::app
        Main["main.ts"]:::app
        AppModule["AppModule"]:::app

        subgraph "Modules"
            ConfigModule["ConfigModule"]:::app
            AuthModule["AuthModule"]:::app
            PrismaModule["PrismaModule"]:::app
        end

        subgraph "Auth Module"
            AuthController["AuthController"]:::app
            AuthService["AuthService"]:::app
            DTOs["Auth DTOs"]:::app
            JWTInterface["JWT Payload Interface"]:::app
        end

        PrismaService["PrismaService"]:::app
    end

    %% Database
    DB["Relational Database"]:::database

    %% Config Files
    ENV[".env.template"]:::app
    Envs["envs.ts"]:::app
    ServicesConfig["services.ts"]:::app

    %% Testing Config
    E2EConfig["jest-e2e.json"]:::external

    %% Lint & Format
    ESLint[".eslintrc.js"]:::external
    Prettierrc[".prettierrc"]:::external

    %% TS Configs
    TSConfig["tsconfig.json"]:::external
    TSConfigBuild["tsconfig.build.json"]:::external

    %% Package Files
    Package["package.json"]:::external
    PackageLock["package-lock.json"]:::external

    %% Relationships
    Client -->|"HTTP Request"| NestApp
    E2E -->|"HTTP Request"| NestApp

    NestApp -->|bootstrap via| Main
    Main -->|imports| AppModule
    AppModule -->|imports| ConfigModule
    AppModule -->|imports| AuthModule
    AppModule -->|imports| PrismaModule

    ConfigModule -->|loads| ENV
    ConfigModule -->|loads| Envs
    ConfigModule -->|loads| ServicesConfig

    AuthModule --> AuthController
    AuthModule --> AuthService
    AuthModule --> DTOs
    AuthModule --> JWTInterface

    AuthController -->|calls| AuthService
    AuthService -->|uses| PrismaService
    PrismaService -->|queries| DB

    CloudBuild -->|builds with| DockerfileDev
    CloudBuild -->|builds with| DockerfileProd
    CloudBuild -->|push to| DockerRegistry
    DockerRegistry -->|deploy| DockerContainer

    %% Click Events
    click Main "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/src/main.ts"
    click AppModule "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/src/app.module.ts"
    click AuthModule "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/src/auth/auth.module.ts"
    click AuthController "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/src/auth/auth.controller.ts"
    click AuthService "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/src/auth/auth.service.ts"
    click DTOs "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/src/auth/dto/index.ts"
    click DTOs "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/src/auth/dto/login-user.dto.ts"
    click DTOs "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/src/auth/dto/register-user.dto.ts"
    click JWTInterface "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/src/auth/interfaces/jwt-payload.interface.ts"
    click ConfigModule "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/src/config/index.ts"
    click Envs "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/src/config/envs.ts"
    click ENV "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/.env.template"
    click ServicesConfig "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/src/config/services.ts"
    click PrismaService "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/prisma/schema.prisma"
    click CloudBuild "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/cloudbuild.yml"
    click DockerfileDev "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/tree/main/dockerfile"
    click DockerfileProd "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/dockerfile.prod"
    click E2E "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/test/app.e2e-spec.ts"
    click E2EConfig "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/test/jest-e2e.json"
    click ESLint "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/.eslintrc.js"
    click Prettierrc "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/.prettierrc"
    click TSConfig "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/tsconfig.json"
    click TSConfigBuild "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/tsconfig.build.json"
    click Package "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/package.json"
    click PackageLock "https://github.com/federico-osandon/auth-mongo-skeleton-nestjs/blob/main/package-lock.json"

    %% Styles
    classDef app fill:#D6EAF8,stroke:#21618C
    classDef database fill:#ABEBC6,stroke:#196F3D
    classDef pipeline fill:#FAD7A0,stroke:#B9770E
    classDef container fill:#D5DBDB,stroke:#424949
    classDef external fill:#F2F4F4,stroke:#909497
```
