# yocere/inventario-gen architecture

> Architecture diagram of the GitHub repository yocere/inventario-gen, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yocere/inventario-gen
- Repository: https://github.com/yocere/inventario-gen

## Overview

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: [`app/Services`](https://github.com/yocere/inventario-gen/tree/main/app/Services) (Services), [`routes/web.php`](https://github.com/yocere/inventario-gen/blob/main/routes/web.php) (Web routes), [`app/Models`](https://github.com/yocere/inventario-gen/tree/main/app/Models) (Eloquent models), [`resources/views`](https://github.com/yocere/inventario-gen/tree/main/resources/views) (Blade views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_routing["Routing & entrypoints"]
  node_routes_web["Web routes<br/>route map<br/>[web.php]"]
  node_routes_auth["Auth routes<br/>route map<br/>[auth.php]"]
  node_routes_console["Console routes<br/>cli routes<br/>[console.php]"]
end

subgraph group_presentation["Presentation layer"]
  node_ui_controllers["Page controllers<br/>http controllers"]
  node_api_controllers["API controllers<br/>json CRUD"]
  node_auth_controllers["Auth controllers<br/>auth flow"]
  node_livewire_crud["Livewire CRUD<br/>interactive screens"]
  node_livewire_ops["Ops screens<br/>workflow UI"]
  node_views["Blade views<br/>server views"]
  node_layout_components["UI components<br/>blade components"]
end

subgraph group_domain["Domain services"]
  node_services["Services<br/>application logic"]
  node_dtos_enums["DTOs & enums<br/>domain contracts"]
  node_exceptions["Domain exceptions<br/>failure model"]
end

subgraph group_persistence["Persistence layer"]
  node_models_core[("Eloquent models<br/>entities")]
  node_migrations["Schema migrations<br/>schema evolution"]
  node_seeders_factories["Seed data<br/>bootstrap data"]
end

subgraph group_infra["Infrastructure"]
  node_auth_middleware["Admin guard<br/>middleware<br/>[EnsureAdmin.php]"]
  node_console_commands["Console commands<br/>automation"]
end

node_routes_web -->|"dispatches"| node_ui_controllers
node_routes_web -->|"renders"| node_livewire_ops
node_routes_web -->|"renders"| node_livewire_crud
node_routes_auth -->|"dispatches"| node_auth_controllers
node_routes_console -->|"registers"| node_console_commands
node_ui_controllers -->|"delegates"| node_services
node_api_controllers -->|"delegates"| node_services
node_auth_controllers -->|"updates"| node_models_core
node_livewire_crud -->|"delegates"| node_services
node_livewire_ops -->|"delegates"| node_services
node_services -->|"uses"| node_dtos_enums
node_services -->|"raises"| node_exceptions
node_services -->|"persists"| node_models_core
node_models_core -->|"mapped by"| node_migrations
node_seeders_factories -->|"populates"| node_migrations
node_seeders_factories -->|"creates"| node_models_core
node_auth_middleware -->|"protects"| node_routes_web
node_console_commands -->|"invokes"| node_services
node_views -->|"composes"| node_layout_components
node_views -->|"hosts"| node_livewire_crud
node_views -->|"renders"| node_ui_controllers

click node_routes_web "https://github.com/yocere/inventario-gen/blob/main/routes/web.php"
click node_routes_auth "https://github.com/yocere/inventario-gen/blob/main/routes/auth.php"
click node_routes_console "https://github.com/yocere/inventario-gen/blob/main/routes/console.php"
click node_ui_controllers "https://github.com/yocere/inventario-gen/tree/main/app/Http/Controllers"
click node_api_controllers "https://github.com/yocere/inventario-gen/tree/main/app/Http/Controllers/Api"
click node_auth_controllers "https://github.com/yocere/inventario-gen/tree/main/app/Http/Controllers/Auth"
click node_livewire_crud "https://github.com/yocere/inventario-gen/tree/main/app/Livewire"
click node_livewire_ops "https://github.com/yocere/inventario-gen/tree/main/app/Livewire"
click node_views "https://github.com/yocere/inventario-gen/tree/main/resources/views"
click node_services "https://github.com/yocere/inventario-gen/tree/main/app/Services"
click node_dtos_enums "https://github.com/yocere/inventario-gen/tree/main/app/DTOs"
click node_exceptions "https://github.com/yocere/inventario-gen/tree/main/app/Exceptions"
click node_models_core "https://github.com/yocere/inventario-gen/tree/main/app/Models"
click node_migrations "https://github.com/yocere/inventario-gen/tree/main/database/migrations"
click node_seeders_factories "https://github.com/yocere/inventario-gen/tree/main/database/seeders"
click node_auth_middleware "https://github.com/yocere/inventario-gen/blob/main/app/Http/Middleware/EnsureAdmin.php"
click node_console_commands "https://github.com/yocere/inventario-gen/tree/main/app/Console/Commands"
click node_layout_components "https://github.com/yocere/inventario-gen/tree/main/app/View/Components"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_routes_web,node_routes_auth,node_routes_console toneBlue
class node_ui_controllers,node_api_controllers,node_auth_controllers,node_livewire_crud,node_livewire_ops,node_views,node_layout_components toneAmber
class node_services,node_dtos_enums,node_exceptions toneMint
class node_models_core,node_migrations,node_seeders_factories toneRose
class node_auth_middleware,node_console_commands toneIndigo
```

## Components

### Routing & entrypoints

HTTP and console entrypoints that fan into the app

- [Web routes](https://github.com/yocere/inventario-gen/blob/main/routes/web.php): route map · Main authenticated UI routes and page entrypoints · `routes/web.php`
- [Auth routes](https://github.com/yocere/inventario-gen/blob/main/routes/auth.php): route map · Login, registration, reset, and verification routes · `routes/auth.php`
- [Console routes](https://github.com/yocere/inventario-gen/blob/main/routes/console.php): cli routes · Command registration and scheduled/console wiring · `routes/console.php`

### Presentation layer

Blade, Livewire, and controller-backed screens

- [Page controllers](https://github.com/yocere/inventario-gen/tree/main/app/Http/Controllers): http controllers · Dashboard, profile, purchases, sales, reports, and other full-page controllers · `app/Http/Controllers`
- [API controllers](https://github.com/yocere/inventario-gen/tree/main/app/Http/Controllers/Api): json CRUD · CRUD-style endpoints for core master-data entities and users · `app/Http/Controllers/Api`
- [Auth controllers](https://github.com/yocere/inventario-gen/tree/main/app/Http/Controllers/Auth): auth flow · Session, registration, password reset, and email verification controllers · `app/Http/Controllers/Auth`
- [Livewire CRUD](https://github.com/yocere/inventario-gen/tree/main/app/Livewire): interactive screens · Table/form/detail Livewire components for master data and finance screens · `app/Livewire`
- [Ops screens](https://github.com/yocere/inventario-gen/tree/main/app/Livewire): workflow UI · Dashboard, profile, settings, purchases, sales, and shared Livewire components · `app/Livewire`
- [Blade views](https://github.com/yocere/inventario-gen/tree/main/resources/views): server views · Rendered pages, layouts, reusable components, and print views · `resources/views`
- [UI components](https://github.com/yocere/inventario-gen/tree/main/app/View/Components): blade components · Reusable Blade and view-component building blocks · `app/View/Components`

### Domain services

Application services, DTOs, enums, and exceptions

- [Services](https://github.com/yocere/inventario-gen/tree/main/app/Services): application logic · Orchestrates validation, workflows, reporting, and domain operations · `app/Services`
- [DTOs & enums](https://github.com/yocere/inventario-gen/tree/main/app/DTOs): domain contracts · Typed input objects and shared vocabularies for business rules · `app/DTOs`
- [Domain exceptions](https://github.com/yocere/inventario-gen/tree/main/app/Exceptions): failure model · Entity-specific exceptions used by services and UI flows · `app/Exceptions`

### Persistence layer

Models plus database schema and seed data

- [Eloquent models](https://github.com/yocere/inventario-gen/tree/main/app/Models): entities · Core entities for products, parties, documents, finance, settings, and users · `app/Models`
- [Schema migrations](https://github.com/yocere/inventario-gen/tree/main/database/migrations): schema evolution · Relational schema for master data, transactions, line items, settings, and roles · `database/migrations`
- [Seed data](https://github.com/yocere/inventario-gen/tree/main/database/seeders): bootstrap data · Factories and seeders for initial system state and baseline records · `database/seeders`

### Infrastructure

Auth, middleware, commands, and tooling

- [Admin guard](https://github.com/yocere/inventario-gen/blob/main/app/Http/Middleware/EnsureAdmin.php): middleware · Custom authorization gate for admin-only access · `app/Http/Middleware/EnsureAdmin.php`
- [Console commands](https://github.com/yocere/inventario-gen/tree/main/app/Console/Commands): automation · Bootstrap and reconciliation commands for admin setup and finance sync · `app/Console/Commands`

## Connections

- 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
