# jesus-colomacardoza/gestiondocumentalserver architecture

> Architecture diagram of the GitHub repository jesus-colomacardoza/gestiondocumentalserver, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jesus-colomacardoza/gestiondocumentalserver
- Repository: https://github.com/jesus-colomacardoza/gestiondocumentalserver

## Overview

##### Project type and purpose
- This is a monolithic, server-side application built with NestJS (a Node.js framework) and TypeScript.
- It exposes a RESTful API to manage documents, workflows, users, roles, and related entities.
- It also integrates with external services (AWS for file storage, a RENIEC API, and an SMTP mail service) and uses Prisma as its ORM/data-access layer.

##### File structure
- Top-level files & folders:
- config/ – application configuration
- prisma/ – the Prisma schema & migrations
- public/ – static HTML and image assets
- src/ – all NestJS modules, controllers, services, DTOs, entities, and interfaces
- test/ – end-to-end test suite
- src/ is organized per domain module: auth, usuario, documento, tramite, file-aws, file-manager, mail, reniec, etc.
- A central connection/prisma module provides the PrismaService to all other modules (the Data Access Layer).
- There’s no separate “frontend” – this is a backend API with some static public views.

##### README
- It’s the standard NestJS starter README.
- Confirms usage of NestJS core modules, npm scripts for start/dev/prod, and testing.

##### Main components & their roles
a. API Layer (NestJS HTTP Server)
- app.module.ts glues everything together
- Controllers (one per domain: auth, usuario, tramite, documento, etc.)
b. Business Logic Layer
- Services (e.g. AuthService, TramiteService, DocumentoService, FileAwsService, MailService)
c. Data Access Layer (DAL) – **central**
- prisma.module.ts & prisma.service.ts
- Provides CRUD and query functionality to all Services via Prisma ORM
d. Persistence
- Relational Database (e.g. PostgreSQL/MySQL) behind Prisma
e. External Integrations
- AWS SDK for file storage (S3)
- RENIEC external API for identity lookup
- SMTP/email provider via MailService
- Static assets served from public/

##### Relationships & interactions
- Incoming HTTP request → Controller → Service → (via DAL) Database
- Service may also call → AWS module or RENIEC module or Mail module
- PrismaService sits at the heart of all Services (it “talks” to the database)
- The API server hosts a static-file endpoint for public/
- Tests (in test/) exercise end-to-end flows against the running server

##### Architectural patterns & design principles
- Modular Monolith: Each domain feature is isolated in its own NestJS module
- Layered Architecture: Controllers → Services → Repositories/DAL
- Dependency Injection: NestJS’s DI container injects Services into Controllers and PrismaService into Services
- DTOs & Entities separate external API contracts from persistence models

- Top band: Controllers (list modules: Auth, Usuario, Documento, Tramite, etc.)
- Middle band: Services (AuthService, UsuarioService, etc.)
- Bottom band (centered): Data Access Layer – PrismaService
4. Technologies next to each component:
- Node.js + Express beneath “NestJS API Server”
- TypeScript for all code
- Prisma ORM in DAL
- AWS SDK in AWS module
- HTTP client/axios in RENIEC module
- Nodemailer in Mail module
6. Review with domain experts to ensure all modules and flows are represented.

## Diagram (Mermaid)

```mermaid
graph TB
  subgraph "NestJS API Server"
    direction TB
    Main["main.ts"]:::api
    AppModule["app.module.ts"]:::api

    subgraph "API Layer"
      direction TB
      AuthController["AuthController"]:::api
      UsuarioController["UsuarioController"]:::api
      DocumentoController["DocumentoController"]:::api
      TramiteController["TramiteController"]:::api
      StaticFiles["public/"]:::api
    end

    subgraph "Business Logic Layer"
      direction TB
      AuthService["AuthService"]:::service
      UsuarioService["UsuarioService"]:::service
      DocumentoService["DocumentoService"]:::service
      TramiteService["TramiteService"]:::service
      FileAwsService["FileAwsService"]:::service
      FileManagerService["FileManagerService"]:::service
      MailService["MailService"]:::service
      ReniecService["ReniecService"]:::service
    end

    subgraph "Data Access Layer"
      direction TB
      PrismaModule["PrismaModule"]:::dal
      PrismaService["PrismaService"]:::dal
    end
  end

  Database[(PostgreSQL)]:::db
  AWS_S3("AWS S3"):::external
  RENIEC_API("RENIEC API"):::external
  SMTP_Server("SMTP Server"):::external

  Main --> AppModule
  AppModule --> AuthController
  AppModule --> UsuarioController
  AppModule --> DocumentoController
  AppModule --> TramiteController
  AppModule --> StaticFiles

  AuthController --> AuthService
  UsuarioController --> UsuarioService
  DocumentoController --> DocumentoService
  TramiteController --> TramiteService
  StaticFiles -.->|serves| AppModule

  AuthService --> PrismaService
  UsuarioService --> PrismaService
  DocumentoService --> PrismaService
  TramiteService --> PrismaService
  FileAwsService --> PrismaService
  FileManagerService --> PrismaService
  MailService --> PrismaService
  ReniecService --> PrismaService

  FileAwsService --> AWS_S3
  ReniecService --> RENIEC_API
  MailService --> SMTP_Server

  PrismaService --> Database

  click Main "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/src/main.ts"
  click AppModule "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/src/app.module.ts"
  click AuthController "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/src/auth/auth.controller.ts"
  click UsuarioController "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/src/usuario/usuario.controller.ts"
  click DocumentoController "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/src/documento/documento.controller.ts"
  click TramiteController "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/src/tramite/tramite.controller.ts"
  click AuthService "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/src/auth/auth.service.ts"
  click UsuarioService "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/src/usuario/usuario.service.ts"
  click DocumentoService "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/src/documento/documento.service.ts"
  click TramiteService "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/src/tramite/tramite.service.ts"
  click FileAwsService "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/src/file-aws/file-aws.service.ts"
  click FileManagerService "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/src/file-manager/file-manager.service.ts"
  click MailService "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/src/mail/mail.service.ts"
  click ReniecService "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/src/reniec/reniec.service.ts"
  click PrismaModule "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/src/connection/prisma.module.ts"
  click PrismaService "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/src/connection/prisma.service.ts"
  click Database "https://github.com/jesus-colomacardoza/gestiondocumentalserver/blob/main/prisma/schema.prisma"
  click StaticFiles "https://github.com/jesus-colomacardoza/gestiondocumentalserver/tree/main/public/"

  classDef api fill:#bbdefb,stroke:#2196f3,stroke-width:1px
  classDef service fill:#c8e6c9,stroke:#388e3c,stroke-width:1px
  classDef dal fill:#ffe0b2,stroke:#fb8c00,stroke-width:1px
  classDef db fill:#e0e0e0,stroke:#757575,stroke-width:1px
  classDef external fill:#e1bee7,stroke:#8e24aa,stroke-width:1px
```
