# winnicius-moura/calc-mp-api architecture

> Architecture diagram of the GitHub repository winnicius-moura/calc-mp-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/winnicius-moura/calc-mp-api
- Repository: https://github.com/winnicius-moura/calc-mp-api

## Overview

##### Project type and purpose
- This is a NestJS-based Node.js monolithic API server starter.
- Purpose: provide a structured, scalable backend with built-in support for modules, configuration, Swagger, and TypeORM.

##### File structure
- Top-level files: package.json, nest-cli.json, tsconfig.json, eslint.config.mjs, README.md
- src/
- app.module.ts – root module
- app.controller.ts / app.controller.spec.ts – HTTP controller + unit tests
- app.service.ts – business-logic service
- infrastructure/config/
– swagger.config.ts – Swagger/OpenAPI setup
– typeorm.config.ts – database connection via TypeORM
- main.ts – application bootstrap
- test/ – e2e tests
- config/build & lint files → build, test, and deployment scripts

##### README for additional insights
- Uses NestJS modules, controllers, services, TypeORM, and Swagger.
- Encourages production builds, live-reload, tests, and Mau/AWS deployment.

##### Elements
- Client → HTTP Server (HTTP request)
- HTTP Server → AppController (route handler)
- AppController → AppService (method calls)
- AppService → TypeORM Module → Database (SQL queries)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entities
    Client["Client"]:::external
    HTTP["HTTP Server<br/>(Express/Fastify)"]:::server

    %% NestJS Application
    subgraph "NestJS Application"
        direction TB
        Main["Bootstrap (main.ts)"]:::bootstrap
        AppMod["AppModule"]:::nest

        subgraph "Module Components"
            direction TB
            Controller["AppController"]:::nest
            Service["AppService"]:::nest

            subgraph "Infrastructure Config"
                direction TB
                SwaggerCfg["SwaggerConfig"]:::config
                TypeOrmCfg["TypeOrmConfig"]:::config
            end

            TypeOrmMod["TypeORM Module"]:::orm
        end
    end

    DB["Database"]:::db

    %% Tests
    subgraph "Tests"
        direction TB
        ControllerTest["AppController Unit Tests"]:::test
        E2ETest["End-to-End Tests"]:::test
        E2EConf["E2E Test Config"]:::test
    end

    %% Project Config Files
    subgraph "Project Configs"
        direction TB
        Package["package.json"]:::configfile
        NestCLI["nest-cli.json"]:::configfile
        Tsconfig["tsconfig.json"]:::configfile
        TsconfigBuild["tsconfig.build.json"]:::configfile
        ESLint["eslint.config.mjs"]:::configfile
    end

    %% Request Flow
    Client -->|HTTP Request| HTTP
    HTTP -->|handles request| Controller
    Controller -->|calls| Service
    Service -->|queries| TypeOrmMod
    TypeOrmMod -->|SQL Queries| DB

    %% Startup Flow
    Main -.->|boots NestFactory| AppMod
    AppMod -.->|loads| SwaggerCfg
    AppMod -.->|loads| TypeOrmCfg

    %% Click Events
    click AppMod "https://github.com/winnicius-moura/calc-mp-api/blob/main/src/app.module.ts"
    click Controller "https://github.com/winnicius-moura/calc-mp-api/blob/main/src/app.controller.ts"
    click ControllerTest "https://github.com/winnicius-moura/calc-mp-api/blob/main/src/app.controller.spec.ts"
    click Service "https://github.com/winnicius-moura/calc-mp-api/blob/main/src/app.service.ts"
    click Main "https://github.com/winnicius-moura/calc-mp-api/blob/main/src/main.ts"
    click SwaggerCfg "https://github.com/winnicius-moura/calc-mp-api/blob/main/src/infrastructure/config/swagger.config.ts"
    click TypeOrmCfg "https://github.com/winnicius-moura/calc-mp-api/blob/main/src/infrastructure/config/typeorm.config.ts"
    click E2ETest "https://github.com/winnicius-moura/calc-mp-api/blob/main/test/app.e2e-spec.ts"
    click E2EConf "https://github.com/winnicius-moura/calc-mp-api/blob/main/test/jest-e2e.json"
    click Package "https://github.com/winnicius-moura/calc-mp-api/blob/main/package.json"
    click NestCLI "https://github.com/winnicius-moura/calc-mp-api/blob/main/nest-cli.json"
    click Tsconfig "https://github.com/winnicius-moura/calc-mp-api/blob/main/tsconfig.json"
    click TsconfigBuild "https://github.com/winnicius-moura/calc-mp-api/blob/main/tsconfig.build.json"
    click ESLint "https://github.com/winnicius-moura/calc-mp-api/blob/main/eslint.config.mjs"

    %% Styles
    classDef external fill:#D5DBDB,stroke:#333,stroke-width:1px
    classDef server fill:#F2F4F4,stroke:#333,stroke-width:1px
    classDef bootstrap fill:#85C1E9,stroke:#333,stroke-width:1px
    classDef nest fill:#AED6F1,stroke:#1B4F72,stroke-width:1px
    classDef config fill:#ABEBC6,stroke:#1D8348,stroke-width:1px
    classDef orm fill:#AED6F1,stroke:#1B4F72,stroke-width:1px
    classDef db fill:#F5B041,stroke:#7D6608,stroke-width:1px
    classDef test fill:#D2B4DE,stroke:#512E5F,stroke-width:1px
    classDef configfile fill:#E8DAEF,stroke:#633974,stroke-width:1px
```
