# darwin-1bit/bingomaster architecture

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

- Interactive diagram: https://gitdiagram.com/darwin-1bit/bingomaster
- Repository: https://github.com/darwin-1bit/bingomaster

## Overview

1. **Overall shape**
   - This is a custom PHP/MySQL application built around a classic MVC-style structure: `controllers/`, `models/`, and `views/`.
   - The main domain is bingo sales operations: cartones, ventas, entregas, comisiones, metas, notificaciones, and user/vendor administration.

2. **Entry point and request flow**
   - `public/index.php` is the public entrypoint and likely acts as the front controller.
   - Requests enter through `public/`, are routed into controller classes in `controllers/`, which then coordinate model access and select a view for rendering.

3. **Presentation layer**
   - The UI is split into reusable layouts under `views/layouts/` and feature pages under `views/`.
   - Feature views are organized by workflow: authentication, dashboards, ventas, cartones, entregas, metas, notificaciones, usuarios, and vendedores.

4. **Domain/application layer**
   - Controllers represent the main business workflows:
     - `AuthController`, `RecuperarController` for login and password recovery
     - `VentaController`, `VentaVendedorController` for sales flows
     - `CartonController` for bingo card management
     - `EntregaController` for delivery/fulfillment
     - `MetaController` and `ComisionController` for goals and commissions
     - `NotificacionController` and `NotificacionVendedorController` for messaging/alerts
     - `UsuarioController`, `AdminUsuarioController`, `VendedorController` for administration and role-specific management
   - The controller split suggests separate admin and vendedor experiences.

5. **Data layer**
   - Models under `models/` encapsulate persistence for core entities: usuarios, ventas, cartones, entregas, metas, and notificaciones.
   - This layer is the primary boundary to MySQL and likely contains the SQL queries and record shaping used by controllers.

6. **Database and schema**
   - Database configuration lives in `config/database.php`.
   - The schema and seed data appear to be defined in `sql/bingomaster.sql`.
   - The application is designed to depend on a MySQL backend and is not structured around an ORM; the repo suggests hand-managed relational tables.

7. **Email and notifications**
   - `config/mail.php` indicates outbound email is a first-class integration, likely for password recovery and user notifications.
   - Notifications are also modeled in the app itself, so there is both application-level notification storage and external email delivery.

8. **Role-based areas**
   - The views and controllers are divided around two major user roles: admin and vendedor.
   - Separate dashboards exist in `views/dashboard/admin.php` and `views/dashboard/vendedor.php`, which indicates role-specific navigation, KPIs, and available actions.

9. **Core business processes**
   - Sales are central: `ventas`, `mis_ventas`, and `registrar_venta` show a transaction flow from capture to reporting.
   - Supporting processes include cartón management, delivery tracking, commission calculation, goal tracking, and payout/earnings views like `mi_ganancias`.

10. **Static assets and runtime packaging**
   - Static CSS is served from `public/css/`, organized by concern such as buttons, navbar, responsive behavior, roles, and stats.
   - `vendor/` plus `composer.json` indicate Composer-managed dependencies, but the app itself is mostly custom PHP rather than a large framework.

11. **Documentation and design artifacts**
   - The `docs/` folder is unusually rich and maps one-to-one to controllers, models, views, config, and SQL.
   - There are also use-case diagrams for admin and vendedor flows, which reinforces the role-based architecture.

12. **Architecture boundaries to diagram**
   - A useful diagram should show:
     - Browser/users entering through `public/index.php`
     - Controllers orchestrating business use cases
     - Models reading/writing MySQL
     - Config supplying DB and mail settings
     - Views rendering admin/vendor dashboards and feature pages
     - External mail service used for recovery/notifications
   - The strongest structural boundary is between presentation/workflow logic in controllers and persistence logic in models, with role-specific UX branching after authentication.

Main entry points: [`public/index.php`](https://github.com/darwin-1bit/bingomaster/blob/main/public/index.php) (Front controller), [`config/database.php`](https://github.com/darwin-1bit/bingomaster/blob/main/config/database.php) (Database config), [`models/usuario.php`](https://github.com/darwin-1bit/bingomaster/blob/main/models/usuario.php) (User model), [`views/cartones`](https://github.com/darwin-1bit/bingomaster/tree/main/views/cartones) (Ops UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_public_index["Front controller<br/>entrypoint<br/>[index.php]"]
  node_views_layouts["Layouts<br/>view partials"]
  node_views_auth["Auth pages<br/>views"]
  node_views_dashboard_admin["Admin dashboard<br/>dashboard view<br/>[admin.php]"]
  node_views_dashboard_vendor["Vendor dashboard<br/>dashboard view<br/>[vendedor.php]"]
  node_views_sales["Sales UI<br/>workflow views"]
  node_views_ops["Ops UI<br/>workflow views"]
end

subgraph group_application["Application"]
  node_auth_ctrl["Auth controller<br/>[AuthController.php]"]
  node_recover_ctrl["Recovery controller"]
  node_sales_ctrl["Sales controller"]
  node_vendor_sales_ctrl["Vendor sales<br/>controller"]
  node_carton_ctrl["Cartons<br/>controller"]
  node_delivery_ctrl["Deliveries<br/>controller"]
  node_meta_ctrl["Goals<br/>controller<br/>[MetaController.php]"]
  node_commission_ctrl["Commissions<br/>controller"]
  node_notify_ctrl["Notifications<br/>controller"]
  node_vendor_notify_ctrl["Vendor alerts<br/>controller"]
  node_user_ctrl["Users<br/>controller"]
  node_admin_user_ctrl["Admin users<br/>controller"]
  node_vendor_ctrl["Vendors<br/>controller"]
end

subgraph group_data["Data"]
  node_venta_model[("Sales model<br/>[VentaModel.php]")]
  node_carton_model[("Carton model<br/>[CartonModel.php]")]
  node_delivery_model[("Delivery model<br/>[EntregaModel.php]")]
  node_meta_model[("Goals model<br/>[MetaModel.php]")]
  node_notify_model[("Notification model")]
  node_user_model[("User model<br/>[usuario.php]")]
end

subgraph group_integrations["Integrations"]
  node_db_config["Database config<br/>[database.php]"]
  node_mail_config["Mail config<br/>[mail.php]"]
  node_mysql_db[("MySQL<br/>database<br/>[bingomaster.sql]")]
  node_mail_service(("Email service<br/>external service"))
end

node_public_index -->|"routes to"| node_auth_ctrl
node_public_index -->|"routes to"| node_sales_ctrl
node_public_index -->|"routes to"| node_vendor_sales_ctrl
node_public_index -->|"routes to"| node_carton_ctrl
node_public_index -->|"routes to"| node_delivery_ctrl
node_public_index -->|"routes to"| node_meta_ctrl
node_public_index -->|"routes to"| node_notify_ctrl
node_auth_ctrl -->|"renders"| node_views_auth
node_recover_ctrl -->|"renders"| node_views_auth
node_sales_ctrl -->|"renders"| node_views_sales
node_vendor_sales_ctrl -->|"renders"| node_views_sales
node_carton_ctrl -->|"renders"| node_views_ops
node_delivery_ctrl -->|"renders"| node_views_ops
node_meta_ctrl -->|"renders"| node_views_ops
node_notify_ctrl -->|"renders"| node_views_ops
node_user_ctrl -->|"renders"| node_views_ops
node_admin_user_ctrl -->|"renders"| node_views_dashboard_admin
node_vendor_ctrl -->|"renders"| node_views_dashboard_vendor
node_auth_ctrl -->|"uses"| node_user_model
node_recover_ctrl -->|"uses"| node_user_model
node_sales_ctrl -->|"uses"| node_venta_model
node_vendor_sales_ctrl -->|"uses"| node_venta_model
node_carton_ctrl -->|"uses"| node_carton_model
node_delivery_ctrl -->|"uses"| node_delivery_model
node_meta_ctrl -->|"uses"| node_meta_model
node_notify_ctrl -->|"uses"| node_notify_model
node_vendor_notify_ctrl -->|"uses"| node_notify_model
node_user_ctrl -->|"uses"| node_user_model
node_admin_user_ctrl -->|"uses"| node_user_model
node_vendor_ctrl -->|"uses"| node_user_model
node_venta_model -->|"connects via"| node_db_config
node_carton_model -->|"connects via"| node_db_config
node_delivery_model -->|"connects via"| node_db_config
node_meta_model -->|"connects via"| node_db_config
node_notify_model -->|"connects via"| node_db_config
node_user_model -->|"connects via"| node_db_config
node_db_config -->|"targets"| node_mysql_db
node_mail_config -->|"targets"| node_mail_service
node_auth_ctrl -->|"uses"| node_mail_config
node_recover_ctrl -->|"uses"| node_mail_config
node_notify_ctrl -->|"uses"| node_mail_config
node_vendor_notify_ctrl -->|"uses"| node_mail_config
node_views_layouts -->|"wraps"| node_views_dashboard_admin
node_views_layouts -->|"wraps"| node_views_dashboard_vendor
node_views_layouts -->|"wraps"| node_views_sales
node_views_layouts -->|"wraps"| node_views_ops

click node_public_index "https://github.com/darwin-1bit/bingomaster/blob/main/public/index.php"
click node_views_layouts "https://github.com/darwin-1bit/bingomaster/tree/main/views/layouts"
click node_views_auth "https://github.com/darwin-1bit/bingomaster/tree/main/views/usuarios"
click node_views_dashboard_admin "https://github.com/darwin-1bit/bingomaster/blob/main/views/dashboard/admin.php"
click node_views_dashboard_vendor "https://github.com/darwin-1bit/bingomaster/blob/main/views/dashboard/vendedor.php"
click node_views_sales "https://github.com/darwin-1bit/bingomaster/tree/main/views/ventas"
click node_views_ops "https://github.com/darwin-1bit/bingomaster/tree/main/views/cartones"
click node_auth_ctrl "https://github.com/darwin-1bit/bingomaster/blob/main/controllers/AuthController.php"
click node_recover_ctrl "https://github.com/darwin-1bit/bingomaster/blob/main/controllers/RecuperarController.php"
click node_sales_ctrl "https://github.com/darwin-1bit/bingomaster/blob/main/controllers/VentaController.php"
click node_vendor_sales_ctrl "https://github.com/darwin-1bit/bingomaster/blob/main/controllers/VentaVendedorController.php"
click node_carton_ctrl "https://github.com/darwin-1bit/bingomaster/blob/main/controllers/CartonController.php"
click node_delivery_ctrl "https://github.com/darwin-1bit/bingomaster/blob/main/controllers/EntregaController.php"
click node_meta_ctrl "https://github.com/darwin-1bit/bingomaster/blob/main/controllers/MetaController.php"
click node_commission_ctrl "https://github.com/darwin-1bit/bingomaster/blob/main/controllers/ComisionController.php"
click node_notify_ctrl "https://github.com/darwin-1bit/bingomaster/blob/main/controllers/NotificacionController.php"
click node_vendor_notify_ctrl "https://github.com/darwin-1bit/bingomaster/blob/main/controllers/NotificacionVendedorController.php"
click node_user_ctrl "https://github.com/darwin-1bit/bingomaster/blob/main/controllers/UsuarioController.php"
click node_admin_user_ctrl "https://github.com/darwin-1bit/bingomaster/blob/main/controllers/AdminUsuarioController.php"
click node_vendor_ctrl "https://github.com/darwin-1bit/bingomaster/blob/main/controllers/VendedorController.php"
click node_venta_model "https://github.com/darwin-1bit/bingomaster/blob/main/models/VentaModel.php"
click node_carton_model "https://github.com/darwin-1bit/bingomaster/blob/main/models/CartonModel.php"
click node_delivery_model "https://github.com/darwin-1bit/bingomaster/blob/main/models/EntregaModel.php"
click node_meta_model "https://github.com/darwin-1bit/bingomaster/blob/main/models/MetaModel.php"
click node_notify_model "https://github.com/darwin-1bit/bingomaster/blob/main/models/NotificacionModel.php"
click node_user_model "https://github.com/darwin-1bit/bingomaster/blob/main/models/usuario.php"
click node_db_config "https://github.com/darwin-1bit/bingomaster/blob/main/config/database.php"
click node_mail_config "https://github.com/darwin-1bit/bingomaster/blob/main/config/mail.php"
click node_mysql_db "https://github.com/darwin-1bit/bingomaster/blob/main/sql/bingomaster.sql"

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_public_index,node_views_layouts,node_views_auth,node_views_dashboard_admin,node_views_dashboard_vendor,node_views_sales,node_views_ops toneBlue
class node_auth_ctrl,node_recover_ctrl,node_sales_ctrl,node_vendor_sales_ctrl,node_carton_ctrl,node_delivery_ctrl,node_meta_ctrl,node_commission_ctrl,node_notify_ctrl,node_vendor_notify_ctrl,node_user_ctrl,node_admin_user_ctrl,node_vendor_ctrl toneAmber
class node_venta_model,node_carton_model,node_delivery_model,node_meta_model,node_notify_model,node_user_model toneMint
class node_db_config,node_mail_config,node_mysql_db,node_mail_service toneRose
```

## Components

### Presentation

Front controller, shared layout, and feature views.

- [Front controller](https://github.com/darwin-1bit/bingomaster/blob/main/public/index.php): entrypoint · Public web entry and request bootstrap. · `public/index.php`
- [Layouts](https://github.com/darwin-1bit/bingomaster/tree/main/views/layouts): view partials · Shared header, footer, and sidebar shell. · `views/layouts`
- [Auth pages](https://github.com/darwin-1bit/bingomaster/tree/main/views/usuarios): views · Login, registration, and password recovery screens. · `views/usuarios`
- [Admin dashboard](https://github.com/darwin-1bit/bingomaster/blob/main/views/dashboard/admin.php): dashboard view · Role-specific admin landing page. · `views/dashboard/admin.php`
- [Vendor dashboard](https://github.com/darwin-1bit/bingomaster/blob/main/views/dashboard/vendedor.php): dashboard view · Role-specific vendedor landing page. · `views/dashboard/vendedor.php`
- [Sales UI](https://github.com/darwin-1bit/bingomaster/tree/main/views/ventas): workflow views · Venta, mis ventas, and registrar venta screens. · `views/ventas`
- [Ops UI](https://github.com/darwin-1bit/bingomaster/tree/main/views/cartones): workflow views · Cartones, entregas, metas, notificaciones, usuarios, and vendedores screens. · `views/cartones`

### Application

Controllers that coordinate business workflows.

- [Auth controller](https://github.com/darwin-1bit/bingomaster/blob/main/controllers/AuthController.php): controller · Login and session access flow. · `controllers/AuthController.php`
- [Recovery controller](https://github.com/darwin-1bit/bingomaster/blob/main/controllers/RecuperarController.php): controller · Password recovery and email-assisted reset flow. · `controllers/RecuperarController.php`
- [Sales controller](https://github.com/darwin-1bit/bingomaster/blob/main/controllers/VentaController.php): controller · Main sales capture and reporting workflow. · `controllers/VentaController.php`
- [Vendor sales](https://github.com/darwin-1bit/bingomaster/blob/main/controllers/VentaVendedorController.php): controller · Vendor-facing sales workflow and self-service views. · `controllers/VentaVendedorController.php`
- [Cartons](https://github.com/darwin-1bit/bingomaster/blob/main/controllers/CartonController.php): controller · Bingo card administration. · `controllers/CartonController.php`
- [Deliveries](https://github.com/darwin-1bit/bingomaster/blob/main/controllers/EntregaController.php): controller · Delivery and fulfillment operations. · `controllers/EntregaController.php`
- [Goals](https://github.com/darwin-1bit/bingomaster/blob/main/controllers/MetaController.php): controller · Sales goals and targets. · `controllers/MetaController.php`
- [Commissions](https://github.com/darwin-1bit/bingomaster/blob/main/controllers/ComisionController.php): controller · Commission calculation and payout logic. · `controllers/ComisionController.php`
- [Notifications](https://github.com/darwin-1bit/bingomaster/blob/main/controllers/NotificacionController.php): controller · Application alerts and inbox workflows. · `controllers/NotificacionController.php`
- [Vendor alerts](https://github.com/darwin-1bit/bingomaster/blob/main/controllers/NotificacionVendedorController.php): controller · Vendor-specific notifications and messaging. · `controllers/NotificacionVendedorController.php`
- [Users](https://github.com/darwin-1bit/bingomaster/blob/main/controllers/UsuarioController.php): controller · User administration and profile management. · `controllers/UsuarioController.php`
- [Admin users](https://github.com/darwin-1bit/bingomaster/blob/main/controllers/AdminUsuarioController.php): controller · Admin-side user and role management. · `controllers/AdminUsuarioController.php`
- [Vendors](https://github.com/darwin-1bit/bingomaster/blob/main/controllers/VendedorController.php): controller · Vendor administration and management. · `controllers/VendedorController.php`

### Data

Persistence models and SQL schema.

- [Sales model](https://github.com/darwin-1bit/bingomaster/blob/main/models/VentaModel.php): model · Persistence for sales and related records. · `models/VentaModel.php`
- [Carton model](https://github.com/darwin-1bit/bingomaster/blob/main/models/CartonModel.php): model · Persistence for bingo card entities. · `models/CartonModel.php`
- [Delivery model](https://github.com/darwin-1bit/bingomaster/blob/main/models/EntregaModel.php): model · Persistence for deliveries and fulfillment. · `models/EntregaModel.php`
- [Goals model](https://github.com/darwin-1bit/bingomaster/blob/main/models/MetaModel.php): model · Persistence for targets and progress. · `models/MetaModel.php`
- [Notification model](https://github.com/darwin-1bit/bingomaster/blob/main/models/NotificacionModel.php): model · Storage for app-level notifications. · `models/NotificacionModel.php`
- [User model](https://github.com/darwin-1bit/bingomaster/blob/main/models/usuario.php): model · Persistence for users and roles. · `models/usuario.php`

### Integrations

Runtime configuration and external services.

- [Database config](https://github.com/darwin-1bit/bingomaster/blob/main/config/database.php): config · MySQL connection settings. · `config/database.php`
- [Mail config](https://github.com/darwin-1bit/bingomaster/blob/main/config/mail.php): config · Outbound email settings. · `config/mail.php`
- [MySQL](https://github.com/darwin-1bit/bingomaster/blob/main/sql/bingomaster.sql): database · Relational backend schema and data store. · `sql/bingomaster.sql`
- **Email service**: external service · Outbound delivery for recovery and notifications.

## Connections

- Front controller → Auth controller: routes to · Front controller dispatches requests into application controllers.
- Front controller → Sales controller: routes to · Front controller dispatches requests into application controllers.
- Front controller → Vendor sales: routes to · Front controller dispatches requests into application controllers.
- Front controller → Cartons: routes to · Front controller dispatches requests into application controllers.
- Front controller → Deliveries: routes to · Front controller dispatches requests into application controllers.
- Front controller → Goals: routes to · Front controller dispatches requests into application controllers.
- Front controller → Notifications: routes to · Front controller dispatches requests into application controllers.
- Auth controller → Auth pages: renders · Authentication workflows select login and registration views.
- Recovery controller → Auth pages: renders · Recovery flow uses the auth pages.
- Sales controller → Sales UI: renders · Sales controller selects sales-related views.
- Vendor sales → Sales UI: renders · Vendor sales controller selects self-service sales views.
- Cartons → Ops UI: renders · Operations screens include card management pages.
- Deliveries → Ops UI: renders · Operations screens include delivery pages.
- Goals → Ops UI: renders · Operations screens include goal pages.
- Notifications → Ops UI: renders · Operations screens include notification pages.
- Users → Ops UI: renders · User administration pages live in the operations area.
- Admin users → Admin dashboard: renders · Admin management connects to the admin dashboard.
- Vendors → Vendor dashboard: renders · Vendor management connects to the vendor dashboard.
- Auth controller → User model: uses · Authentication reads and validates user records.
- Recovery controller → User model: uses · Password recovery targets user records.
- Sales controller → Sales model: uses · Sales workflows persist and query sales data.
- Vendor sales → Sales model: uses · Vendor sales workflows persist and query sales data.
- Cartons → Carton model: uses · Card management reads and writes card data.
- Deliveries → Delivery model: uses · Delivery workflows read and write fulfillment data.
- Goals → Goals model: uses · Goal workflows read and write target data.
- Notifications → Notification model: uses · Notification workflows persist app alerts.
- Vendor alerts → Notification model: uses · Vendor alerts reuse notification storage.
- Users → User model: uses · User management reads and writes user records.
- Admin users → User model: uses · Admin user management reads and writes user records.
- Vendors → User model: uses · Vendor management reads and writes user records.
- Sales model → Database config: connects via · Models depend on the database connection config.
- Carton model → Database config: connects via · Models depend on the database connection config.
- Delivery model → Database config: connects via · Models depend on the database connection config.
- Goals model → Database config: connects via · Models depend on the database connection config.
- Notification model → Database config: connects via · Models depend on the database connection config.
- User model → Database config: connects via · Models depend on the database connection config.
- Database config → MySQL: targets · Database config points the app at the MySQL backend.
- Mail config → Email service: targets · Mail configuration drives outbound email delivery.
- Auth controller → Mail config: uses · Auth flows may send recovery or account emails.
- Recovery controller → Mail config: uses · Recovery flow relies on email delivery settings.
- Notifications → Mail config: uses · Notifications can be sent through email integration.
- Vendor alerts → Mail config: uses · Vendor alerts can be sent through email integration.
- Layouts → Admin dashboard: wraps · Shared layout frames role-specific screens.
- Layouts → Vendor dashboard: wraps · Shared layout frames role-specific screens.
- Layouts → Sales UI: wraps · Shared layout frames feature pages.
- Layouts → Ops UI: wraps · Shared layout frames feature pages.
