How joaotux/pdv works
1. Overall shape
- This is a Spring-based monolithic ERP/PDV application.
- It follows a classic server-rendered MVC architecture: browser requests hit Spring controllers, which delegate to services, which call repositories, which persist to MySQL via Hibernate/JPA.
2. Presentation layer
- The user interface is built with Thymeleaf templates under src/main/resources/templates.
- Page fragments are organized by business area: venda, caixa, produto, pessoa, nota fiscal, tributação, usuário, etc.
- Static assets live in src/main/resources/static and include CSS, JavaScript, masks/validation scripts, images, and icons.
3. Web/API controllers
- Controllers under net.originmobi.pdv.controller are the main entry points for business features such as sales, cash register, payments, people, products, tax rules, user/group management, and reports.
- The controllers are organized by domain rather than by technical layer, which makes each module relatively self-contained.
- There is also a relatorios package with dedicated report controllers, separate from the CRUD-oriented controllers.
4. Business/service layer
- The service package contains most of the business logic and orchestration.
- Services typically sit between controllers and repositories and encapsulate domain operations like sales handling, cash movements, receivables/payables, product stock updates, user permissions, and invoice/tax processing.
- A notable boundary is the NFe/invoice subdomain, which has its own service classes under service/notafiscal, indicating more specialized processing than standard CRUD.
5. Persistence layer
- The repository package contains the data access interfaces for entities like Produto, Venda, Caixa, Receber, Pagar, NotaFiscal, Usuario, and many support tables.
- There are dedicated repository subpackages for cartao and notafiscal, reflecting separate subdomains with their own persistence concerns.
- The presence of Hibernate in the README and repository interfaces implies Spring Data JPA-style persistence over MySQL.
6. Domain model
- The model package contains the core entities and relationships for the ERP: products, people, companies, addresses, tax configurations, sales, payments, cash movements, accounts payable/receivable, invoices, and card transactions.
- The model is broad and business-heavy; it is not a thin CRUD schema.
- Several related value-like entities and enumerations capture operational states such as sale status, cash movement type, product control flags, card status, and invoice type.
7. Subdomain boundaries
- The code is split into business areas that map well to an architecture diagram:
- Venda: sales and sold items
- Caixa: cash register opening/closing and movements
- Pagar/Receber: financial obligations and collections
- Cartão: card terminals and card settlements
- Nota Fiscal: invoice generation and tax composition
- Tributação: tax rules and regimes
- Cadastro: products, people, suppliers, categories, groups, users
- These areas share infrastructure but keep their own controllers/services/repositories.
8. Security and access control
- The security package contains Spring Security integration, including a custom UserDetailsService and a user principal wrapper.
- Permissions are domain-driven: users belong to groups, and groups have permissions.
- This means authorization is part of the business model, not just a technical add-on.
9. Reporting and document generation
- Report generation is handled in the relatorios package, with .jrxml templates stored under resources/relatorios.
- This suggests JasperReports-style PDF/report output for operational views like cash and sales reports.
- XML/NFe support is also explicit in xml/nfe, where invoice XML generation, signing, and conversion are isolated from the rest of the app.
10. Infrastructure and startup
- PdvApplication.java is the Spring Boot entry point.
- Database schema initialization is managed with Flyway migrations in resources/db/migration, which means schema and seed data are versioned with the codebase.
- application.properties is the main runtime configuration point, including MySQL connection settings.
11. Supporting utilities and state
- utilitarios contains low-level helpers such as JDBC connection handling and date utilities.
- singleton/Aplicacao.java suggests there is some globally shared application state or bootstrap context beyond standard Spring bean usage.
- These are cross-cutting utilities rather than domain modules.
12. Typical request/data flow
- A user action in a Thymeleaf page triggers a controller request.
- The controller delegates to one or more services for validation and business rules.
- Services load/update entities through repositories, often involving multiple related models such as sale + items + stock + cash movement.
- Results are rendered back to the same server-side templates, or exported through report/XML generation paths.
13. Notable architectural traits
- The repo is strongly business-domain oriented, with significant overlap between operational finance, sales, stock, and fiscal concerns.
- It is a single deployable application rather than a distributed system.
- The main architectural boundaries are by subdomain and by layer, with security, reporting, and fiscal document generation as important cross-cutting concerns.
Main entry points: service Services · repository Repositories · controller MVC Layer · model Domain Model
Components 19
Presentation
Server-rendered MVC UI, controllers, and static assets
- MVC Layer · Primary Spring MVC entry points for business features
src/main/java/net/originmobi/pdv/controller - Thymeleaf · Rendered pages and fragments organized by business area
src/main/resources/templates - Static UI · CSS, JavaScript, images, and client-side validation helpers
src/main/resources/static
Domain
Core business services and entities
- Services · Domain orchestration and business rules across sales, finance, stock, and users
src/main/java/net/originmobi/pdv/service - Venda · Sale lifecycle, sold items, and stock-linked sales processing
src/main/java/net/originmobi/pdv/service/VendaService.java - Caixa · Cash register opening, closing, and movements
src/main/java/net/originmobi/pdv/service/CaixaService.java - Finance · Payables, receivables, installments, and transfers
src/main/java/net/originmobi/pdv/service - Fiscal · Tributação, CFOP, regime, and invoice tax composition
src/main/java/net/originmobi/pdv/service/notafiscal - Cadastro · Products, people, companies, categories, images, and related registries
src/main/java/net/originmobi/pdv/service - Domain Model · Business entities for sales, finance, tax, users, and invoices
src/main/java/net/originmobi/pdv/model
Persistence
Spring Data repositories and database access
- Repositories · Spring Data repositories for JPA persistence
src/main/java/net/originmobi/pdv/repository - NFe Repos · Dedicated persistence for fiscal document subdomain
src/main/java/net/originmobi/pdv/repository/notafiscal - Card Repos · Persistence for card settlement and machine data
src/main/java/net/originmobi/pdv/repository/cartao
Fiscal & Reports
Invoice/XML/report generation and special fiscal workflows
Infrastructure
Security, bootstrap, shared utilities, and startup
- PdvApp · Application bootstrap and main entry point
src/main/java/net/originmobi/pdv/PdvApplication.java - Security · Spring Security integration and user principal handling
src/main/java/net/originmobi/pdv/security - Runtime Config · Application properties, Flyway migrations, and report templates
src/main/resources - Utilities · JDBC and date helpers plus shared singleton state
src/main/java/net/originmobi/pdv/utilitarios
Connections 23
- PdvApp → MVC Layer: starts · Bootstraps the MVC application and request handling
- MVC Layer → Thymeleaf: renders · Controllers return Thymeleaf views
- MVC Layer → Services: delegates · Web layer hands off business operations to services
- MVC Layer → Reports: opens reports · Report endpoints trigger document generation
- Security → MVC Layer: protects · Secures controller access through Spring Security
- Services → Domain Model: uses · Services orchestrate the core entities
- Services → Repositories: persists via · Business logic reads and writes through repositories
- Services → Fiscal: specializes · Fiscal services handle invoice and tax workflows
- Services → Finance: coordinates · Finance workflows span receivables, payables, and transfers
- Services → Cadastro: manages · Master data services maintain catalog and registry data
- Venda → Repositories: loads/saves · Sale processing persists sales and items
- Caixa → Repositories: loads/saves · Cash movements and register state are persisted
- Fiscal → NFe Repos: persists · Invoice persistence is isolated in the fiscal repository set
- Fiscal → NFe XML: generates · Invoice services feed XML signing and conversion
- Finance → Repositories: persists via · Accounts and transfers use the shared data layer
- Cadastro → Repositories: persists via · Product and registry services use repositories
- Domain Model → Repositories: mapped by · Entities are the JPA persistence model
- Repositories → Runtime Config: initialized by · Schema and seed data come from Flyway migrations
- Reports → Runtime Config: templates · Report layouts are stored as JRXML resources
- Security → Domain Model: auth model · Users, groups, and permissions are part of the domain model
- Utilities → Services: supports · Cross-cutting helpers are used across business logic
- MVC Layer → Domain Model: binds · Controllers bind form data to domain entities
- Card Repos → Domain Model: stores · Card settlement data is persisted through dedicated repositories