# zphek/pt_pasi architecture

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

- Interactive diagram: https://gitdiagram.com/zphek/pt_pasi
- Repository: https://github.com/zphek/pt_pasi

## Overview

##### Main Components
- Frontend Client:
- Use of the app directory with separate “logged” and “unlogged” routes, implying different user flows for authenticated versus non-authenticated users.
- Modular UI components (customers, products, reservations, UI libraries, etc.) that form the user interface.
- Backend Server:
- It as “NestJS API Server” since the server makes use of NestJS modules, controllers, and services with clearly defined modules (auth, customer, product, reservation).
- Use of Prisma for data access and how the backend is structured around RESTful (or possibly GraphQL if applicable, but here it seems RESTful) controllers.
- External Services:
- “MongoDB Atlas” as the main database (as indicated by the DATABASE_URL).
- “Supabase” for authentication, given the SUPABASE_URL, SUPABASE_KEY, and associated auth strategy/guard in the server.
- Containerization & Infrastructure:
- “Docker & Docker Compose” – show that both the client and server have individual Dockerfiles, and the overall startup is controlled through docker-compose.yml.
- Network infrastructure if reverse proxies, load balancers, or environment variables are managed via Docker.

##### Relationships and Interactions
- Also, the Backend communicates with Supabase (illustrated by the auth modules, guards, and strategy) for user authentication and session validation.
- Within the Docker environment, indicate that both the frontend and backend containers communicate over a shared network (as described in docker-compose setup).

##### Architectural Patterns and Design Principles
- The Frontend displays a clear separation between authentication routes (“unlogged”) and authenticated (“logged”) pages, which is a key aspect to capture.
- The Backend uses NestJS’s modular architecture – identify modules for auth, customer, product, and reservation as distinct components. These modules encapsulate controllers, services, DTOs, and even middleware.
- The use of Prisma in the “server/src/prisma” folder signifies the repository pattern for database operations.
- API Gateway pattern where the backend serves as the main entry point for data and logic processing.

##### Including Relevant Technologies
- Next.js (frontend) with TypeScript, Tailwind CSS, and dynamic routes.
- NestJS (backend) with TypeScript, Docker integration, and Prisma.
- External services such as MongoDB Atlas and Supabase.

##### Detail Level
- Using a layered approach where you first display a high-level overview (client, server, external services) and then break down each major system (e.g., list out backend modules like auth, customer, etc.) in a subdiagram.

- Drill down into the internal architecture of each (e.g., for the server, list modules and how they interact).
- Containerization aspect with Docker, ensuring that the inter-service communication is covered.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Docker Environment Container
    subgraph "Docker Environment"
        direction TB
        subgraph "Frontend Container"
            direction TB
            F["Next.js Frontend"]:::frontend
            FR["Logged Routes"]:::frontend
            FU["Unlogged Routes"]:::frontend
            FC["Modular UI Components"]:::frontend
            UT["Utility Functions"]:::frontend
            F --> FR
            F --> FU
            F --> FC
            F --> UT
        end
        subgraph "Backend Container"
            direction TB
            B["NestJS API Server"]:::backend
            BA["Auth Module"]:::backend
            BC["Customer Module"]:::backend
            BP["Product Module"]:::backend
            BR["Reservation Module"]:::backend
            P["Prisma Integration"]:::backend
            B --> BA
            B --> BC
            B --> BP
            B --> BR
            B --> P
        end
    end

    %% External Services
    DB[(MongoDB Atlas)]:::database
    SB(("Supabase")):::external

    %% Deployment Components
    subgraph "Deployment"
        direction TB
        D1["Root Dockerfile"]:::deployment
        D2["Client Dockerfile"]:::deployment
        D3["Server Dockerfile"]:::deployment
        DC["docker-compose.yml"]:::deployment
    end

    %% Data Flow Connections
    F -->|"API_requests"| B
    UT -->|"Uses_API"| B
    BA -->|"ValidatesAuth"| SB
    P -->|"DB_Operations"| DB

    %% Deployment Connections (Orchestration)
    DC --- F
    DC --- B
    D2 --- F
    D3 --- B

    %% Click Events for Frontend
    click F "https://github.com/zphek/pt_pasi/tree/main/client/"
    click FR "https://github.com/zphek/pt_pasi/tree/main/client/app/(logged)/"
    click FU "https://github.com/zphek/pt_pasi/tree/main/client/app/(unlogged)/"
    click FC "https://github.com/zphek/pt_pasi/tree/main/client/components/"
    click UT "https://github.com/zphek/pt_pasi/tree/main/client/utilites/"

    %% Click Events for Backend
    click B "https://github.com/zphek/pt_pasi/tree/main/server/"
    click BA "https://github.com/zphek/pt_pasi/tree/main/server/src/auth/"
    click BC "https://github.com/zphek/pt_pasi/tree/main/server/src/customer/"
    click BP "https://github.com/zphek/pt_pasi/tree/main/server/src/product/"
    click BR "https://github.com/zphek/pt_pasi/tree/main/server/src/reservation/"
    click P "https://github.com/zphek/pt_pasi/tree/main/server/prisma/"

    %% Click Events for Deployment Files
    click D1 "https://github.com/zphek/pt_pasi/tree/main/Dockerfile"
    click D2 "https://github.com/zphek/pt_pasi/tree/main/client/Dockerfile"
    click D3 "https://github.com/zphek/pt_pasi/tree/main/server/Dockerfile"
    click DC "https://github.com/zphek/pt_pasi/blob/main/docker-compose.yml"

    %% Styling
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef external fill:#e2e3e5,stroke:#6c757d,stroke-width:2px,stroke-dasharray:5,5;
    classDef deployment fill:#fff3cd,stroke:#856404,stroke-width:2px;
```
