How lafabricadeinventos/erp-lfdi works
1. This is a Laravel 11-style monolith with a mixed server-rendered/client-rendered UI: PHP handles routing, auth, domain logic, and persistence, while the frontend is built with React + TypeScript via Vite and Inertia-style page components.
2. The main request boundary is Laravel HTTP routing under routes/web.php, routes/auth.php, and routes/api.php. Controllers in app/Http/Controllers are organized by functional area, and they hand off work to service classes rather than embedding all logic directly in controllers.
3. The UI layer lives in resources/js. It is structured around Inertia pages (resources/js/Pages), reusable components, modal dialogs, and layouts. app/Http/Middleware/HandleInertiaRequests.php is the bridge that shares server data into the React frontend.
4. The core business domains are CRM/operations oriented: customers, leads, contacts, projects, tasks, services, budgets, billing, payments, sales, debtors, reports, and administrative management. Each of these has its own controller and, in many cases, associated models and request validators.
5. The budgeting flow is one of the most specialized subsystems. There are BudgetController, budget-specific request classes, BudgetService, helper constructors for “ordinary” and “simplified” invoices, a dedicated PDF budget template in resources/views/templates/budget.blade.php, and prebuilt sample PDFs/assets under public/assets/budgets.
6. Customer management is split between web and API entry points. There are standard customer controllers plus API controllers and requests (app/Http/Controllers/Api/CustomersController.php, ApiCustomerRequest), with service classes such as CustomerService, ApiCustomerService, and helper classes for customer/contact handling.
7. Authentication and authorization are first-class subsystems. Laravel auth controllers handle login/registration/password reset/email verification, while role/permission management is backed by Laratrust (config/laratrust.php, Laratrust migrations, RoleService, PermissionsController, RolesController, UsersController). This suggests access control is central to the application’s architecture.
8. The persistence layer is relational and model-driven. Eloquent models cover customers, projects, budgets, services, senders, bank accounts, payments, tax rules, geographic data, roles, permissions, and user-linked entities. Migrations show a schema that evolved over time, including customer phone/email tables, service details, project phases, and payment methods.
9. Geographic and reference data are treated as seeded datasets. Countries, states, and cities are loaded from JSON seeders in database/seeders/data, and there are dedicated service classes for geo data lookup. This indicates forms and workflows depend on normalized location data rather than free-text entry.
10. Several service classes encapsulate non-trivial workflows and integration boundaries: GeoDataService, B2BRouterService, SenderBankService, UserService, RoleService, and BudgetService. These are the main abstraction layer between controllers and Eloquent models, and likely the right place to draw business-process boundaries in a diagram.
11. The frontend has a dense interaction model built around forms and modals. Many actions such as create/edit/delete, assigning phases, confirming customers, adding payments, and selecting budgets/projects happen through modal components rather than full page transitions, which means a lot of stateful user interaction is concentrated in the React layer.
12. Operationally, the repo is set up for standard Laravel deployment with CI/CD workflows in .github/workflows for staging and production. Static assets, fonts, and public PDF templates are checked into public/, and the app uses the usual Laravel storage/cache/log directories plus PHPUnit and JS tooling (ESLint, PostCSS/Tailwind, Vite) for build and test boundaries.
Main entry points: Controllers Feature Controllers · Models Eloquent Models · Pages Inertia Pages · BudgetService.php Budget Service
Components 23
HTTP Layer
Laravel request boundaries, controllers, middleware, and form validation.
- Web Routes · Main browser-facing request boundary.
routes/web.php - Auth Routes · Login, registration, and password flows.
routes/auth.php - API Routes · API entry points for mobile or external clients.
routes/api.php - Feature Controllers · Functional controllers for CRM, billing, projects, and admin tasks.
app/Http/Controllers - Auth Controllers · Session, registration, password reset, and verification endpoints.
app/Http/Controllers/Auth - Inertia Bridge · Shares server-side state into the React frontend.
app/Http/Middleware/HandleInertiaRequests.php - Request Validators · Typed input validation for customers, budgets, roles, users, and auth.
app/Http/Requests
Domain Services
Business workflows that sit between controllers and Eloquent models.
- Budget Service · Budget creation, update, and invoice construction logic.
app/Services/BudgetService.php - Customer Service · Customer CRUD and customer/contact orchestration.
app/Services/CustomerService.php - API Customer Service · Customer operations specialized for API entry points.
app/Services/ApiCustomerService.php - Geo Data Service · Country, state, and city lookup over seeded reference data.
app/Services/GeoDataService.php - Access Services · Role, user, and permission orchestration.
app/Services/RoleService.php - Sender Bank Service · Sender and bank-account management workflows.
app/Services/SenderBankService.php - Invoice Helpers · Customer/contact helpers and ordinary/simplified invoice builders.
app/Helpers
React UI
Inertia pages, shared components, modals, and layouts.
- Inertia Pages · Top-level screens for customers, budgets, billing, reports, and admin.
resources/js/Pages - UI Components · Shared controls, nav, forms, and modal primitives.
resources/js/Components - Modal Workflows · Stateful create/edit/delete and selection flows.
resources/js/Components/modals - Layouts · Authenticated and guest shells for the app.
resources/js/Layouts - Blade Templates · App shell and PDF templates, including budget and receipt output.
resources/views/templates
Data Model
Eloquent models, migrations, and seed data.
- Eloquent Models · Customers, budgets, projects, payments, roles, services, and related entities.
app/Models - Migrations · Relational schema evolution for core, CRM, billing, and access control.
database/migrations - Seed Data · Countries, states, cities, users, roles, services, and tax rules.
database/seeders
Ops & Delivery
Deployment and build/test boundaries.
- CI/CD Workflows · Staging and production deployment automation.
.github/workflows
Connections 28
- Web Routes → Feature Controllers: dispatches to · Browser routes are handled by feature controllers.
- Auth Routes → Auth Controllers: dispatches to · Auth-specific routes use dedicated auth controllers.
- API Routes → Feature Controllers: dispatches to · API endpoints are exposed through controller actions.
- Feature Controllers → Request Validators: validates with · Controllers rely on typed request objects for input validation.
- Feature Controllers → Budget Service: delegates budget · Budget-related controller actions are pushed into the service layer.
- Feature Controllers → Customer Service: delegates customer · Customer management is coordinated through services.
- Feature Controllers → API Customer Service: delegates api customer · API customer endpoints use a specialized service.
- Feature Controllers → Geo Data Service: looks up geo · Location-aware flows use normalized geographic lookup.
- Feature Controllers → Access Services: delegates access · Role and user administration is service-backed.
- Feature Controllers → Sender Bank Service: delegates sender bank · Sender and bank workflows are encapsulated in a service.
- Feature Controllers → Eloquent Models: reads/writes · Controllers persist and query through Eloquent models.
- Budget Service → Invoice Helpers: builds invoices · Budget workflows use invoice constructors and customer helpers.
- Budget Service → Eloquent Models: uses · Budget workflows operate on budgets, items, services, and tax rules.
- Customer Service → Eloquent Models: uses · Customer workflows manage customers and contact sub-records.
- API Customer Service → Eloquent Models: uses · API customer operations persist through the same domain models.
- Geo Data Service → Seed Data: depends on · Geo lookups are backed by seeded country/state/city datasets.
- Access Services → Eloquent Models: uses · Authorization management centers on users, roles, and permissions.
- Sender Bank Service → Eloquent Models: uses · Sender/bank workflows persist via sender and bank models.
- Inertia Bridge → Inertia Pages: feeds props · Server data is shared into Inertia pages.
- Inertia Pages → UI Components: composes · Pages are assembled from reusable controls and form elements.
- Inertia Pages → Modal Workflows: opens · Most create/edit/confirm flows are handled in modals.
- Layouts → Inertia Pages: wraps · Application shells host the page screens.
- Blade Templates → Budget Service: templates output · Budget PDF rendering relies on dedicated Blade templates.
- Blade Templates → Inertia Pages: app shell · Blade app entry point mounts the React frontend.
- Migrations → Eloquent Models: defines schema for · Schema changes shape the Eloquent model layer.
- Seed Data → Eloquent Models: loads reference data for · Seeders populate app data used by models and forms.
- CI/CD Workflows → Web Routes: ships · CI/CD deploys the Laravel application and its routes.
- CI/CD Workflows → Inertia Pages: builds · Frontend assets are built and deployed with the app.