How guillenme/nawi-2 works
1. Repository type and runtime
- This is a Laravel PHP monolith with a classic server-rendered UI.
- The primary delivery path is HTTP -> Laravel routing -> controllers -> Eloquent models -> Blade views.
- Front-end behavior is lightweight, built from resources/js, resources/css, and resources/sass, then served through the Laravel/Vite pipeline.
2. Core domain
- The app models a taxi platform with distinct personas and workflows: admin, taxista, pasajero, taxi, viaje, documentos, calificaciones, suscripciones.
- The domain is centered on user onboarding, role assignment, document validation, taxi registration, trip management, and ratings.
3. Application boundaries
- app/Http/Controllers contains the main business entry points.
- app/Models contains the persistent domain objects.
- app/Services isolates cross-cutting or integration logic such as geolocation, payment, external API access, role handling, document-status handling, and security logging.
- resources/views contains all UI rendering; there is no separate SPA boundary.
4. User and authentication subsystem
- Authentication is split across several controllers: standard login/register, password reset, email verification, and a custom WebAuthController / AuthController.
- app/Http/Requests adds request validation for passenger and driver registration.
- The presence of both sanctum config and OAuth-related migration tables indicates the project supports token-based auth for API access alongside web sessions.
5. Role- and type-based access control
- Role, Usuario, Admin, Taxista, and Pasajero suggest the system separates identity from role-specific profiles.
- ValidateUserTypeMiddleware and RoleService indicate access is not just authenticated/unauthenticated; it is persona-aware, gating controllers and dashboards by user type.
- AuthServiceProvider and security config likely centralize authorization policies and security rules.
6. Taxi and trip management
- TaxiController, TaxistaController, ViajeController, PasajeroViajeController, and TaxistaViajeController form the operational core.
- Trips (Viaje) appear to carry state, location, and additional operational fields, implying a lifecycle such as request/assignment/in-progress/completed/cancelled.
- Taxi ownership/association is modeled separately from drivers and passengers, which is important for diagramming the domain boundaries.
7. Document and compliance workflow
- The system has explicit document entities: Matricula, Licencia, EstatusDocumento, Foto, and related controller/service support.
- Admin and taxista views include document review/management screens, so document validation is a first-class workflow, not a side feature.
- The EstatusDocumentoService suggests document approval/rejection status is normalized and reused across the app.
8. Payments, subscriptions, and external integrations
- PaymentService and Suscripcion imply some subscription or billing flow, likely tied to driver/taxi enablement.
- ExternalApiService and GeolocationService indicate the app integrates with outside systems for location-based or third-party data.
- These are isolated in services, so the controllers likely orchestrate them rather than embedding external calls directly.
9. Security and request handling
- Several middleware layers are notable: input sanitization, rate limiting, API throttling, security headers, CSRF, auth, user-type validation.
- SecurityLoggerService shows security-relevant events are intentionally logged.
- This means request flow is hardened at the middleware boundary before reaching business controllers.
10. Data model and persistence
- The database layer is Eloquent-driven with migrations for users, roles, admins, taxistas, pasajeros, taxis, viajes, ratings, subscriptions, photos, and tokens.
- Later migrations add operational fields to trips and adjust taxi/document constraints, showing the schema evolved around real workflow needs.
- Seeders for roles, genres, languages, and document status provide baseline reference data.
11. Presentation layer
- Blade templates are organized by audience: auth, admin, taxista, perfil, home, welcome, and offline.
- There are dedicated screens for dashboards, document management, taxi CRUD, profile editing, and password reset emails.
- The UI is therefore segmented by role and task, matching the backend authorization model.
12. Offline/PWA behavior
- public/service-worker.js, manifest.json, offline.html, and related update/debug assets show the app includes PWA/offline support.
- This is a meaningful architectural boundary: the public folder contains not just static assets, but client-side caching and offline fallback behavior.
- For an architecture diagram, this is a separate client capability layered over the Laravel server.
13. Routing and entry points
- routes/web.php is the main browser-facing entry, routes/api.php exposes API endpoints, and routes/console.php handles artisan commands.
- app/Console/Kernel.php and app/Http/Kernel.php define scheduled/background and HTTP middleware orchestration.
- public/index.php is the single web entry point into the framework.
14. Operational concern
- The repository includes extensive docs focused on email setup, password reset, environment review, and security analysis, which suggests authentication and notification flow are operationally important.
- The .env.example, mail config, queue config, and logging config indicate deployment depends on environment-driven infrastructure for email, background work, and observability.
Main entry points: web.php Web routes · Kernel.php HTTP kernel · AdminController.php Personas · ViajeController.php Trips
Components 22
Runtime
Laravel request, console, and middleware orchestration
- Entry · Single HTTP entry point into the framework
public/index.php - Web routes · Primary server-rendered request map
routes/web.php - API routes · Token/API surface for programmatic access
routes/api.php - HTTP kernel · Assembles request middleware and web pipeline
app/Http/Kernel.php - Console kernel · Coordinates console commands and scheduled work
app/Console/Kernel.php
Domain
Core taxi platform concepts and workflows
- Auth flow · Login, register, reset, verification, and custom auth entry points
app/Http/Controllers/AuthController.php - Personas · Admin, taxista, pasajero, and profile control surfaces
app/Http/Controllers/AdminController.php - Trips · Taxi, viaje, and role-specific trip orchestration
app/Http/Controllers/ViajeController.php - Documents · License, vehicle registration, and photo workflows
app/Http/Controllers/LicenciaController.php - Identity · Users, roles, profiles, and typed identities
app/Models/Usuario.php - Mobility · Taxi, driver, passenger, and trip records
app/Models/Taxi.php - Compliance · Document, status, subscription, and rating records
app/Models/Licencia.php
UI
Server-rendered views and client assets
Infra
Security, config, queues, mail, and external integrations
- Role service · Persona-aware role and access decisions
app/Services/RoleService.php - Doc status · Normalizes approval and rejection states for documents
app/Services/EstatusDocumentoService.php - Geolocation · Location lookup and trip/location support
app/Services/GeolocationService.php - Payments · Subscription or billing orchestration
app/Services/PaymentService.php - External API · Boundary for third-party API calls
app/Services/ExternalApiService.php - Security log · Records security-relevant events
app/Services/SecurityLoggerService.php - Schema · Eloquent-backed tables, tokens, roles, documents, trips, and ratings
database/migrations/2025_09_25_151341_create_roles_table.php
Connections 25
- Entry → HTTP kernel: bootstraps · HTTP requests enter the middleware pipeline
- HTTP kernel → Web routes: dispatches · Web requests route into browser controllers
- HTTP kernel → API routes: dispatches · API requests route into token-based endpoints
- Web routes → Auth flow: maps to · Authentication and account flows
- Web routes → Personas: maps to · Dashboards, profiles, and persona views
- Web routes → Trips: maps to · Taxi and trip operations
- Web routes → Documents: maps to · Document review and upload screens
- API routes → External API: uses · API-facing operations can delegate integration calls
- Auth flow → Identity: persists · Login, registration, and verification use identity records
- Personas → Identity: uses · Role-specific profiles and dashboards
- Trips → Mobility: persists · Taxi and trip state live in fleet models
- Documents → Compliance: persists · License, photo, and compliance data
- Trips → Geolocation: uses · Trip flows depend on geolocation support
- Trips → Payments: uses · Subscription/billing actions are coordinated here
- Documents → Doc status: uses · Document status transitions are normalized
- Personas → Role service: gates · Persona-aware access and dashboard selection
- Personas → Security log: logs · Security-sensitive actions are audited
- HTTP kernel → Security log: guards · Middleware hardens requests before controllers
- HTTP kernel → Blade UI: renders · Server responses resolve to Blade templates
- Blade UI → Assets: includes · Views are styled and scripted by bundled assets
- PWA → Blade UI: backs up · Offline fallback complements the server-rendered UI
- Console kernel → Schema: maintains · Scheduled or artisan tasks support data lifecycle
- Identity → Schema: maps to · Users, roles, tokens, and profiles are persisted here
- Mobility → Schema: maps to · Taxi and trip tables form the operational core
- Compliance → Schema: maps to · Documents, ratings, and subscriptions are stored here