# jsanchezl12/apis_miso architecture

> Architecture diagram of the GitHub repository jsanchezl12/apis_miso, 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/jsanchezl12/apis_miso
- Repository: https://github.com/jsanchezl12/apis_miso

## Overview

##### Main Components & Their Roles
- API Gateway / Entry Point: Represent the primary NestJS application (main.ts) that routes incoming requests.
- Authentication Module: Highlight the auth module, JWT and local strategies, and the associated guards, showing how they protect the API endpoints.
- Domain Modules: For each business domain (culturagastronomica, gastroculture_pais, gastroculture_producto, gastroculture_receta, gastroculture_restaurante, ingrediente, pais, producto, receta, region, restaurante, and user) create separate nodes. These modules include controllers (for REST), resolvers (for GraphQL), DTOs, entities, and services. This division underlines the modular architecture and separation of concerns.
- GraphQL Layer: Indicate that many modules expose GraphQL resolvers and that there is a GraphQL schema (src/schema.gql) that underpins these endpoints. This layer acts as an alternative API interface alongside REST.
- Shared Utilities & Interceptors: Show a shared module that includes error handling, security constants, and testing utilities that are common across the project.
- External Integrations: Include external systems such as the continuous integration tools (Jenkins, SonarQube) and client API testing collections (Postman collections) which are used for validation and monitoring. These highlight the CI/CD and testing pipeline.
- Database Interaction (if applicable): Although the files don’t show a dedicated database folder explicitly, the presence of entity and seeding scripts indicates that a database is integrated. Represent a “Database” node that interacts with the domain modules via repositories or ORM layers.

##### Relationships & Interactions
- Internal Dependencies: Indicate that shared utilities, interceptors, and error handlers are used across modules (a common “shared” component connected to all business modules).
- CI/CD Pipeline: Optionally, include a side note that the project integrates automated test suites (unit tests and JMeter tests), and that Jenkins and SonarQube monitor code quality and deployments.

##### Architectural Patterns & Design Principles
- Modular Architecture: Emphasize that each domain is isolated within its own module – promoting separation of concerns, scalability, and maintainability.
- Layered Design: The structure follows a typical layered approach with a presentation layer (controllers/resolvers), business logic layer (services), and a data-access layer (entities, and scripts for database operations).
- Security and Testing: Highlight the use of guards, strategies, and testing utilities, underscoring best practices in secure and reliable API design.

- Branch out from the API gateway to separate components:
- Authentication Layer (with JWT/Local strategies)
- GraphQL API Router (with resolvers and schema)
- API endpoint handlers (controllers/resolvers)
- Business logic (services)
- Auxiliary components (shared errors, interceptors, utilities)
- Side notes or legends indicating CI/CD integrations and testing aspects.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["API Consumers"]:::client
    B["NestJS API Gateway"]:::gateway
    C["Auth Module"]:::auth

    subgraph "Domain Modules"
        D["Culturagastronomica Module"]:::domain
        E["Gastroculture_Pais Module"]:::domain
        F["Gastroculture_Producto Module"]:::domain
        G["Gastroculture_Receta Module"]:::domain
        H["Gastroculture_Restaurante Module"]:::domain
        I["Ingrediente Module"]:::domain
        J["Pais Module"]:::domain
        K["Producto Module"]:::domain
        L["Receta Module"]:::domain
        M["Region Module"]:::domain
        N["Restaurante Module"]:::domain
        O["User Module"]:::domain
    end

    subgraph "GraphQL Layer"
        P["GraphQL Schema"]:::graphql
        Q["GraphQL Resolvers"]:::graphql
    end

    R["Shared Utilities"]:::shared

    S["Database"]:::database

    subgraph "Database Scripts"
        T["Database Seeder"]:::script
        U["Database Cleaner"]:::script
        V["SQL Inserts"]:::script
    end

    subgraph "External Integrations"
        W["Jenkinsfile"]:::external
        X["SonarQube Config"]:::external
        Y["Postman Collections"]:::external
    end

    A --> B
    B --> C
    B --> D
    B --> E
    B --> F
    B --> G
    B --> H
    B --> I
    B --> J
    B --> K
    B --> L
    B --> M
    B --> N
    B --> O
    B --> P
    B --> Q
    B --> R

    D --> S
    E --> S
    F --> S
    G --> S
    H --> S
    I --> S
    J --> S
    K --> S
    L --> S
    M --> S
    N --> S
    O --> S

    T --- S
    U --- S
    V --- S

    W --- B
    X --- B
    Y --- B

    P --- Q

    click B "https://github.com/jsanchezl12/apis_miso/blob/main/src/main.ts"
    click C "https://github.com/jsanchezl12/apis_miso/tree/main/src/auth"
    click D "https://github.com/jsanchezl12/apis_miso/tree/main/src/culturagastronomica"
    click E "https://github.com/jsanchezl12/apis_miso/tree/main/src/gastroculture_pais"
    click F "https://github.com/jsanchezl12/apis_miso/tree/main/src/gastroculture_producto"
    click G "https://github.com/jsanchezl12/apis_miso/tree/main/src/gastroculture_receta"
    click H "https://github.com/jsanchezl12/apis_miso/tree/main/src/gastroculture_restaurante"
    click I "https://github.com/jsanchezl12/apis_miso/tree/main/src/ingrediente"
    click J "https://github.com/jsanchezl12/apis_miso/tree/main/src/pais"
    click K "https://github.com/jsanchezl12/apis_miso/tree/main/src/producto"
    click L "https://github.com/jsanchezl12/apis_miso/tree/main/src/receta"
    click M "https://github.com/jsanchezl12/apis_miso/tree/main/src/region"
    click N "https://github.com/jsanchezl12/apis_miso/tree/main/src/restaurante"
    click O "https://github.com/jsanchezl12/apis_miso/tree/main/src/user"
    click P "https://github.com/jsanchezl12/apis_miso/blob/main/src/schema.gql"
    click Q "https://github.com/jsanchezl12/apis_miso/tree/main/graphql"
    click R "https://github.com/jsanchezl12/apis_miso/tree/main/src/shared"
    click T "https://github.com/jsanchezl12/apis_miso/blob/main/scripts_cache/database-seeder.ts"
    click U "https://github.com/jsanchezl12/apis_miso/blob/main/scripts_cache/database-cleaner.ts"
    click V "https://github.com/jsanchezl12/apis_miso/tree/main/scripts_cache/sql_inserts"
    click W "https://github.com/jsanchezl12/apis_miso/tree/main/Jenkinsfile"
    click X "https://github.com/jsanchezl12/apis_miso/blob/main/sonar-project.properties"
    click Y "https://github.com/jsanchezl12/apis_miso/tree/main/api_collection"

    classDef client fill:#FFEBEE,stroke:#B71C1C,stroke-width:2px;
    classDef gateway fill:#E3F2FD,stroke:#1565C0,stroke-width:2px;
    classDef auth fill:#FCE4EC,stroke:#AD1457,stroke-width:2px;
    classDef domain fill:#E8F5E9,stroke:#2E7D32,stroke-width:2px;
    classDef graphql fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;
    classDef shared fill:#ECEFF1,stroke:#455A64,stroke-width:2px;
    classDef database fill:#E0F2F1,stroke:#00695C,stroke-width:2px;
    classDef script fill:#F3E5F5,stroke:#6A1B9A,stroke-width:2px;
    classDef external fill:#E1F5FE,stroke:#0277BD,stroke-width:2px;
```
