# jhonnyyunda86/sistemalatribu architecture

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

- Interactive diagram: https://gitdiagram.com/jhonnyyunda86/sistemalatribu
- Repository: https://github.com/jhonnyyunda86/sistemalatribu

## Overview

1. **Overall shape**
   - This is a plain PHP application using a classic **MVC** structure, not a framework.
   - The core runtime is a restaurant management system with three main actor areas: **admin**, **mesero (waiter)**, and **cliente (customer)**.

2. **Entry points and request flow**
   - The primary web entry is **`public/index.php`**, which likely acts as the public front controller.
   - There is also a root **`index.php`**, which may route or redirect into the public app.
   - Requests flow from the browser into controllers in `controllers/`, which then load models and render views.

3. **Presentation layer**
   - UI is organized in `views/`.
   - Shared chrome lives in `views/layouts/` with `header.php`, `footer.php`, and `sidebar.php`.
   - Role-specific screens are separated under `views/dashboard/`, including:
     - `admin_*` views for management,
     - `cliente_*` views for customer self-service,
     - `mesero_*` views for waiter operations.
   - Authentication screens live in `views/usuarios/` (`login.php`, `registre.php`).

4. **Controller layer**
   - Controllers coordinate each business area:
     - `AuthController.php` for login/session handling.
     - `UsuarioController.php` and `UsuarioAdminController.php` for user management.
     - `ProductoController.php`, `MesaController.php`, `ReservaController.php`, `PedidoController.php`, `InventarioController.php`, `ReporteController.php` for domain operations.
   - The controllers are the main orchestration boundary between HTTP requests, domain models, and rendered views.

5. **Domain and data model**
   - The app has dedicated model classes in `models/` for the core restaurant entities:
     - `Usuario`, `UsuarioAdmin`
     - `Producto`
     - `Mesa`
     - `Reserva`
     - `Pedido`
     - `Inventario`
     - `Reporte`
   - This suggests a relational domain where orders, reservations, tables, products, inventory, and reporting are all persisted through model classes.

6. **Persistence and database**
   - Database configuration is centralized in **`config/database.php`**.
   - The repository includes SQL assets:
     - `sql/restaurante.sql` as the main schema/data bootstrap,
     - additional setup scripts like `inventario_setup.sql`, `menu_cliente_setup.sql`, and `agregar_activo.sql`.
   - `backup.sql` is also present, implying a full database snapshot or migration source.
   - The README notes corrected foreign keys and test users, so the DB schema is an important architectural dependency.

7. **Authentication and role-based access**
   - Authentication is built with native PHP password functions: **`password_hash`** and **`password_verify`**.
   - The system explicitly distinguishes roles: **admin**, **mesero**, and **cliente**.
   - The README mentions a correction from `rol`/`role`, which indicates role consistency is part of the app’s access-control boundary.

8. **Role-specific subsystems**
   - **Admin subsystem:** dashboards and modules for users, inventory, menu/products, tables, reservations, orders, and reports.
   - **Cliente subsystem:** dashboard, account view, reservation management, and order history/details.
   - **Mesero subsystem:** dashboard, reservation list, order list/details, and stock view.
   - These are separated in both controllers and views, which makes role-based navigation and permissions a key architectural concern.

9. **Operational/business flows**
   - The likely business flows are:
     - login → role resolution → dashboard selection,
     - admin manages catalog/table/order/inventory/report data,
     - client browses account/history and makes reservations,
     - waiter handles reservations, orders, and stock visibility.
   - `PedidoController`, `ReservaController`, and `MesaController` are likely the most workflow-heavy parts because they connect multiple entities.

10. **Inventory and reporting**
   - Inventory is treated as a first-class subsystem with both model and controller support.
   - Reporting is separate from transactional views, suggesting summary/analytics queries rather than CRUD only.
   - This separation implies that reporting reads across other domain tables instead of owning its own core data.

11. **Static and supporting assets**
   - Product images live under `img/productos/`, so the catalog likely includes media alongside product records.
   - The `docs/` folder contains design and analysis artifacts, but these are documentation rather than runtime components.
   - The docs are useful for understanding intended module boundaries and use cases, but they are not part of the production request path.

12. **Architecture boundary to diagram**
   - A useful diagram would place the **browser/UI** on one side, then **controllers**, then **models/database**.
   - Inside the UI layer, split the dashboards by role.
   - Inside the backend, show the main domain modules: authentication, user management, products/menu, tables, reservations, orders, inventory, and reporting.
   - The database should be shown as the central persistence layer accessed by all models, with SQL scripts as setup/bootstrap artifacts.

13. **What is notably not present**
   - There is no sign of a framework, API layer, queue worker, or external service integration.
   - The architecture appears self-contained: PHP server-side rendering plus MySQL-style relational persistence.

Main entry points: [`public/index.php`](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/public/index.php) (Public entry), [`views/dashboard`](https://github.com/jhonnyyunda86/sistemalatribu/tree/main/views/dashboard) (Dashboards), [`config/database.php`](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/config/database.php) (DB config), [`controllers/AuthController.php`](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/AuthController.php) (Auth)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry_ui["Entry & UI"]
  node_root_index["Root entry<br/>PHP entry<br/>[index.php]"]
  node_public_index["Public entry<br/>Front controller<br/>[index.php]"]
  node_ui_layouts["Layouts<br/>Shared UI"]
  node_ui_auth["Auth screens<br/>View set"]
  node_ui_dashboards["Dashboards<br/>View set"]
end

subgraph group_controllers["Controllers"]
  node_auth_controller["Auth<br/>Controller<br/>[AuthController.php]"]
  node_usuario_controller["Usuarios<br/>Controller"]
  node_usuario_admin_controller["Admin users<br/>Controller"]
  node_producto_controller["Productos<br/>Controller"]
  node_mesa_controller["Mesas<br/>Controller<br/>[MesaController.php]"]
  node_reserva_controller["Reservas<br/>Controller"]
  node_pedido_controller["Pedidos<br/>Controller"]
  node_inventario_controller["Inventario<br/>Controller"]
  node_reporte_controller["Reportes<br/>Controller"]
end

subgraph group_domain["Domain Models"]
  node_usuario_model["Usuario<br/>Model<br/>[Usuario.php]"]
  node_usuario_admin_model["UsuarioAdmin<br/>Model<br/>[UsuarioAdmin.php]"]
  node_producto_model["Producto<br/>Model<br/>[Producto.php]"]
  node_mesa_model["Mesa<br/>Model<br/>[Mesa.php]"]
  node_reserva_model["Reserva<br/>Model<br/>[Reserva.php]"]
  node_pedido_model["Pedido<br/>Model<br/>[Pedido.php]"]
  node_inventario_model["Inventario<br/>Model<br/>[Inventario.php]"]
  node_reporte_model["Reporte<br/>Model<br/>[Reporte.php]"]
end

subgraph group_persistence["Persistence"]
  node_db_config["DB config<br/>Database config<br/>[database.php]"]
  node_sql_bootstrap["SQL bootstrap<br/>SQL assets<br/>[restaurante.sql]"]
  node_product_images["Product images<br/>Static assets"]
end

node_root_index -->|"delegates"| node_public_index
node_public_index -->|"routes"| node_auth_controller
node_public_index -->|"routes"| node_usuario_controller
node_public_index -->|"routes"| node_usuario_admin_controller
node_public_index -->|"routes"| node_producto_controller
node_public_index -->|"routes"| node_mesa_controller
node_public_index -->|"routes"| node_reserva_controller
node_public_index -->|"routes"| node_pedido_controller
node_public_index -->|"routes"| node_inventario_controller
node_public_index -->|"routes"| node_reporte_controller
node_auth_controller -->|"renders"| node_ui_auth
node_auth_controller -->|"uses"| node_ui_layouts
node_usuario_controller -->|"renders"| node_ui_dashboards
node_usuario_admin_controller -->|"renders"| node_ui_dashboards
node_producto_controller -->|"renders"| node_ui_dashboards
node_mesa_controller -->|"renders"| node_ui_dashboards
node_reserva_controller -->|"renders"| node_ui_dashboards
node_pedido_controller -->|"renders"| node_ui_dashboards
node_inventario_controller -->|"renders"| node_ui_dashboards
node_reporte_controller -->|"renders"| node_ui_dashboards
node_auth_controller -->|"authenticates"| node_usuario_model
node_usuario_controller -->|"loads"| node_usuario_model
node_usuario_admin_controller -->|"loads"| node_usuario_admin_model
node_producto_controller -->|"loads"| node_producto_model
node_mesa_controller -->|"loads"| node_mesa_model
node_reserva_controller -->|"loads"| node_reserva_model
node_pedido_controller -->|"loads"| node_pedido_model
node_inventario_controller -->|"loads"| node_inventario_model
node_reporte_controller -->|"loads"| node_reporte_model
node_usuario_model -->|"connects"| node_db_config
node_usuario_admin_model -->|"connects"| node_db_config
node_producto_model -->|"connects"| node_db_config
node_mesa_model -->|"connects"| node_db_config
node_reserva_model -->|"connects"| node_db_config
node_pedido_model -->|"connects"| node_db_config
node_inventario_model -->|"connects"| node_db_config
node_reporte_model -->|"connects"| node_db_config
node_db_config -.->|"backed by"| node_sql_bootstrap
node_producto_controller -.->|"uses"| node_product_images
node_ui_dashboards -->|"composes"| node_ui_layouts

click node_root_index "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/index.php"
click node_public_index "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/public/index.php"
click node_ui_layouts "https://github.com/jhonnyyunda86/sistemalatribu/tree/main/views/layouts"
click node_ui_auth "https://github.com/jhonnyyunda86/sistemalatribu/tree/main/views/usuarios"
click node_ui_dashboards "https://github.com/jhonnyyunda86/sistemalatribu/tree/main/views/dashboard"
click node_auth_controller "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/AuthController.php"
click node_usuario_controller "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/UsuarioController.php"
click node_usuario_admin_controller "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/UsuarioAdminController.php"
click node_producto_controller "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/ProductoController.php"
click node_mesa_controller "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/MesaController.php"
click node_reserva_controller "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/ReservaController.php"
click node_pedido_controller "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/PedidoController.php"
click node_inventario_controller "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/InventarioController.php"
click node_reporte_controller "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/ReporteController.php"
click node_usuario_model "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/models/Usuario.php"
click node_usuario_admin_model "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/models/UsuarioAdmin.php"
click node_producto_model "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/models/Producto.php"
click node_mesa_model "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/models/Mesa.php"
click node_reserva_model "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/models/Reserva.php"
click node_pedido_model "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/models/Pedido.php"
click node_inventario_model "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/models/Inventario.php"
click node_reporte_model "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/models/Reporte.php"
click node_db_config "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/config/database.php"
click node_sql_bootstrap "https://github.com/jhonnyyunda86/sistemalatribu/blob/main/sql/restaurante.sql"
click node_product_images "https://github.com/jhonnyyunda86/sistemalatribu/tree/main/img/productos"

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_root_index,node_public_index,node_ui_layouts,node_ui_auth,node_ui_dashboards toneBlue
class node_auth_controller,node_usuario_controller,node_usuario_admin_controller,node_producto_controller,node_mesa_controller,node_reserva_controller,node_pedido_controller,node_inventario_controller,node_reporte_controller toneAmber
class node_usuario_model,node_usuario_admin_model,node_producto_model,node_mesa_model,node_reserva_model,node_pedido_model,node_inventario_model,node_reporte_model toneMint
class node_db_config,node_sql_bootstrap,node_product_images toneRose
```

## Components

### Entry & UI

Web entry points and rendered screens.

- [Root entry](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/index.php): PHP entry · Top-level index.php entry point. · `index.php`
- [Public entry](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/public/index.php): Front controller · Primary web entry used by the application. · `public/index.php`
- [Layouts](https://github.com/jhonnyyunda86/sistemalatribu/tree/main/views/layouts): Shared UI · Common header, footer, and sidebar chrome. · `views/layouts`
- [Auth screens](https://github.com/jhonnyyunda86/sistemalatribu/tree/main/views/usuarios): View set · Login and registration views. · `views/usuarios`
- [Dashboards](https://github.com/jhonnyyunda86/sistemalatribu/tree/main/views/dashboard): View set · Role-based admin, cliente, and mesero screens. · `views/dashboard`

### Controllers

HTTP orchestration and role-specific actions.

- [Auth](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/AuthController.php): Controller · Login, session, and role resolution. · `controllers/AuthController.php`
- [Usuarios](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/UsuarioController.php): Controller · Customer account and user management. · `controllers/UsuarioController.php`
- [Admin users](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/UsuarioAdminController.php): Controller · Administrative user management. · `controllers/UsuarioAdminController.php`
- [Productos](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/ProductoController.php): Controller · Menu and catalog operations. · `controllers/ProductoController.php`
- [Mesas](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/MesaController.php): Controller · Table state and table workflow. · `controllers/MesaController.php`
- [Reservas](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/ReservaController.php): Controller · Reservation workflow and scheduling. · `controllers/ReservaController.php`
- [Pedidos](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/PedidoController.php): Controller · Order workflow and order detail handling. · `controllers/PedidoController.php`
- [Inventario](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/InventarioController.php): Controller · Stock and inventory operations. · `controllers/InventarioController.php`
- [Reportes](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/controllers/ReporteController.php): Controller · Reporting and summary queries. · `controllers/ReporteController.php`

### Domain Models

Core restaurant entities and business state.

- [Usuario](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/models/Usuario.php): Model · Core user account entity. · `models/Usuario.php`
- [UsuarioAdmin](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/models/UsuarioAdmin.php): Model · Administrative user entity. · `models/UsuarioAdmin.php`
- [Producto](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/models/Producto.php): Model · Menu item and product entity. · `models/Producto.php`
- [Mesa](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/models/Mesa.php): Model · Restaurant table entity. · `models/Mesa.php`
- [Reserva](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/models/Reserva.php): Model · Reservation entity. · `models/Reserva.php`
- [Pedido](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/models/Pedido.php): Model · Order entity. · `models/Pedido.php`
- [Inventario](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/models/Inventario.php): Model · Stock and inventory entity. · `models/Inventario.php`
- [Reporte](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/models/Reporte.php): Model · Reporting model and summary data. · `models/Reporte.php`

### Persistence

Database configuration and SQL bootstrap assets.

- [DB config](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/config/database.php): Database config · Central database connection settings. · `config/database.php`
- [SQL bootstrap](https://github.com/jhonnyyunda86/sistemalatribu/blob/main/sql/restaurante.sql): SQL assets · Main schema, backups, and setup scripts. · `sql/restaurante.sql`
- [Product images](https://github.com/jhonnyyunda86/sistemalatribu/tree/main/img/productos): Static assets · Catalog image assets used by the UI. · `img/productos`

## Connections

- Root entry → Public entry: delegates · Root entry forwards into the public front controller.
- Public entry → Auth: routes · Incoming requests are dispatched to controllers.
- Public entry → Usuarios: routes · Incoming requests are dispatched to controllers.
- Public entry → Admin users: routes · Incoming requests are dispatched to controllers.
- Public entry → Productos: routes · Incoming requests are dispatched to controllers.
- Public entry → Mesas: routes · Incoming requests are dispatched to controllers.
- Public entry → Reservas: routes · Incoming requests are dispatched to controllers.
- Public entry → Pedidos: routes · Incoming requests are dispatched to controllers.
- Public entry → Inventario: routes · Incoming requests are dispatched to controllers.
- Public entry → Reportes: routes · Incoming requests are dispatched to controllers.
- Auth → Auth screens: renders · Authentication screens are rendered here.
- Auth → Layouts: uses · Shared layout chrome wraps auth and dashboard pages.
- Usuarios → Dashboards: renders · Customer account and history pages are rendered here.
- Admin users → Dashboards: renders · Admin management views are rendered here.
- Productos → Dashboards: renders · Menu and product screens are rendered here.
- Mesas → Dashboards: renders · Table management screens are rendered here.
- Reservas → Dashboards: renders · Reservation screens are rendered here.
- Pedidos → Dashboards: renders · Order workflow screens are rendered here.
- Inventario → Dashboards: renders · Inventory screens are rendered here.
- Reportes → Dashboards: renders · Reporting screens are rendered here.
- Auth → Usuario: authenticates · Login and session checks rely on user records.
- Usuarios → Usuario: loads · User account operations use the user model.
- Admin users → UsuarioAdmin: loads · Admin user operations use the admin user model.
- Productos → Producto: loads · Product CRUD and menu data use the product model.
- Mesas → Mesa: loads · Table operations use the table model.
- Reservas → Reserva: loads · Reservation workflow uses the reservation model.
- Pedidos → Pedido: loads · Order workflow uses the order model.
- Inventario → Inventario: loads · Inventory workflow uses the stock model.
- Reportes → Reporte: loads · Reporting uses the report model.
- Usuario → DB config: connects · Models share the centralized database configuration.
- UsuarioAdmin → DB config: connects · Models share the centralized database configuration.
- Producto → DB config: connects · Models share the centralized database configuration.
- Mesa → DB config: connects · Models share the centralized database configuration.
- Reserva → DB config: connects · Models share the centralized database configuration.
- Pedido → DB config: connects · Models share the centralized database configuration.
- Inventario → DB config: connects · Models share the centralized database configuration.
- Reporte → DB config: connects · Models share the centralized database configuration.
- DB config → SQL bootstrap: backed by · Database config points to the SQL schema and setup assets.
- Productos → Product images: uses · Product views likely reference catalog imagery.
- Dashboards → Layouts: composes · Dashboard screens share common layout components.
