# manuel-bautista-ramirez/project-residency-hotel-club architecture

> Architecture diagram of the GitHub repository manuel-bautista-ramirez/project-residency-hotel-club, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/manuel-bautista-ramirez/project-residency-hotel-club
- Repository: https://github.com/manuel-bautista-ramirez/project-residency-hotel-club

## Overview

1. **Overall shape**
   - This is a Node.js, server-rendered hotel club management system.
   - The backend is organized around feature modules under `src/modules`, with a central app bootstrap in `index.js` and shared routing from `src/router/routerGlobal.js`.
   - The app appears to use Express-style controllers, routers, middleware, MySQL persistence, and Handlebars views.

2. **Primary business domains**
   - The core subsystems are:
     - **Login / access control**
     - **Admin**
     - **Rooms**: reservations, rent, pricing, reports, PDFs, QR
     - **Membership**: family memberships, renewals, QR scanning, reports
     - **Entries**: daily entries for sports/amenities
     - **Store**: inventory and sales
   - Each domain has its own controllers, models, routes, and HBS views, which makes the architecture modular and diagram-friendly.

3. **Request flow**
   - Incoming HTTP requests are routed through the global router into module-specific routers.
   - Controllers coordinate the workflow, call models/services, then render Handlebars views or return API responses.
   - Validation middleware is inserted before controllers in several modules, especially login, admin, and rooms-related operations.

4. **Authentication and authorization boundary**
   - `src/modules/login` owns login, password reset, and session/auth behavior.
   - Its model (`userModel.js`) reads/writes user data in MySQL, while the controller handles the authentication lifecycle.
   - Shared validation middleware lives under `src/middlewares/validation`, including access denial and user-active checks, indicating a centralized authorization gate used across modules.

5. **Rooms subsystem**
   - The rooms module is one of the most complex parts of the repo.
   - It includes reservation, rent, calendar, price management, conversion from reservation to rent, and reporting.
   - It also has PDF-related controllers/routes and utility layers for PDF generation, QR generation, report PDFs, and directory validation.
   - The presence of a bundled FullCalendar library in `public/js/ModuleRooms/js/lib/fullcalendar@6.1.8` suggests a calendar-centric UI for reservations.

6. **Membership subsystem**
   - Membership management is split into create, edit, delete, list, manage, renewal, and reports flows.
   - It includes services for client and membership logic, which suggests a separation between domain orchestration and persistence.
   - Utilities include QR generation and number-to-words conversion, implying printable receipts or membership documents.
   - There is also a scan-QR view and client-side QR scanning support, making this subsystem a hybrid of admin workflows and check-in style operations.

7. **Entries subsystem**
   - The entries module handles daily access records, likely for sports areas or amenities referenced in the README.
   - It has a dedicated controller, model, routes, and report utilities.
   - The module also contains directory validation utilities, which likely support generated artifacts such as exported reports.

8. **Store subsystem**
   - The store module manages products, sales, sale details, inventory reports, and sales reports.
   - It is structured similarly to the other modules: controller, model, routes, and document/report helpers.
   - PDF generators and report generators indicate that sales and inventory outputs can be exported as documents.

9. **Shared services and infrastructure**
   - `src/services` contains cross-cutting services for connectivity, email, job queues, and WhatsApp.
   - These are not tied to a single domain and likely act as infrastructure adapters for notifications, background processing, and external communication.
   - `src/utils/directoryManager.js` and the various `validadorDirectorios.js` files show that generated files are stored and validated consistently across modules.

10. **Data layer**
    - MySQL is the main persistence layer, configured from `src/config/configuration.js` and `src/dataBase/connectionDataBase.js`.
    - `src/dataBase/database.sql` provides the schema and seed data, including default users and room records.
    - Each module has its own model layer, which suggests direct SQL-driven data access rather than a heavy ORM.

11. **Server-side rendering and shared UI**
    - Views are Handlebars templates under `src/views` and each module’s `views` directory.
    - Shared layout, navbar, footer, loading overlay, and reusable buttons live in `src/views/layouts` and `src/views/partials`.
    - This indicates an SSR application where most business pages are rendered server-side, with partial client-side enhancements.

12. **Client-side validation and interactive behavior**
    - `public/js` contains feature-specific browser scripts for form validation, live validation, and UI fixes.
    - Modules are mirrored on the client side: login, rooms, membership, entries, store.
    - This layer supports richer interaction but does not appear to be the primary source of business logic; the server remains authoritative.

13. **Document generation and file outputs**
    - PDFs and QR outputs are a first-class part of the architecture, especially in rooms and membership.
    - Puppeteer/Chrome is required for PDF generation, so rendering is not purely in-browser—it relies on a server-side headless browser workflow.
    - The README notes generated artifacts are stored under `public/uploads/rooms/`, making file storage part of the application boundary.

14. **Operational and support tooling**
    - `script/dbBackupScheduler.js` suggests scheduled database backup automation.
    - `nodemon.json` and package scripts indicate local development support.
    - Tailwind config and PostCSS show that frontend styling is built as part of the toolchain, but the app itself remains backend-led and template-driven.

15. **Architecture summary for a diagram**
    - A useful diagram would show:
      - Browser/client UI on the left
      - Express-style router/controller layer in the middle
      - Module-specific models/services beneath that
      - MySQL plus file/PDF/QR storage on the right
      - Shared services for email, WhatsApp, queueing, and connectivity as cross-cutting infrastructure
    - The biggest architectural boundary is between **feature modules** and **shared infrastructure**, with the rooms and membership modules carrying the most document-generation and operational complexity.

Main entry points: [`src/router/routerGlobal.js`](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/blob/main/src/router/routerGlobal.js) (Global Router), [`src/modules/rooms`](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/modules/rooms) (Rooms), [`src/dataBase`](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/dataBase) (MySQL Data), [`src/modules/membership`](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/modules/membership) (Membership)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_frontend["Client/UI"]
  node_n_hbs["Views<br/>SSR templates"]
  node_n_public_js["Client Scripts<br/>browser assets"]
end

subgraph group_grp_core["Server Core"]
  node_n_index["Bootstrap<br/>app entry<br/>[index.js]"]
  node_n_global_router["Global Router<br/>route hub<br/>[routerGlobal.js]"]
  node_n_validation["Shared Guards<br/>middleware"]
end

subgraph group_grp_domains["Feature Modules"]
  node_n_login["Login<br/>auth module"]
  node_n_admin["Admin"]
  node_n_rooms["Rooms<br/>booking module"]
  node_n_membership["Membership<br/>member module"]
  node_n_entries["Entries<br/>access module"]
  node_n_store["Store<br/>sales module"]
end

subgraph group_grp_infra["Infrastructure"]
  node_n_mysql[("MySQL Data<br/>database")]
  node_n_services["Shared Services<br/>adapters"]
  node_n_files["Files & PDFs<br/>artifact storage"]
  node_n_backup["Backup Job<br/>ops script"]
end

node_n_index -->|"mounts"| node_n_global_router
node_n_index -->|"uses"| node_n_validation
node_n_global_router -->|"routes to"| node_n_login
node_n_global_router -->|"routes to"| node_n_admin
node_n_global_router -->|"routes to"| node_n_rooms
node_n_global_router -->|"routes to"| node_n_membership
node_n_global_router -->|"routes to"| node_n_entries
node_n_global_router -->|"routes to"| node_n_store
node_n_login -->|"guards"| node_n_validation
node_n_admin -->|"guards"| node_n_validation
node_n_rooms -->|"guards"| node_n_validation
node_n_login -->|"reads/writes"| node_n_mysql
node_n_admin -->|"reads/writes"| node_n_mysql
node_n_rooms -->|"reads/writes"| node_n_mysql
node_n_membership -->|"reads/writes"| node_n_mysql
node_n_entries -->|"reads/writes"| node_n_mysql
node_n_store -->|"reads/writes"| node_n_mysql
node_n_login -->|"renders"| node_n_hbs
node_n_rooms -->|"renders"| node_n_hbs
node_n_membership -->|"renders"| node_n_hbs
node_n_entries -->|"renders"| node_n_hbs
node_n_store -->|"renders"| node_n_hbs
node_n_public_js -.->|"enhances"| node_n_login
node_n_public_js -.->|"enhances"| node_n_rooms
node_n_public_js -.->|"enhances"| node_n_membership
node_n_services -.->|"supports"| node_n_rooms
node_n_services -.->|"supports"| node_n_membership
node_n_services -.->|"supports"| node_n_store
node_n_rooms -->|"exports"| node_n_files
node_n_membership -->|"exports"| node_n_files
node_n_entries -->|"exports"| node_n_files
node_n_store -->|"exports"| node_n_files
node_n_backup -.->|"backs up"| node_n_mysql

click node_n_index "https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/blob/main/index.js"
click node_n_global_router "https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/blob/main/src/router/routerGlobal.js"
click node_n_validation "https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/middlewares/validation"
click node_n_login "https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/modules/login"
click node_n_admin "https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/modules/admin"
click node_n_rooms "https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/modules/rooms"
click node_n_membership "https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/modules/membership"
click node_n_entries "https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/modules/entries"
click node_n_store "https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/modules/store"
click node_n_hbs "https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/views"
click node_n_public_js "https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/public/js"
click node_n_mysql "https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/dataBase"
click node_n_services "https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/services"
click node_n_files "https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/utils"
click node_n_backup "https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/blob/main/script/dbBackupScheduler.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n_hbs,node_n_public_js toneBlue
class node_n_index,node_n_global_router,node_n_validation toneAmber
class node_n_login,node_n_admin,node_n_rooms,node_n_membership,node_n_entries,node_n_store toneMint
class node_n_mysql,node_n_services,node_n_files,node_n_backup toneRose
```

## Components

### Client/UI

Browser-facing views and scripts

- [Views](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/views): SSR templates · Shared layouts, partials, and module templates · `src/views`
- [Client Scripts](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/public/js): browser assets · Feature validation and interactive UI behavior · `public/js`

### Server Core

App bootstrap, routing, and shared middleware

- [Bootstrap](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/blob/main/index.js): app entry · Starts the server and wires configuration · `index.js`
- [Global Router](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/blob/main/src/router/routerGlobal.js): route hub · Dispatches requests into feature routers · `src/router/routerGlobal.js`
- [Shared Guards](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/middlewares/validation): middleware · Access control and user-state validation · `src/middlewares/validation`

### Feature Modules

Business domains implemented as modules

- [Login](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/modules/login): auth module · Authentication, reset flow, and session access · `src/modules/login`
- [Admin](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/modules/admin): admin module · Administration dashboard and management actions · `src/modules/admin`
- [Rooms](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/modules/rooms): booking module · Reservations, rent, pricing, reports, PDFs, and QR · `src/modules/rooms`
- [Membership](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/modules/membership): member module · Create, renew, manage, scan QR, and report memberships · `src/modules/membership`
- [Entries](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/modules/entries): access module · Daily entries and entry reports · `src/modules/entries`
- [Store](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/modules/store): sales module · Products, sales, inventory, and sales reporting · `src/modules/store`

### Infrastructure

Persistence, external services, and generated artifacts

- [MySQL Data](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/dataBase): database · Connection, schema, and seed data · `src/dataBase`
- [Shared Services](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/services): adapters · Connectivity, email, queues, and WhatsApp · `src/services`
- [Files & PDFs](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/tree/main/src/utils): artifact storage · Generated PDFs, QR codes, and directory management · `src/utils`
- [Backup Job](https://github.com/manuel-bautista-ramirez/project-residency-hotel-club/blob/main/script/dbBackupScheduler.js): ops script · Database backup scheduler · `script/dbBackupScheduler.js`

## Connections

- Bootstrap → Global Router: mounts · Bootstrap hands off request handling to the router
- Bootstrap → Shared Guards: uses · Application-wide request checks and access gates
- Global Router → Login: routes to · Authentication routes are delegated to the login module
- Global Router → Admin: routes to · Admin routes are delegated to the admin module
- Global Router → Rooms: routes to · Room booking and reporting routes are delegated
- Global Router → Membership: routes to · Membership workflows are delegated
- Global Router → Entries: routes to · Entry management routes are delegated
- Global Router → Store: routes to · Store routes are delegated
- Login → Shared Guards: guards · Login flow uses validation and active-user checks
- Admin → Shared Guards: guards · Admin actions are protected by shared checks
- Rooms → Shared Guards: guards · Rooms operations apply validation before controllers
- Login → MySQL Data: reads/writes · User records and authentication state are stored in MySQL
- Admin → MySQL Data: reads/writes · Admin data is persisted through the database layer
- Rooms → MySQL Data: reads/writes · Reservations, rents, prices, and PDFs are backed by MySQL
- Membership → MySQL Data: reads/writes · Membership and client data are persisted in MySQL
- Entries → MySQL Data: reads/writes · Daily entry records are stored in MySQL
- Store → MySQL Data: reads/writes · Products, sales, and inventory data are stored in MySQL
- Login → Views: renders · Login pages are server-rendered with Handlebars
- Rooms → Views: renders · Room workflows render calendars, forms, and reports
- Membership → Views: renders · Membership workflows render forms, lists, and scans
- Entries → Views: renders · Entry pages and reports are rendered server-side
- Store → Views: renders · Store dashboards and reports are rendered server-side
- Client Scripts → Login: enhances · Client-side validation supports login screens
- Client Scripts → Rooms: enhances · Client scripts support reservation, rent, pricing, and reports flows
- Client Scripts → Membership: enhances · Browser scripts support membership CRUD, renewal, and QR scanning
- Shared Services → Rooms: supports · Rooms can notify or process background work through shared services
- Shared Services → Membership: supports · Membership flows can use shared notification and queue adapters
- Shared Services → Store: supports · Store flows can use shared notification and queue adapters
- Rooms → Files & PDFs: exports · PDF, QR, and report artifacts are generated and stored
- Membership → Files & PDFs: exports · Membership QR and printable artifacts are generated
- Entries → Files & PDFs: exports · Entry reports can produce exported files
- Store → Files & PDFs: exports · Sales and inventory reports can produce exported files
- Backup Job → MySQL Data: backs up · Scheduled backup job targets the database
