# kaibabenja/fullreservasapi architecture

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

- Interactive diagram: https://gitdiagram.com/kaibabenja/fullreservasapi
- Repository: https://github.com/kaibabenja/fullreservasapi

## Overview

##### Project type and purpose
- This is a TypeScript-based Node.js RESTful API ("fullreservas-api") providing reservation functionality for shops (e.g., restaurants).
- It follows a modular, layered architecture: each domain (address, bookings, contentblocks, memberships, shops, users) has its own controllers, services, models, routes, schemas and types.
- Key features (inferred from file tree): CRUD endpoints per domain, email notifications, file uploads, input validation, Swagger documentation, MySQL persistence via Sequelize, external integrations (Firebase, Cloudflare, Nodemailer).

##### File structure
- Top-level:
- src/app.ts – Express app setup and startup
- src/config – environment, database, middleware, external-service configs
- src/middlewares – request pre-processors (file upload, schema validation)
- src/modules – domain folders, each containing MVC + service + types + schemas
- src/routes – main router aggregator
- src/swagger-ui + src/swagger – API documentation setup
- src/utils – shared utilities (error handling, formatters, validators)
- Config & deployment files: .env.example, tsconfig.json, vercel.json
- Database: MySQL with Sequelize (initAssociations.ts, sequelize.config.ts).

## Diagram (Mermaid)

```mermaid
flowchart TB
    Client["Client"]:::external
    subgraph "Express Application"
        App["Express App"]:::app
        subgraph "Configuration Layer"
            dotenv["dotenv.config.ts"]:::config
            cors["cors.config.ts"]:::config
            multerCfg["multer.config.ts"]:::config
            firebaseCfg["firebase.ts"]:::config
            cloudflareCfg["cloudflare.config.ts"]:::config
            nodemailerCfg["nodemailer.config.ts"]:::config
            mysqlCfg["mysql.config.ts"]:::config
            sequelizeCfg["sequalize.config.ts"]:::config
            initAssoc["initAssociations.ts"]:::config
        end
        subgraph "Middleware Layer"
            upload["upload.ts"]:::middleware
            validateSchema["validateSchema.ts"]:::middleware
        end
        subgraph "Routing Layer"
            mainRoutes["main.routes.ts"]:::routing
            domainRoutes["Domain Routes"]:::routing
        end
        subgraph "Controller Layer"
            bookingsController["BookingsController"]:::controller
            usersController["UsersController"]:::controller
        end
        subgraph "Service Layer"
            shopsService["ShopsService"]:::service
            bookingsService["BookingsService"]:::service
        end
        subgraph "Persistence Layer"
            usersModel["UsersModel"]:::persistence
            bookingsModel["BookingsModel"]:::persistence
            db["MySQL Database"]:::db
        end
        subgraph "Utilities Layer"
            handleError["handleErrorResponse.ts"]:::utils
            validator["zodValidator.ts"]:::utils
            formatDate["formatDate.ts"]:::utils
            uuidVal["uuidValidator.ts"]:::utils
            streamToStr["streamToString.ts"]:::utils
            uuidToBuf["uuidToBuffer.ts"]:::utils
            formatName["formatName.ts"]:::utils
            validateEnv["validateEnv.ts"]:::utils
        end
        subgraph "Swagger UI"
            swaggerCore["swagger.ts"]:::swagger
            swaggerUI["SwaggerDark.css"]:::swagger
        end
    end
    subgraph "External Services"
        Firebase["Firebase"]:::externalService
        Cloudflare["Cloudflare"]:::externalService
        SMTP["SMTP (Nodemailer)"]:::externalService
    end

    Client --> App
    App --> dotenv
    App --> mysqlCfg
    App --> sequelizeCfg
    App --> initAssoc
    App --> mainRoutes
    App --> swaggerCore
    mainRoutes --> domainRoutes
    domainRoutes --> upload
    domainRoutes --> validateSchema
    validateSchema --> bookingsController
    validateSchema --> usersController
    bookingsController --> bookingsService
    usersController --> bookingsService
    bookingsService --> bookingsModel
    bookingsService --> shopsService
    shopsService --> usersModel
    bookingsModel --> db
    usersModel --> db
    shopsService --> handleError
    shopsService --> validator
    shopsService --> formatDate
    shopsService --> firebaseCfg
    shopsService --> cloudflareCfg
    shopsService --> nodemailerCfg
    shopsService --> streamToStr
    shopsService --> uuidVal
    shopsService --> uuidToBuf
    shopsService --> formatName
    shopsService --> validateEnv
    App --> swaggerUI
    bookingsService --> Firebase
    bookingsService --> Cloudflare
    bookingsService --> SMTP

    click App "https://github.com/kaibabenja/fullreservasapi/blob/main/src/app.ts"
    click dotenv "https://github.com/kaibabenja/fullreservasapi/blob/main/src/config/dotenv.config.ts"
    click cors "https://github.com/kaibabenja/fullreservasapi/blob/main/src/config/cors.config.ts"
    click multerCfg "https://github.com/kaibabenja/fullreservasapi/blob/main/src/config/multer.config.ts"
    click firebaseCfg "https://github.com/kaibabenja/fullreservasapi/blob/main/src/config/firebase.ts"
    click cloudflareCfg "https://github.com/kaibabenja/fullreservasapi/blob/main/src/config/cloudflare.config.ts"
    click nodemailerCfg "https://github.com/kaibabenja/fullreservasapi/blob/main/src/config/nodemailer.config.ts"
    click mysqlCfg "https://github.com/kaibabenja/fullreservasapi/blob/main/src/config/mysql.config.ts"
    click sequelizeCfg "https://github.com/kaibabenja/fullreservasapi/blob/main/src/config/sequalize.config.ts"
    click initAssoc "https://github.com/kaibabenja/fullreservasapi/blob/main/src/config/sequelize/initAssociations.ts"
    click upload "https://github.com/kaibabenja/fullreservasapi/blob/main/src/middlewares/upload.ts"
    click validateSchema "https://github.com/kaibabenja/fullreservasapi/blob/main/src/middlewares/validateSchema.ts"
    click mainRoutes "https://github.com/kaibabenja/fullreservasapi/blob/main/src/routes/main.routes.ts"
    click bookingsController "https://github.com/kaibabenja/fullreservasapi/blob/main/src/modules/bookings/controllers/bookings.controller.ts"
    click shopsService "https://github.com/kaibabenja/fullreservasapi/blob/main/src/modules/shops/services/shops.service.ts"
    click usersModel "https://github.com/kaibabenja/fullreservasapi/blob/main/src/modules/users/models/users.model.ts"
    click handleError "https://github.com/kaibabenja/fullreservasapi/blob/main/src/utils/handleErrorResponse.ts"
    click validator "https://github.com/kaibabenja/fullreservasapi/blob/main/src/utils/zodValidator.ts"
    click formatDate "https://github.com/kaibabenja/fullreservasapi/blob/main/src/utils/formatDate.ts"
    click uuidVal "https://github.com/kaibabenja/fullreservasapi/blob/main/src/utils/uuidValidator.ts"
    click streamToStr "https://github.com/kaibabenja/fullreservasapi/blob/main/src/utils/streamToString.ts"
    click uuidToBuf "https://github.com/kaibabenja/fullreservasapi/blob/main/src/utils/uuidToBuffer.ts"
    click formatName "https://github.com/kaibabenja/fullreservasapi/blob/main/src/utils/formatName.ts"
    click validateEnv "https://github.com/kaibabenja/fullreservasapi/blob/main/src/utils/validateEnv.ts"
    click swaggerCore "https://github.com/kaibabenja/fullreservasapi/blob/main/src/swagger/swagger.ts"
    click swaggerUI "https://github.com/kaibabenja/fullreservasapi/blob/main/src/swagger-ui/SwaggerDark.css"

    classDef external fill:#f9f,stroke:#333,stroke-width:1px
    classDef app fill:#bbf,stroke:#333,stroke-width:1px
    classDef config fill:#ddd,stroke:#333,stroke-width:1px
    classDef middleware fill:#bbf,stroke:#333,stroke-width:1px
    classDef routing fill:#bbf,stroke:#333,stroke-width:1px
    classDef controller fill:#bbf,stroke:#333,stroke-width:1px
    classDef service fill:#bbf,stroke:#333,stroke-width:1px
    classDef persistence fill:#afa,stroke:#333,stroke-width:1px
    classDef db fill:#afa,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef utils fill:#ccc,stroke:#333,stroke-width:1px
    classDef swagger fill:#bbf,stroke:#333,stroke-width:1px
    classDef externalService fill:#f96,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
```
