How shahzaibahmadd/fsms-dd works
Purpose and Entry Points
This is a Laravel field-service/maintenance management system for machines, service tickets, technician assignment, work/spare-part tracking, customer approval, invoicing, and reporting. HTTP entry points split browser workflows from programmatic APIs at routes/web.php and routes/api.php; the public PHP front controller is public/index.php. Scheduled/CLI work enters through artisan and routes/console.php.
Delivery Boundaries
Web controllers render role-oriented Blade dashboards and ticket/machine views, while API controllers expose equivalent operational capabilities with request validation, DTOs, and resources. Key boundaries are app/Http/Controllers/Web/Ticket/TicketController.php, app/Http/Controllers/Api/Ticket/TicketController.php, and app/Http/Resources/Ticket/TicketResource.php. Controllers should remain adapters: validated requests feed DTO/service operations; API responses are normalized through resources and response traits.
Identity, Authorization, and Operational Roles
Users have technician and customer profiles, with administrative user/role management. Authorization is enforced through role middleware and permission services, centered on app/Models/User.php, app/Http/Middleware/RoleAccess.php, and app/Services/Admin/RolePermissionService.php. Authentication configuration includes Laravel auth, Sanctum, and JWT configuration (config/auth.php, config/sanctum.php, config/jwt.php); permission schema/configuration is present in database/migrations/2026_07_30_123046_create_permission_tables.php and config/permission.php.
Ticket Lifecycle and Assignment
Tickets are the core workflow aggregate: creation, priority evaluation/override, status transitions/history, assignment or reassignment, progress, and completion. The main orchestration services are app/Services/Ticket/TicketService.php, app/Services/Assignment/AssignmentService.php, and app/Services/ProgressTracking/ProgressService.php. Assignment is explicitly strategy-based, separating manual versus automatic selection through app/Services/Strategies/AssignmentStrategyFactory.php, app/Services/Strategies/AutoAssignmentStrategy.php, and app/Services/Strategies/ManualAssignmentStrategy.php; availability is managed separately by app/Services/TechnicianAvailability/TechnicianAvailabilityService.php.
Domain Persistence and Work Execution
Eloquent models and migrations define a relational domain around tickets, machines, assignments, technicians/customers, logs, parts, invoices, and maintenance schedules. Core records are app/Models/Ticket.php, app/Models/TicketAssignment.php, and app/Models/machine.php; schema evolution is under database/migrations/. Technician execution adds time/work logs and consumed spare parts via app/Services/WorkLog/WorkLogService.php, app/Models/WorkLog.php, and app/Models/TicketSparePart.php. Status enums, history traits, and transition exceptions indicate lifecycle integrity is a domain concern.
Maintenance, Approval, and Financial Flow
Preventive-maintenance schedules generate due-work signals, while completed work is customer-approved or rejected before invoice processing. This chain is represented by app/Services/Maintenance/MaintenanceService.php, app/Services/CustomerApproval/ApprovalService.php, and app/Services/Invoice/InvoiceService.php. Invoice totals are abstracted behind a calculator interface and standard implementation in app/Services/Interfaces/InvoiceCalculatorInterface.php and app/Services/Calculation/StandardInvoiceCalculator.php; invoice/PDF output uses app/Jobs/GenerateInvoicePdfJob.php and resources/views/pdf/invoice.blade.php.
Events, Async Processing, and Notifications
Domain events decouple lifecycle changes from side effects: ticket creation/assignment/status/completion and maintenance due events live in app/Events/. Listeners trigger invoice generation and stakeholder notifications, including app/Listeners/GenerateInvoiceListener.php, app/Listeners/SendTechnicianAssignmentNotification.php, and app/Listeners/NotifyCustomerOfCompletion.php. Laravel queues support deferred PDF generation and weekly reporting (app/Jobs/GenerateInvoicePdfJob.php, app/Jobs/SendWeeklyReportEmailJob.php); notifications depend on configured mail/queue infrastructure in config/mail.php and config/queue.php.
Reporting, Observability, and Runtime
Financial and performance reporting are service implementations behind report-generation abstractions: app/Services/Report/FinancialReportService.php, app/Services/Report/PerformanceReportService.php, and app/Services/Interfaces/ReportGeneratorInterface.php. Request/error logging has dedicated models/services (app/Models/RequestLogs.php, app/Services/ErrorLogging/ErrorLoggingService.php). Runtime is PHP/Laravel with Eloquent database, filesystem storage, cache/session, queue, mail, and optional broadcasting configured under config/; Vite-managed frontend assets originate at resources/js/app.js.
Main entry points: TicketService.php Ticket service · Ticket/TicketController.php API ticket controller · Ticket.php Ticket & assignment records · Ticket/TicketController.php Web ticket controller
Components 22
Entry & Delivery
- Browser routes · Role-oriented Blade workflows.
routes/web.php - API routes · Programmatic operational endpoints.
routes/api.php - Web ticket controller
app/Http/Controllers/Web/Ticket/TicketController.php - API ticket controller
app/Http/Controllers/Api/Ticket/TicketController.php - Ticket resource · Normalizes ticket API responses.
app/Http/Resources/Ticket/TicketResource.php - CLI & scheduler
routes/console.php
Identity & Access
- Role access · Enforces role-based authorization.
app/Http/Middleware/RoleAccess.php - Users & permissions
app/Models/User.php - Role permission service
app/Services/Admin/RolePermissionService.php
Ticket Lifecycle
- Ticket service · Creates tickets and governs priority and status lifecycle.
app/Services/Ticket/TicketService.php - Assignment service
app/Services/Assignment/AssignmentService.php - Assignment strategies · Selects manual or automatic technician assignment.
app/Services/Strategies/AssignmentStrategyFactory.php - Technician availability
app/Services/TechnicianAvailability/TechnicianAvailabilityService.php - Ticket & assignment records · Persists tickets, assignments, machines, and lifecycle history.
app/Models/Ticket.php
Execution & Finance
- Work logs & spare parts
app/Services/WorkLog/WorkLogService.php - Maintenance service · Generates due-work signals from preventive schedules.
app/Services/Maintenance/MaintenanceService.php - Customer approval
app/Services/CustomerApproval/ApprovalService.php - Invoice service · Calculates and processes approved work invoices.
app/Services/Invoice/InvoiceService.php
Events & Async
- Invoice PDF job · Generates invoice PDF output.
app/Jobs/GenerateInvoicePdfJob.php - Lifecycle events & listeners · Publishes lifecycle changes and triggers notifications/invoicing.
app/Listeners/GenerateInvoiceListener.php - Financial & performance reports
app/Services/Report/FinancialReportService.php
Other components
- Laravel infrastructure · Eloquent database, queue, mail, storage, cache, and sessions.
Connections 25
- Browser routes → Web ticket controller: dispatches to
- API routes → API ticket controller: dispatches to
- Web ticket controller → Role access: authorized by
- API ticket controller → Role access: authorized by
- Role access → Role permission service: checks permissions
- Role permission service → Users & permissions: uses
- Web ticket controller → Ticket service: invokes
- API ticket controller → Ticket service: invokes
- API ticket controller → Ticket resource: returns
- Ticket service → Ticket & assignment records: persists lifecycle
- Ticket service → Assignment service: assigns tickets
- Assignment service → Assignment strategies: selects strategy
- Assignment strategies → Technician availability: evaluates availability
- Assignment service → Ticket & assignment records: records assignment
- Work logs & spare parts → Ticket & assignment records: records work and parts
- Maintenance service → Ticket service: creates due work
- Ticket service → Lifecycle events & listeners: emits lifecycle events
- Lifecycle events & listeners → Customer approval: completion notification
- Customer approval → Invoice service: approved work
- Invoice service → Invoice PDF job: queues PDF generation
- Lifecycle events & listeners → Invoice PDF job: triggers invoice generation
- CLI & scheduler → Maintenance service: runs scheduled work
- CLI & scheduler → Financial & performance reports: runs weekly reports
- Invoice PDF job → Laravel infrastructure: uses queue, mail, storage
- Ticket & assignment records → Laravel infrastructure: stored through Eloquent