How yocere/inventario-gen works
This repository is a Laravel monolith for an operations/ERP-style system: it manages master data, purchasing, sales, inventory-related records, finance categories/transactions, users, settings, and reporting. The application is primarily server-rendered with Blade and Livewire, while also exposing some JSON API endpoints.
The top-level request flow is split by route type. routes/web.php and routes/auth.php drive the main authenticated UI, while app/Http/Controllers/Api/* exposes CRUD-style API controllers for core entities such as categories, customers, suppliers, products, units, finance categories, and users. The UI side mixes classic controllers for full pages with Livewire components for interactive CRUD screens.
The presentation layer is centered around resources/views and app/Livewire. Most business screens have a Livewire trio: table, form, and detail components. This pattern is repeated for categories, customers, finance categories, finance transactions, products, suppliers, units, and users. Purchases, sales, dashboard, profile, and settings also have dedicated Livewire or controller-backed views. Reusable UI pieces live in resources/views/components and app/View/Components.
Business logic is intentionally pushed into app/Services rather than kept in controllers or Livewire components. Each domain area has a service class such as ProductService, PurchaseService, SaleService, FinanceTransactionService, and DashboardStatsService. Controllers and Livewire components appear to act mostly as orchestration/presentation layers that delegate validation and workflow execution to these services.
The domain model is expressed with Eloquent models in app/Models. The core entities are products, categories, units, customers, suppliers, purchases, purchase items, sales, sale items, finance categories, finance transactions, settings, and users. The migration history shows the relational shape: purchases and sales have line-item tables, finance transactions gained a polymorphic reference later, and sales gained a global discount field.
A set of DTOs in app/DTOs provides structured data transfer for the main entities and transaction flows. These include purchase/sale headers and line items, product/customer/supplier/unit/category records, and finance transaction/category records. This indicates the services likely accept typed input objects instead of raw request payloads.
Enums in app/Enums define the major domain vocabularies: sale and purchase statuses, payment methods, user roles, finance category types, and date periods. These enums are part of the domain boundary and reduce stringly-typed logic across services, UI, and validation.
Custom exceptions in app/Exceptions exist per domain area, which suggests the service layer raises meaningful, domain-specific failures rather than generic errors. That matters for diagramming because error handling is not centralized only at the framework level; the architecture treats invalid business operations as first-class domain events.
Authentication and authorization are standard Laravel but with a few project-specific layers. The app includes the usual auth controllers, a ProfileController, and a custom EnsureAdmin middleware. There is also an MakeFirstUserAdmin console command and a UserRole enum, so user access is role-based and at least partly bootstrap-managed from the command line.
Reporting and operational automation are separate subsystems. DashboardController and DashboardStatsService power summary metrics, FinanceReportController renders printable finance reports, and SyncFinanceTransactions is a scheduled/CLI-style command for reconciling financial records. The app also includes print-oriented views for sales and finance reports, indicating offline/print output is a supported use case.
Persistence and test data are fully Laravel-native: migrations define schema evolution, factories and seeders populate baseline entities, and DatabaseSeeder coordinates initial data. The presence of settings and finance/category seeders suggests the app needs a configured startup state before normal use.
Infrastructure and tooling are conventional for a Laravel frontend. The repo includes Docker support, Vite, Tailwind, and Livewire-specific config (livewire-powergrid). Storage is used for public/private app files and logs, and the app has an es.json translation file, so localized UI text is part of the delivery layer.
Main entry points: Services Services · web.php Web routes · Models Eloquent models · views Blade views
Components 18
Routing & entrypoints
HTTP and console entrypoints that fan into the app
- Web routes · Main authenticated UI routes and page entrypoints
routes/web.php - Auth routes · Login, registration, reset, and verification routes
routes/auth.php - Console routes · Command registration and scheduled/console wiring
routes/console.php
Presentation layer
Blade, Livewire, and controller-backed screens
- Page controllers · Dashboard, profile, purchases, sales, reports, and other full-page controllers
app/Http/Controllers - API controllers · CRUD-style endpoints for core master-data entities and users
app/Http/Controllers/Api - Auth controllers · Session, registration, password reset, and email verification controllers
app/Http/Controllers/Auth - Livewire CRUD · Table/form/detail Livewire components for master data and finance screens
app/Livewire - Ops screens · Dashboard, profile, settings, purchases, sales, and shared Livewire components
app/Livewire - Blade views · Rendered pages, layouts, reusable components, and print views
resources/views - UI components · Reusable Blade and view-component building blocks
app/View/Components
Domain services
Application services, DTOs, enums, and exceptions
- Services · Orchestrates validation, workflows, reporting, and domain operations
app/Services - DTOs & enums · Typed input objects and shared vocabularies for business rules
app/DTOs - Domain exceptions · Entity-specific exceptions used by services and UI flows
app/Exceptions
Persistence layer
Models plus database schema and seed data
- Eloquent models · Core entities for products, parties, documents, finance, settings, and users
app/Models - Schema migrations · Relational schema for master data, transactions, line items, settings, and roles
database/migrations - Seed data · Factories and seeders for initial system state and baseline records
database/seeders
Infrastructure
Auth, middleware, commands, and tooling
- Admin guard · Custom authorization gate for admin-only access
app/Http/Middleware/EnsureAdmin.php - Console commands · Bootstrap and reconciliation commands for admin setup and finance sync
app/Console/Commands
Connections 21
- Web routes → Page controllers: dispatches · Web routes forward full-page requests to controller actions
- Web routes → Ops screens: renders · Several web pages mount Livewire-driven screens
- Web routes → Livewire CRUD: renders · Master-data pages are often Livewire-backed CRUD screens
- Auth routes → Auth controllers: dispatches · Authentication flow is handled by dedicated auth controllers
- Console routes → Console commands: registers · Console entrypoints expose maintenance and bootstrap commands
- Page controllers → Services: delegates · Controllers mostly orchestrate through service classes
- API controllers → Services: delegates · API endpoints defer business rules and persistence workflows to services
- Auth controllers → Eloquent models: updates · Auth flows create and manage user records
- Livewire CRUD → Services: delegates · Interactive CRUD screens call into services for validation and writes
- Ops screens → Services: delegates · Operational screens use services for purchases, sales, settings, and stats
- Services → DTOs & enums: uses · Services accept typed DTOs and rely on shared enums for workflow rules
- Services → Domain exceptions: raises · Domain-specific failures are surfaced through custom exceptions
- Services → Eloquent models: persists · Services coordinate Eloquent reads and writes across core entities
- Eloquent models → Schema migrations: mapped by · Models correspond to the evolved relational schema
- Seed data → Schema migrations: populates · Factories and seeders assume the schema created by migrations
- Seed data → Eloquent models: creates · Seeders build baseline rows for core entities
- Admin guard → Web routes: protects · Admin-only middleware guards privileged web routes
- Console commands → Services: invokes · Maintenance commands can reuse service logic for reconciliation and setup
- Blade views → UI components: composes · Pages are assembled from shared Blade and view components
- Blade views → Livewire CRUD: hosts · Livewire component views are rendered inside the Blade layer
- Blade views → Page controllers: renders · Controller-backed pages are delivered through Blade templates