How mahonrisiu/localizador-buses-bluefields works
Purpose and runtime
SIGBU/MiBus is a PHP/MySQL bus-location web application for Bluefields. It serves a public live-map experience, a bus-mounted location transmitter (“emisor”), and an administrator workspace. It runs under Apache/PHP with MySQL, intended for XAMPP; browser Geolocation supplies GPS and Leaflet renders maps.
Core bootstrap and persistence: index.php, config/database.php, config/database.sql.
Entry points and role boundary
Role-specific public endpoints form the application boundary:
• Public rider map: public/usuario/index.php
• Emisor login and tracking panel: public/emisor/login.php, public/emisor/panel.php
• Administrator login, panel, and management: public/admin/login.php, public/admin/panel.php, public/admin/gestion.php
The user role is read-only and unauthenticated. Emisor access uses a bus-associated access code; admin access uses credential login. Protected server pages and their endpoints enforce separation rather than exposing one shared UI.
MVC application layer
Controllers coordinate HTTP requests, authorization-related actions, and model operations:
• Bus/routing queries: app/controllers/BusController.php
• GPS-emitter operations: app/controllers/EmisorController.php
• Administrative operations: app/controllers/AdminController.php
Database-facing domain entities are separated into models for buses, routes, users/admin identities, and emitters: app/models/Bus.php, app/models/Ruta.php, app/models/Usuario.php, app/models/Emisor.php.
Live-location flow
An authorized emitter opens its panel; browser JavaScript obtains location from the Geolocation API and submits updates to the PHP update endpoint. The backend associates the update with the authenticated/assigned emitter and bus, then persists current location in MySQL.
Key flow paths: public/emisor/panel.php, assets/js/emisor.js, public/emisor_actualizar.php, app/controllers/EmisorController.php.
This is request/poll-based PHP/MySQL architecture, not the earlier Firebase Realtime Database approach.
Public map and data-read API
The public map page loads Leaflet-oriented client code, retrieves buses and routes through lightweight PHP endpoints, then displays bus positions and route context. Route-specific lookup supports filtering or focused map views.
Key paths: public/usuario/index.php, assets/js/mapa.js, public/obtener_bus.php, public/obtener_bus_por_ruta.php, public/obtener_rutas.php.
The browser/API boundary is important: map rendering and polling behavior live client-side, while PHP endpoints expose database-backed transport data.
Administration and route lifecycle
Admin pages provide operational control over routes and related transport entities. Dedicated endpoints create/remove routes, toggle route availability, and return complete route data for management UI updates.
Key paths: public/admin/gestion.php, public/admin_agregar_ruta.php, public/admin_eliminar_ruta.php, public/admin_toggle_ruta.php, public/admin_obtener_rutas_completas.php.
app/controllers/AdminController.php is the intended orchestration point between these actions and route/bus/emitter models.
Infrastructure and assets
MySQL schema and connection configuration are repository-managed, while Apache/PHP is the serving runtime. Frontend styling and shared browser utilities are static assets; public/asset.php likely mediates asset delivery or resolution.
Key paths: config/database.php, config/database.sql, assets/css/estilos.css, assets/js/utilidades.js, public/asset.php.
Main entry points: Bus.php Bus and route models · EmisorController.php Emisor controller · AdminController.php Admin controller · mapa.js Map client
Components 17
PHP entry points
Role-specific pages and lightweight HTTP endpoints.
- Rider map page · Unauthenticated read-only live map.
public/usuario/index.php - Emisor panel · Bus-associated access-code tracking workspace.
public/emisor/panel.php - Admin workspace · Login, panel, and route management.
public/admin/gestion.php - Location update API · Accepts authorized emitter GPS updates.
public/emisor_actualizar.php - Transport read APIs · Bus, route-filtered bus, and route data.
public/obtener_bus.php - Route admin APIs · Create, remove, toggle, and list routes.
public/admin_agregar_ruta.php
Application layer
Controllers and domain models.
- Bus controller · Coordinates bus and routing queries.
app/controllers/BusController.php - Emisor controller · Authorizes emitter operations and location updates.
app/controllers/EmisorController.php - Admin controller · Orchestrates administrative transport actions.
app/controllers/AdminController.php - Bus and route models · Bus and route persistence entities.
app/models/Bus.php - Identity and emitter models · Admin identity and bus-emitter associations.
app/models/Emisor.php
Browser clients
Client-side map and GPS behavior.
- Map client · Leaflet rendering and bus polling.
assets/js/mapa.js - Emitter client · Captures and submits browser GPS.
assets/js/emisor.js - Browser Geolocation · Supplies device coordinates.
- Leaflet · Renders map and route context.
Persistence
Repository-managed MySQL access and schema.
- Database connection · MySQL connection setup.
config/database.php - MySQL transport data · Current locations, buses, routes, users, and emitters.
config/database.sql
Connections 18
- Rider map page → Map client: loads
- Map client → Transport read APIs: polls
- Map client → Leaflet: renders with
- Emisor panel → Emitter client: loads
- Emitter client → Browser Geolocation: reads GPS
- Emitter client → Location update API: submits coordinates
- Location update API → Emisor controller: dispatches
- Transport read APIs → Bus controller: queries
- Admin workspace → Route admin APIs: manages routes
- Route admin APIs → Admin controller: dispatches
- Bus controller → Bus and route models: uses
- Emisor controller → Identity and emitter models: authorizes and associates
- Emisor controller → Bus and route models: updates bus location
- Admin controller → Bus and route models: manages
- Admin controller → Identity and emitter models: manages related entities
- Bus and route models → Database connection: connects through
- Identity and emitter models → Database connection: connects through
- Database connection → MySQL transport data: accesses