How alfredo1995/erp works
Purpose and Entry Points
This is a Laravel 8 migration of a legacy PHP ERP-style supplier database application. It manages suppliers, products, purchasing orders, sales products, and sales orders. HTTP requests enter through server.php/public-style Laravel bootstrap conventions, initialize at bootstrap/app.php, and pass through app/Http/Kernel.php. CLI operations use artisan and app/Console/Kernel.php.
Routing and HTTP Boundary
Route definitions separate browser and API surfaces:
• routes/web.php
• routes/api.php
• routes/channels.php
The intended primary UI flow is resource-like CRUD routing, especially for suppliers (fornecedores). Controllers receive requests after Laravel’s middleware stack, including authentication, CSRF protection, cookie encryption, proxy handling, and maintenance mode controls in app/Http/Middleware/.
Domain Controllers
Application orchestration is concentrated in CRUD controllers:
• app/Http/Controllers/FornecedorController.php
• app/Http/Controllers/ProdutoController.php
• app/Http/Controllers/PedidoController.php
• app/Http/Controllers/PedidoVendaController.php
• app/Http/Controllers/ProdutoVendaController.php
These controllers are expected to list records, render create/edit views, persist request fields, redirect to named routes, and use route-model binding for updates/deletes. The README documents this pattern primarily for FornecedorController.
Persistence and Legacy Schema Mapping
Eloquent models form the persistence boundary to MySQL:
• app/Models/Fornecedor.php
• app/Models/Produto.php
• app/Models/Pedido.php
• app/Models/PedidoVenda.php
• app/Models/ProdutoVenda.php
• app/Models/Banco.php
• app/Models/Estado.php
The supplier model is intended to map to legacy table sp_supplier, use sup_id as its primary key, disable timestamps, and whitelist legacy fields for mass assignment. This makes the app dependent on imported legacy database structure rather than solely Laravel-created schema.
Primary Data Flow
A typical supplier lifecycle is: browser form → named route in routes/web.php → FornecedorController → Fornecedor Eloquent model → MySQL database → redirect back to a listing view. Index actions retrieve records via Eloquent; create/edit actions supply form data; store/update actions persist request input; destroy removes the bound model. Product and order controllers appear designed to follow the same CRUD control flow.
Runtime, Infrastructure, and External Dependencies
The material runtime is PHP/Laravel 8 with Composer (composer.lock) and MySQL, configured through config/database.php. The documented deployment expects a local MySQL database named Fornecedores with a manually imported legacy database. Front-end asset compilation is available through Laravel Mix in webpack.mix.js; the README references Bootstrap 5-oriented scaffold views, though no view files are present in the supplied tree.
Framework Services and Operational Boundaries
Laravel service providers wire application, auth, events, routes, and broadcasting:
• app/Providers/AppServiceProvider.php
• app/Providers/AuthServiceProvider.php
• app/Providers/RouteServiceProvider.php
Authentication/session behavior is configured under config/auth.php and config/session.php. Queue, cache, mail, filesystems, logging, and broadcasting have standard Laravel configuration files, but the repository tree provides no evidence that the business flows actively integrate external mail, queue workers, or broadcast services.
Main entry points: web.php Browser routes · Fornecedor.php Legacy Eloquent models · app.php Application bootstrap · AppServiceProvider.php Service providers
Components 19
Runtime Entry
- PHP web entry
server.php - Application bootstrap
bootstrap/app.php - Artisan CLI
artisan - Console kernel
app/Console/Kernel.php
HTTP Boundary
- HTTP kernel · Applies authentication, CSRF, cookies, proxies, and maintenance middleware.
app/Http/Kernel.php - HTTP middleware
- Browser routes · Primary named CRUD routes, including suppliers.
routes/web.php - API routes
routes/api.php - Channel routes
routes/channels.php
CRUD Domain
- Supplier CRUD
app/Http/Controllers/FornecedorController.php - Product CRUD
app/Http/Controllers/ProdutoController.php - Purchase order CRUD
app/Http/Controllers/PedidoController.php - Sales order CRUD
app/Http/Controllers/PedidoVendaController.php - Sales product CRUD
app/Http/Controllers/ProdutoVendaController.php
Persistence & Infrastructure
- Legacy Eloquent models · Models map suppliers, products, orders, banks, and states to the legacy schema.
app/Models/Fornecedor.php - Legacy MySQL database · Manually imported Fornecedores database; supplier table uses sp_supplier and sup_id.
config/database.php - Service providers · Wires application, authentication, events, routes, and broadcasting.
app/Providers/AppServiceProvider.php - Auth & sessions
config/auth.php - Laravel Mix assets
webpack.mix.js
Connections 22
- PHP web entry → Application bootstrap: bootstraps
- Artisan CLI → Application bootstrap: bootstraps
- Artisan CLI → Console kernel: runs commands through
- Application bootstrap → HTTP kernel: creates HTTP app
- Application bootstrap → Service providers: loads
- HTTP kernel → HTTP middleware: executes
- HTTP middleware → Browser routes: dispatches browser requests
- HTTP middleware → API routes: dispatches API requests
- Browser routes → Supplier CRUD: supplier CRUD
- Browser routes → Product CRUD: product CRUD
- Browser routes → Purchase order CRUD: purchase CRUD
- Browser routes → Sales order CRUD: sales-order CRUD
- Browser routes → Sales product CRUD: sales-product CRUD
- Supplier CRUD → Legacy Eloquent models: CRUD and route binding
- Product CRUD → Legacy Eloquent models: CRUD
- Purchase order CRUD → Legacy Eloquent models: CRUD
- Sales order CRUD → Legacy Eloquent models: CRUD
- Sales product CRUD → Legacy Eloquent models: CRUD
- Legacy Eloquent models → Legacy MySQL database: reads and persists
- Service providers → Browser routes: registers routes
- Service providers → Auth & sessions: configures auth services
- Auth & sessions → HTTP middleware: supports sessions and auth