# isalin1/karbonsmart architecture

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

- Interactive diagram: https://gitdiagram.com/isalin1/karbonsmart
- Repository: https://github.com/isalin1/karbonsmart

## Overview

##### Main Components
- NestJS Application Core – This is the primary runtime that orchestrates all the modules.
- Modules – The project is divided into many subdomains (for example, auth, departamentos, distritos, encargados, movinventarios, various “movisaldo…” modules, etc.). Each module typically includes a controller (to handle HTTP requests), a service (the business logic), DTOs, and entities that define data structures.
- Data Access Layer via Prisma – The prisma folder (with schema.prisma and migration folders) signifies that all database interaction is abstracted through the Prisma client.
- Database – While the file tree itself doesn’t name a specific database, the presence of migrations and Docker files (docker/docker-compose.yml) hint at a containerized database (e.g., PostgreSQL or MySQL).
- Infrastructure & Deployment – The Docker-related files indicate that the application is intended for containerized deployment. There are also config files for linting, formatting, and the Nest CLI.

##### Relationships and Interactions
- The Controllers serve as the entry point for API requests. They forward calls to their corresponding Services.
- The Services hold the business logic and interact with the Prisma client (found in src/prisma/client.ts) to persist or retrieve data from the database.
- Each module is isolated in terms of responsibilities but may communicate with other modules (e.g., the Auth module might interact with the Users module).
- Migration and schema files under the prisma folder indicate that there is a continuous evolution of the database structure managed separately.

##### Architectural Patterns/Design Principles
- Modular Architecture – Every key business area has its own module with its controller, service, dto, and entity.
- Separation of Concerns – Controllers, services, and data-access (Prisma) are well separated to enhance testability and maintainability.
- Dependency Injection – The typical NestJS pattern is used where services are injected into controllers and other services.
- Infrastructure as Code (Docker) – Deployment and orchestration are handled through Docker and docker-compose.

##### Relevant Technologies and Frameworks
- NestJS – The Node.js framework used.
- Prisma – An Object Relational Mapping (ORM) tool for database communication.
- Docker – For managing consistent containerized environments.
- TypeScript – The underlying type-safe language.
- JWT & Other Authentication strategies – In the auth module, look for JWT strategy, decorators, and DTOs.

##### Must-Include Elements
- Use clear, succinct labels for each major component/module.
- Rectangles for individual modules/components.
- Modularity by possibly grouping related modules under a “Domain Modules” header.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["External Client (HTTP Request)"]:::client
    B["NestJS Application Core"]:::nestjs
    A -->|"sends_request"| B

    subgraph "Domain Modules"
        Auth["Auth Module"]:::module
        Departamentos["Departamentos Module"]:::module
        Distritos["Distritos Module"]:::module
        Encargados["Encargados Module"]:::module
        Movinventarios["Movinventarios Module"]:::module
        Movisaldoclientes["Movisaldoclientes Module"]:::module
        Movisaldoproveedores["Movisaldoproveedores Module"]:::module
        Negocios["Negocios Module"]:::module
        PagoAProveedores["Pago a Proveedores Module"]:::module
        PagoDeClientes["Pago de Clientes Module"]:::module
        Personas["Personas Module"]:::module
        Prodpresentacion["Prodpresentacion Module"]:::module
        ProdpresentacionTamanos["Prodpresentaciontamanos Module"]:::module
        Productos["Productos Module"]:::module
        Productovariantes["Productovariantes Module"]:::module
        Provincias["Provincias Module"]:::module
        Puntoventas["Puntoventas Module"]:::module
        Roles["Roles Module"]:::module
        Rubros["Rubros Module"]:::module
        SaldoClientes["Saldo Clientes Module"]:::module
        SaldoProveedores["Saldo Proveedores Module"]:::module
        TipoDuenoNegocio["Tipo Dueño Negocio Module"]:::module
        TipoMovimientos["Tipo Movimientos Module"]:::module
        TipoMovistocks["Tipo Movistocks Module"]:::module
        TipoPagos["Tipo Pagos Module"]:::module
        TipoProductos["Tipo Productos Module"]:::module
        TransaccionDetalles["Transaccion Detalles Module"]:::module
        Transacciones["Transacciones Module"]:::module
        Transaccionprocesadas["Transaccion Procesadas Module"]:::module
        Unidad["Unidad Module"]:::module
        Users["Users Module"]:::module
    end

    B -->|"routes_to"| Auth
    B -->|"routes_to"| Departamentos
    B -->|"routes_to"| Distritos
    B -->|"routes_to"| Encargados
    B -->|"routes_to"| Movinventarios
    B -->|"routes_to"| Movisaldoclientes
    B -->|"routes_to"| Movisaldoproveedores
    B -->|"routes_to"| Negocios
    B -->|"routes_to"| PagoAProveedores
    B -->|"routes_to"| PagoDeClientes
    B -->|"routes_to"| Personas
    B -->|"routes_to"| Prodpresentacion
    B -->|"routes_to"| ProdpresentacionTamanos
    B -->|"routes_to"| Productos
    B -->|"routes_to"| Productovariantes
    B -->|"routes_to"| Provincias
    B -->|"routes_to"| Puntoventas
    B -->|"routes_to"| Roles
    B -->|"routes_to"| Rubros
    B -->|"routes_to"| SaldoClientes
    B -->|"routes_to"| SaldoProveedores
    B -->|"routes_to"| TipoDuenoNegocio
    B -->|"routes_to"| TipoMovimientos
    B -->|"routes_to"| TipoMovistocks
    B -->|"routes_to"| TipoPagos
    B -->|"routes_to"| TipoProductos
    B -->|"routes_to"| TransaccionDetalles
    B -->|"routes_to"| Transacciones
    B -->|"routes_to"| Transaccionprocesadas
    B -->|"routes_to"| Unidad
    B -->|"routes_to"| Users

    %% Each Module's Service calls the Data Access Layer (Prisma Client)
    Auth -->|"calls"| PC["Prisma Client"]:::prisma
    Departamentos -->|"calls"| PC
    Distritos -->|"calls"| PC
    Encargados -->|"calls"| PC
    Movinventarios -->|"calls"| PC
    Movisaldoclientes -->|"calls"| PC
    Movisaldoproveedores -->|"calls"| PC
    Negocios -->|"calls"| PC
    PagoAProveedores -->|"calls"| PC
    PagoDeClientes -->|"calls"| PC
    Personas -->|"calls"| PC
    Prodpresentacion -->|"calls"| PC
    ProdpresentacionTamanos -->|"calls"| PC
    Productos -->|"calls"| PC
    Productovariantes -->|"calls"| PC
    Provincias -->|"calls"| PC
    Puntoventas -->|"calls"| PC
    Roles -->|"calls"| PC
    Rubros -->|"calls"| PC
    SaldoClientes -->|"calls"| PC
    SaldoProveedores -->|"calls"| PC
    TipoDuenoNegocio -->|"calls"| PC
    TipoMovimientos -->|"calls"| PC
    TipoMovistocks -->|"calls"| PC
    TipoPagos -->|"calls"| PC
    TipoProductos -->|"calls"| PC
    TransaccionDetalles -->|"calls"| PC
    Transacciones -->|"calls"| PC
    Transaccionprocesadas -->|"calls"| PC
    Unidad -->|"calls"| PC
    Users -->|"calls"| PC

    PC -->|"queries"| DB["Database"]:::database
    M["Migrations"]:::prisma -->|"migrates"| DB

    Dock["Docker/Deployment"]:::docker
    Dock -->|"runs"| B
    Dock -->|"runs"| DB

    %% Click Events for Components
    click B "https://github.com/isalin1/karbonsmart/blob/main/src/app.module.ts"
    click B "https://github.com/isalin1/karbonsmart/blob/main/src/main.ts"
    click Auth "https://github.com/isalin1/karbonsmart/tree/main/src/auth/"
    click Departamentos "https://github.com/isalin1/karbonsmart/tree/main/src/departamentos/"
    click Distritos "https://github.com/isalin1/karbonsmart/tree/main/src/distritos/"
    click Encargados "https://github.com/isalin1/karbonsmart/tree/main/src/encargados/"
    click Movinventarios "https://github.com/isalin1/karbonsmart/tree/main/src/movinventarios/"
    click Movisaldoclientes "https://github.com/isalin1/karbonsmart/tree/main/src/movisaldoclientes/"
    click Movisaldoproveedores "https://github.com/isalin1/karbonsmart/tree/main/src/movisaldoproveedores/"
    click Negocios "https://github.com/isalin1/karbonsmart/tree/main/src/negocios/"
    click PagoAProveedores "https://github.com/isalin1/karbonsmart/tree/main/src/pagoaproveedores/"
    click PagoDeClientes "https://github.com/isalin1/karbonsmart/tree/main/src/pagodeclientes/"
    click Personas "https://github.com/isalin1/karbonsmart/tree/main/src/personas/"
    click Prodpresentacion "https://github.com/isalin1/karbonsmart/tree/main/src/prodpresentacion/"
    click ProdpresentacionTamanos "https://github.com/isalin1/karbonsmart/tree/main/src/prodpresentaciontamanos/"
    click Productos "https://github.com/isalin1/karbonsmart/tree/main/src/productos/"
    click Productovariantes "https://github.com/isalin1/karbonsmart/tree/main/src/productovariantes/"
    click Provincias "https://github.com/isalin1/karbonsmart/tree/main/src/provincias/"
    click Puntoventas "https://github.com/isalin1/karbonsmart/tree/main/src/puntoventas/"
    click Roles "https://github.com/isalin1/karbonsmart/tree/main/src/roles/"
    click Rubros "https://github.com/isalin1/karbonsmart/tree/main/src/rubros/"
    click SaldoClientes "https://github.com/isalin1/karbonsmart/tree/main/src/saldoclientes/"
    click SaldoProveedores "https://github.com/isalin1/karbonsmart/tree/main/src/saldoproveedores/"
    click TipoDuenoNegocio "https://github.com/isalin1/karbonsmart/tree/main/src/tipoduenonegocio/"
    click TipoMovimientos "https://github.com/isalin1/karbonsmart/tree/main/src/tipomovimientos/"
    click TipoMovistocks "https://github.com/isalin1/karbonsmart/tree/main/src/tipomovistocks/"
    click TipoPagos "https://github.com/isalin1/karbonsmart/tree/main/src/tipopagos/"
    click TipoProductos "https://github.com/isalin1/karbonsmart/tree/main/src/tipoproductos/"
    click TransaccionDetalles "https://github.com/isalin1/karbonsmart/tree/main/src/transacciondetalles/"
    click Transacciones "https://github.com/isalin1/karbonsmart/tree/main/src/transacciones/"
    click Transaccionprocesadas "https://github.com/isalin1/karbonsmart/tree/main/src/transaccionprocesadas/"
    click Unidad "https://github.com/isalin1/karbonsmart/tree/main/src/unidad/"
    click Users "https://github.com/isalin1/karbonsmart/tree/main/src/users/"
    click PC "https://github.com/isalin1/karbonsmart/blob/main/src/prisma/client.ts"
    click M "https://github.com/isalin1/karbonsmart/tree/main/prisma/migrations/"
    click Dock "https://github.com/isalin1/karbonsmart/blob/main/docker/docker-compose.yml"

    %% Styles
    classDef client fill:#AEDFF7,stroke:#333,stroke-width:2px;
    classDef nestjs fill:#FFEE93,stroke:#333,stroke-width:2px;
    classDef module fill:#CDE7BE,stroke:#333,stroke-width:2px;
    classDef prisma fill:#D1C4E9,stroke:#333,stroke-width:2px;
    classDef database fill:#F8B195,stroke:#333,stroke-width:2px;
    classDef docker fill:#B2DFDB,stroke:#333,stroke-width:2px;
```
