How zalmoxis26/trafficmanagement works
1. This is a Laravel monolith for traffic/customs document management. The application is organized in the standard Laravel layers: HTTP controllers, Eloquent models, Blade views, console commands, queued jobs, events, mail/notifications, and database migrations.
2. The core business domain is centered on a small set of linked records: Empresa, Trafico, Embarque, Pedimento, Revisione, Anexo, Comment, Historial, and the pivot UsersEmpresa. These entities represent companies, traffic cases, shipments, customs pedimentos, review stages, attachments, comments, and audit/history tracking.
3. The main user-facing flows are CRUD-heavy and are split by domain area. There are dedicated controllers and views for tráfico, embarque, pedimento, revisión, anexo, empresa, users-empresa, roles, and comments. Most pages are server-rendered Blade templates, not a separate SPA.
4. Trafico appears to be the central aggregate. It is connected to embarques, pedimentos, revisiones, anexos, and comments through foreign keys and pivot tables. Several migrations add lifecycle fields like closed date, invoice attachment, and review linkage, showing that traffic records evolve through a managed workflow.
5. Authentication is built on Laravel’s native auth scaffolding, but access is further constrained by approval and verification logic. The custom middleware EnsureUserIsVerifiedAndApproved indicates that a user must be both verified and manually approved before using the application. Role management is supported by the permission tables and dedicated role assignment views/controllers.
6. There is an operational ingestion pipeline for external files, especially FTP-based imports. Console commands such as DispatchFtpJob and ProcessAdpSaiFtpFilesCommand, plus jobs like ProcessFtpFiles and ProcessAdpSaiFtpFiles, indicate asynchronous processing of incoming document folders and creation/updating of domain records from those files.
7. The app also has an integration path for document sources beyond the local UI. The presence of DocumentFtpController, AdpPedimentoSaiAwsController, and document views for documentosFTP and documentosLocales suggests a boundary between externally received files and internally managed records.
8. Events are used to signal state changes in the domain. Events like TraficoCreated, FacturaUpdated, RevisionUpdated, MxDocsStatusUpdated, and comment events imply that the app broadcasts or reacts to record updates across the UI and notification layers.
9. Real-time or near-real-time client updates are likely supported through Laravel broadcasting. The repository includes broadcasting, reverb, and front-end Echo bootstrap files, so status changes and comment activity can be pushed to connected clients instead of only being polled.
10. Notifications and email are a first-class output channel. Mails exist for factura updates, revision status, user approval, and registration verification, while notifications cover new user registration and approval. This makes approval and document status changes visible both in-app and by email.
11. Reporting/export is handled server-side through dedicated export classes. TraficoExport and EmbarquesExport indicate downloadable reports, likely for operational tracking and management review rather than interactive analytics.
12. File and persistence boundaries are conventional Laravel ones: database-backed Eloquent models/migrations for domain state, and storage/public folders for uploads and generated artifacts. The application’s architecture is therefore a single Laravel backend with synchronous CRUD, asynchronous file ingestion, and notification/broadcast side effects around a traffic-management core.
Main entry points: Trafico.php Trafico · TraficoCreated.php Domain Events · Comment.php Comment · index.blade.php Blade UI
Components 34
Presentation
HTTP controllers and Blade views for the server-rendered UI
- Trafico · Main CRUD and workflow controller for traffic cases
app/Http/Controllers/TraficoController.php - Embarque · Shipment CRUD and traffic-linked shipment flows
app/Http/Controllers/EmbarqueController.php - Pedimento · Customs document CRUD and traffic-linked creation/editing
app/Http/Controllers/PedimentoController.php - Revisión · Review stage CRUD and status transitions
app/Http/Controllers/RevisioneController.php - Anexo · Attachment CRUD and document linking
app/Http/Controllers/AnexoController.php - Empresa · Company CRUD and company settings
app/Http/Controllers/EmpresaController.php - Users-Empresa · User-to-company assignment management
app/Http/Controllers/UsersEmpresaController.php - Comment · Comment creation and threading around traffic and shipments
app/Http/Controllers/CommentController.php - Docs FTP · UI and intake boundary for externally received documents
app/Http/Controllers/DocumentFtpController.php - ADP SAI · AWS-based document source integration for pedimento files
app/Http/Controllers/AdpPedimentoSaiAwsController.php - Roles · Role assignment and permission management UI
app/Http/Controllers/UserRoleController.php - Blade UI · Server-rendered domain pages and document views
resources/views/trafico/index.blade.php
Domain
Core traffic-management entities and their relationships
- Trafico · Central case record coordinating the workflow
app/Models/Trafico.php - Empresa · Company record and notification preferences
app/Models/Empresa.php - Embarque · Shipment record linked to a traffic case
app/Models/Embarque.php - Pedimento · Customs document record associated with traffic
app/Models/Pedimento.php - Revisión · Review stage and status attachment for a traffic case
app/Models/Revisione.php - Anexo · Attachment record for traffic and related documents
app/Models/Anexo.php - Comment · Discussion and activity comments on cases and shipments
app/Models/Comment.php - Historial · Audit trail and history tracking for changes
app/Models/Historial.php - Users-Empresa · Pivot link between users and companies
app/Models/UsersEmpresa.php - User · Authenticated user with approval state
app/Models/User.php
Ingestion
Console commands and queued jobs that import external files
- FTP Command · Schedules or dispatches file-ingestion jobs
app/Console/Commands/DispatchFtpJob.php - ADP Command · Processes ADP/SAI FTP folders from the console
app/Console/Commands/ProcessAdpSaiFtpFilesCommand.php - FTP Job · Asynchronous processing of incoming FTP files
app/Jobs/ProcessFtpFiles.php - ADP Job · Asynchronous processing of ADP SAI files
app/Jobs/ProcessAdpSaiFtpFiles.php
Delivery
Events, mail, notifications, exports, and realtime push
- Domain Events · State-change signals for traffic, comments, and revisions
app/Events/TraficoCreated.php - Mail · Email notifications for factura, revision, approval, and verification
app/Mail/FacturaMail.php - Notifications · In-app notifications for user registration and approval
app/Notifications/UserApprovedNotification.php - Exports · Server-side downloadable reporting for traffic and shipments
app/Exports/TraficoExport.php - Broadcasting · Realtime client update channel for comments and status changes
routes/channels.php
Platform
Auth, middleware, and client-side realtime bootstrap
- Approval Gate · Requires verified and manually approved users
app/Http/Middleware/EnsureUserIsVerifiedAndApproved.php - Auth · Native authentication, registration, password reset, and verification
app/Http/Controllers/Auth/LoginController.php - Echo Bootstrap · Front-end realtime client wiring for broadcast updates
resources/js/echo.js
Connections 37
- Trafico → Trafico: manages · Creates, updates, closes, and shows traffic cases
- Embarque → Embarque: manages · CRUD for shipments linked to traffic
- Pedimento → Pedimento: manages · CRUD for customs documents and traffic-linked edits
- Revisión → Revisión: manages · CRUD for review stages and attached status fields
- Anexo → Anexo: manages · CRUD for attachments and related uploads
- Empresa → Empresa: manages · CRUD for company records
- Users-Empresa → Users-Empresa: manages · Assigns users to companies
- Comment → Comment: manages · Creates comments on traffic and shipment records
- Docs FTP → FTP Job: triggers · Hands external documents to background processing
- ADP SAI → ADP Job: triggers · Starts ADP SAI ingestion workflow
- FTP Command → FTP Job: dispatches · Console entrypoint for FTP file processing
- ADP Command → ADP Job: dispatches · Console entrypoint for ADP SAI file processing
- FTP Job → Trafico: creates/updates · Imports incoming file data into traffic records
- ADP Job → Pedimento: creates/updates · Imports ADP SAI data into pedimentos and related records
- Trafico → Embarque: has many · Traffic aggregates shipments
- Trafico → Pedimento: links to · Traffic is associated with a pedimento
- Trafico → Revisión: tracks · Traffic workflow advances through review stages
- Trafico → Anexo: has many · Traffic collects attachments
- Trafico → Comment: has many · Traffic discussion history
- Trafico → Historial: audited by · Changes are recorded in history entries
- Empresa → Users-Empresa: has many · Company membership pivot records
- User → Users-Empresa: has many · User membership and access linkage
- Comment → Broadcasting: emits · Comment activity is pushed to connected clients
- Trafico → Domain Events: emits · Traffic lifecycle changes raise events
- Revisión → Domain Events: emits · Review updates raise domain events
- Comment → Domain Events: emits · Comment creation raises notification events
- Domain Events → Mail: notifies · Events feed email delivery
- Domain Events → Notifications: notifies · Events feed in-app notifications
- Domain Events → Broadcasting: broadcasts · State changes are broadcast to clients
- Exports → Trafico: exports · Traffic reporting extracts domain data
- Exports → Embarque: exports · Shipment reporting extracts domain data
- Approval Gate → Auth: guards · Access depends on verified and approved authentication state
- Auth → User: authenticates · Login, registration, verification, and password flows
- Echo Bootstrap → Broadcasting: subscribes · Client-side Echo listens for broadcast events
- Blade UI → Trafico: renders · Server-rendered pages are served by controllers
- Blade UI → Embarque: renders · UI pages support shipment flows
- Blade UI → Pedimento: renders · UI pages support pedimento flows