# marcelomatheus/pizza-fresh-server-nest architecture

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

- Interactive diagram: https://gitdiagram.com/marcelomatheus/pizza-fresh-server-nest
- Repository: https://github.com/marcelomatheus/pizza-fresh-server-nest

## Overview

##### Project Type & Purpose
- That this is a backend application built using the NestJS framework.
- Its purpose is to provide server-side functionality including authentication, product orders, table management, and user handling.
- It uses Prisma for database access, indicating an ORM-based interaction with a relational database.

##### File Structure
- Notice the "src" folder as the main source of business logic. Within it, there are sub-folders like "auth", "order", "product", "table", "user", and "prisma". Each of these modules follows the NestJS paradigm using controllers, services, DTOs, and entities.
- The “prisma” folder at both the root level and inside src highlights database migration and schema definitions. This separation emphasizes how persistence is decoupled from the business logic.
- Utility files (e.g., in "src/utils") and configuration files (e.g., .env.example, tsconfig.json) indicate environment and build settings.
- Testing files and scripts (e.g., in both "test" and unit test files within modules) signal the project's emphasis on maintainability and testability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Level - External Request and Core
    HTTPRequest["HTTP Request"]:::core
    MainEntry["main.ts"]:::core
    AppModule["app.module.ts"]:::core

    HTTPRequest -->|"starts"| MainEntry
    MainEntry -->|"initializes"| AppModule

    %% Modules Layer
    subgraph "Modules Layer"
        %% Auth Module
        subgraph "Auth Module"
            AuthController["Auth Controller"]:::controller
            AuthService["Auth Service"]:::service
            AuthController -->|"calls"| AuthService
        end

        %% Order Module
        subgraph "Order Module"
            OrderController["Order Controller"]:::controller
            OrderService["Order Service"]:::service
            OrderController -->|"calls"| OrderService
        end

        %% Product Module
        subgraph "Product Module"
            ProductController["Product Controller"]:::controller
            ProductService["Product Service"]:::service
            ProductController -->|"calls"| ProductService
        end

        %% Table Module
        subgraph "Table Module"
            TableController["Table Controller"]:::controller
            TableService["Table Service"]:::service
            TableController -->|"calls"| TableService
        end

        %% User Module
        subgraph "User Module"
            UserController["User Controller"]:::controller
            UserService["User Service"]:::service
            UserController -->|"calls"| UserService
        end
    end

    %% AppModule routes to each module's controller
    AppModule -->|"routes"| AuthController
    AppModule -->|"routes"| OrderController
    AppModule -->|"routes"| ProductController
    AppModule -->|"routes"| TableController
    AppModule -->|"routes"| UserController

    %% Modules calling the Prisma Service for DB operations
    AuthService ---|"DBquery"| PrismaService
    OrderService ---|"DBquery"| PrismaService
    ProductService ---|"DBquery"| PrismaService
    TableService ---|"DBquery"| PrismaService
    UserService ---|"DBquery"| PrismaService

    %% Prisma subgraph - Database Integration
    subgraph "Prisma Integration"
        PrismaModule["Prisma Module"]:::prisma
        PrismaService["Prisma Service"]:::prisma
        PrismaModule --> PrismaService
        PrismaService -->|"executes"| Database["Database"]:::db
        PrismaSchema["Prisma Schema"]:::prisma
        PrismaMigrations["Prisma Migrations"]:::prisma
        PrismaSchema ---|"defines"| PrismaModule
        PrismaMigrations ---|"migrates"| PrismaModule
    end

    %% Utility / Shared Services
    Utils["Utils (Shared)"]:::util
    AppModule ---|"uses"| Utils

    %% Click Events
    click MainEntry "https://github.com/marcelomatheus/pizza-fresh-server-nest/blob/production/src/main.ts"
    click AppModule "https://github.com/marcelomatheus/pizza-fresh-server-nest/blob/production/src/app.module.ts"
    click AuthController "https://github.com/marcelomatheus/pizza-fresh-server-nest/tree/production/src/auth"
    click AuthService "https://github.com/marcelomatheus/pizza-fresh-server-nest/tree/production/src/auth"
    click OrderController "https://github.com/marcelomatheus/pizza-fresh-server-nest/tree/production/src/order"
    click OrderService "https://github.com/marcelomatheus/pizza-fresh-server-nest/tree/production/src/order"
    click ProductController "https://github.com/marcelomatheus/pizza-fresh-server-nest/tree/production/src/product"
    click ProductService "https://github.com/marcelomatheus/pizza-fresh-server-nest/tree/production/src/product"
    click TableController "https://github.com/marcelomatheus/pizza-fresh-server-nest/tree/production/src/table"
    click TableService "https://github.com/marcelomatheus/pizza-fresh-server-nest/tree/production/src/table"
    click UserController "https://github.com/marcelomatheus/pizza-fresh-server-nest/tree/production/src/user"
    click UserService "https://github.com/marcelomatheus/pizza-fresh-server-nest/tree/production/src/user"
    click PrismaModule "https://github.com/marcelomatheus/pizza-fresh-server-nest/tree/production/src/prisma"
    click PrismaService "https://github.com/marcelomatheus/pizza-fresh-server-nest/tree/production/src/prisma"
    click PrismaSchema "https://github.com/marcelomatheus/pizza-fresh-server-nest/blob/production/prisma/schema.prisma"
    click PrismaMigrations "https://github.com/marcelomatheus/pizza-fresh-server-nest/tree/production/prisma/migrations"
    click Utils "https://github.com/marcelomatheus/pizza-fresh-server-nest/tree/production/src/utils"

    %% Styles
    classDef core fill:#f9c,stroke:#333,stroke-width:2px;
    classDef controller fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef service fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef prisma fill:#ffeb99,stroke:#333,stroke-width:2px;
    classDef db fill:#ffa500,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5;
    classDef util fill:#d3d3d3,stroke:#333,stroke-width:2px;
```
