# vfaundez-dev/sistema_reserva_restaurantes architecture

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

- Interactive diagram: https://gitdiagram.com/vfaundez-dev/sistema_reserva_restaurantes
- Repository: https://github.com/vfaundez-dev/sistema_reserva_restaurantes

## Overview

##### Project type and purpose
- This is a Laravel-based RESTful API for a Restaurant Reservation System.
- Purpose: manage customers, tables, and reservations; secure access via JWT; role-based permissions; PostgreSQL storage; auto-generated Swagger docs.

##### File structure
- Top-level folders:
- app/ — core application code
– Http/Controllers (Auth, v1 controllers)
– Http/Middleware (permission guards)
– Http/Requests & Resources (validation & serialization)
– Models (Eloquent ORM)
– Policies (authorization rules)
– Repositories + Interfaces (repository pattern)
– Swagger (auto-docs: schemas, parameters, responses)
– Traits (Filterable)
- bootstrap/, config/, routes/ — framework startup, settings, route definitions
- database/ — migrations, factories, seeders
- public/ — entry point index.php, static files
- resources/js, resources/css, resources/views — optional front-end scaffolding (Tailwind, Vite)
- storage/ — cache, logs, API docs
- Configuration: .env, composer.json, package.json, phpunit.xml
- Uses JWT auth, Spatie permissions, L5-Swagger for API docs

##### README for additional insights
- Tech stack: PHP 8.2, Laravel 11, PostgreSQL 17.2, JWT
- Features: CRUD endpoints for users, customers, tables, reservations; filters, pagination; role/permission matrix
- Deployment: artisan serve, migrations, seeders
- External clients: Postman, Insomnia, any HTTP consumer

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients and Entry
    subgraph "Clients" 
        APIClient["API Client"]:::external
        SwaggerUI["Swagger UI"]:::external
    end

    subgraph "Transport Layer"
        HTTPServer["HTTP Server"]:::transport
    end

    subgraph "Routing & Middleware" 
        Router["Laravel Router<br/>(routes/api.php)"]:::appLayer
        AuthMW["JWT Auth Middleware<br/>(CheckPermission, ProtectAdminUser, PasswordChangePermission)"]:::appLayer
    end

    subgraph "Request Validation & Resources"
        subgraph Validation
            StoreUserReq["StoreUserRequest"]:::appLayer
            UpdateUserReq["UpdateUserRequest"]:::appLayer
            StoreCustomerReq["StoreCustomerRequest"]:::appLayer
            UpdateCustomerReq["UpdateCustomerRequest"]:::appLayer
            StoreTableReq["StoreTableRequest"]:::appLayer
            UpdateTableReq["UpdateTableRequest"]:::appLayer
            StoreReservationReq["StoreReservationRequest"]:::appLayer
            UpdateReservationReq["UpdateReservationRequest"]:::appLayer
        end
        subgraph Resources
            UserRes["UserResource/Collection"]:::appLayer
            CustomerRes["CustomerResource/Collection"]:::appLayer
            TableRes["TableResource/Collection"]:::appLayer
            ReservationRes["ReservationResource/Collection"]:::appLayer
            ApiResp["ApiResponse"]:::appLayer
        end
    end

    subgraph "Controllers & Business Logic"
        AuthCtrl["AuthController"]:::appLayer
        subgraph "v1 Controllers"
            UserCtrl["UserController"]:::appLayer
            CustomerCtrl["CustomerController"]:::appLayer
            TableCtrl["TableController"]:::appLayer
            ReservationCtrl["ReservationController"]:::appLayer
        end
        Policies["Authorization Policies"]:::appLayer
        FilterTrait["Filterable Trait"]:::appLayer
    end

    subgraph "Persistence Layer"
        subgraph "Repository Pattern"
            Interfaces["Repository Interfaces"]:::appLayer
            Repos["Repository Implementations"]:::appLayer
            DIProvider["RepositoryServiceProvider"]:::appLayer
        end
        Models["Eloquent Models"]:::appLayer
    end

    subgraph "Data Storage"
        DB[(PostgreSQL)]:::persistence
    end

    subgraph "Swagger Generation"
        SwaggerGen["SwaggerDoc/SwaggerResponses"]:::external
        SwaggerDefs["Swagger Schemas/Parameters/Requests/Responses"]:::external
    end

    %% Flows
    APIClient -->|HTTPS| HTTPServer
    SwaggerUI -->|Fetch OpenAPI JSON| SwaggerGen
    HTTPServer -->|routes/api.php| Router
    Router -->|Authenticate & Authorize| AuthMW
    AuthMW -->|Validate Requests| StoreUserReq & UpdateUserReq & StoreCustomerReq & UpdateCustomerReq & StoreTableReq & UpdateTableReq & StoreReservationReq & UpdateReservationReq
    AuthMW --> ControllersGroup
    ControllersGroup["Controllers"] --> AuthCtrl & UserCtrl & CustomerCtrl & TableCtrl & ReservationCtrl
    AuthCtrl -->|issues JWT| APIClient
    ControllersGroup -->|calls Policies| Policies
    ControllersGroup -->|uses Filterable| FilterTrait
    ControllersGroup -->|wrap responses| ApiResp
    ControllersGroup -->|use Resources| UserRes & CustomerRes & TableRes & ReservationRes
    ControllersGroup --> Interfaces
    Interfaces --> Repos
    Repos --> Models
    Models --> DB
    SwaggerGen --> SwaggerDefs
    SwaggerGen -->|serve docs| SwaggerUI

    %% Click events
    click Router "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/routes/api.php"
    click HTTPServer "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/public/index.php"
    click AuthMW "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Middleware/CheckPermission.php"
    click AuthMW "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Middleware/ProtectAdminUser.php"
    click AuthMW "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Middleware/PasswordChangePermission.php"
    click AuthCtrl "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Controllers/AuthController.php"
    click UserCtrl "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Controllers/v1/UserController.php"
    click CustomerCtrl "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Controllers/v1/CustomerController.php"
    click TableCtrl "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Controllers/v1/TableController.php"
    click ReservationCtrl "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Controllers/v1/ReservationController.php"
    click StoreUserReq "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Requests/StoreUserRequest.php"
    click UpdateUserReq "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Requests/UpdateUserRequest.php"
    click StoreCustomerReq "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Requests/StoreCustomerRequest.php"
    click UpdateCustomerReq "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Requests/UpdateCustomerRequest.php"
    click StoreTableReq "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Requests/StoreTableRequest.php"
    click UpdateTableReq "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Requests/UpdateTableRequest.php"
    click StoreReservationReq "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Requests/StoreReservationRequest.php"
    click UpdateReservationReq "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Requests/UpdateReservationRequest.php"
    click UserRes "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Resources/UserResource.php"
    click CustomerRes "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Resources/CustomerResource.php"
    click TableRes "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Resources/TableResource.php"
    click ReservationRes "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Resources/ReservationResource.php"
    click ApiResp "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Http/Responses/ApiResponse.php"
    click Models "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Models/User.php"
    click Interfaces "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Repositories/Interfaces/UserRepositoryInterface.php"
    click Repos "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Repositories/UserRepository.php"
    click DIProvider "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Providers/RepositoryServiceProvider.php"
    click SwaggerGen "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Swagger/SwaggerDoc.php"
    click SwaggerDefs "https://github.com/vfaundez-dev/sistema_reserva_restaurantes/blob/main/app/Swagger/Schemas/UserSchema.php"

    %% Styles
    classDef transport fill:#cce5ff,stroke:#3399ff,color:#000;
    classDef appLayer fill:#d4edda,stroke:#28a745,color:#000;
    classDef persistence fill:#ffe5b4,stroke:#ff9900,color:#000;
    classDef external fill:#f0e6ff,stroke:#9966cc,color:#000;
```
