Business Microservices
Sistema de Ventas consists of 8 business microservices, each responsible for a specific domain:Auth Service
Authentication, authorization, user and role management
Catalogo Service
Product catalog, categories, and inventory management
Cliente Service
Customer information and management
Venta Service
Sales transactions and order processing
Compra Service
Purchase orders and supplier transactions
Pedido Service
Customer orders and order fulfillment
Pagos Service
Payment methods and processing
Proveedor Service
Supplier information and management
Auth Service (jea-auth-service)
Overview
Handles authentication, authorization, user management, and role-based access control.Technical Details
- Port: Dynamic (configured via environment)
- Database: MySQL (
auth-jea) - API Routes:
/auth/**,/usuario/**,/rol/** - Authentication: JWT-based with configurable secret
Key Entities
Usuario (User)
AuthUser (Authentication User)
- Username
- Password (encrypted)
- Active status
Rol (Role)
- Role name
- Description
- Permissions
Acceso (Access/Permission)
- Access name
- Resource
- Action
Relationships
- Usuario ↔ AuthUser: One-to-One
- Usuario ↔ Rol: Many-to-Many (via UsuarioRol)
- Rol ↔ Acceso: Many-to-Many (via AccesoRol)
Responsibilities
- User registration and profile management
- Login and JWT token generation
- Role and permission management
- Access control validation
- User authentication and authorization
Catalogo Service (jea-catalogo-service)
Overview
Manages product catalog, categories, and inventory levels.Technical Details
- Port: Dynamic
- Database: MySQL (
catalogo-ms) - API Routes:
/categoria/**,/producto/**,/imagenes/** - Protected: Requires authentication (AuthFilter)
Key Entities
Producto (Product)
Categoria (Category)
Responsibilities
- Product CRUD operations
- Category management
- Inventory tracking
- Product search and filtering
- Product image management
- Stock level updates
Business Rules
- Product codes and names must be unique
- Default quantity is 0 for new products
- Timestamps are automatically managed
- Products are associated with a single category
Cliente Service (jea-cliente-service)
Overview
Manages customer information and profiles.Technical Details
- Port: Dynamic
- Database: PostgreSQL (
cliente-jea) - API Routes:
/cliente/** - Protected: Requires authentication
Key Entities
Cliente (Customer)
Responsibilities
- Customer registration
- Customer profile management
- Customer search and listing
- Customer status management (active/inactive)
Business Rules
- DNI must be unique
- Email must be unique
- Registration date is automatically set
- Customers are active by default
Venta Service (jea-venta-service)
Overview
Handles sales transactions and manages the complete sales workflow.Technical Details
- Port: Dynamic
- Database: MySQL (
venta-jea) - API Routes:
/venta/** - Protected: Requires authentication
- Circuit Breaker: Configured for Cliente and Pedido services
Key Entities
Venta (Sale)
VentaDetalle (Sale Detail)
Service Integration (Feign Clients)
- ClienteFeign: Fetches customer information
- ProductoFeign: Fetches product details and updates stock
- FormaPagoFeign: Fetches payment method information
- CategoriaFeign: Fetches category information
Responsibilities
- Create and manage sales
- Calculate tax and totals (18% IGV)
- Generate unique series and numbers
- Update product inventory
- Track sales history
- Sales reporting and analytics
Business Rules
- Serie and número are auto-generated and unique
- Tax calculation: Base = Price / 1.18, IGV = Price - Base
- Totals are automatically calculated from line items
- Inventory is updated upon sale completion
Compra Service (jea-compra-service)
Overview
Manages purchase orders from suppliers.Technical Details
- Port: Dynamic
- Database: MySQL (
compra-jea) - API Routes:
/compra/** - Protected: Requires authentication
- Circuit Breaker: Configured for external services
Key Entities
Compra (Purchase)
CompraDetalle (Purchase Detail)
Service Integration
- ProveedorFeign: Fetches supplier information
- ProductoFeign: Updates product stock and cost
- FormaPagoFeign: Fetches payment method
Responsibilities
- Create and manage purchase orders
- Calculate costs and taxes
- Update product inventory upon receipt
- Track purchase history
- Supplier order management
Pedido Service (jea-pedido-service)
Overview
Manages customer orders and order fulfillment workflow.Technical Details
- Port: Dynamic
- Database: MySQL (
pedido-jea) - API Routes:
/pedido/** - Protected: Requires authentication
- Circuit Breaker: Configured
Key Entities
Pedido (Order)
PedidoDetalle (Order Detail)
- Similar structure to VentaDetalle and CompraDetalle
- Links to products via productoId
Responsibilities
- Create and manage customer orders
- Track order status (pending, processing, completed)
- Schedule delivery dates
- Calculate order totals
- Order fulfillment workflow
Business Rules
- Default estado is “PENDIENTE”
- Delivery date defaults to 1 week after order date
- Tax calculations follow same rules as Venta
Pagos Service (jea-pagos-service)
Overview
Manages payment methods and processing.Technical Details
- Port: Dynamic
- Database: MySQL (
pagos-ms) - API Routes:
/pagos/** - Protected: Requires authentication
Key Entities
FormaPago (Payment Method)
Supported Payment Methods
- Efectivo (Cash)
- Transferencia Bancaria (Bank Transfer)
- Cheque (Check)
- Tarjeta de Crédito (Credit Card)
- Tarjeta de Débito (Debit Card)
- Depósito Bancario (Bank Deposit)
- Letra de Cambio (Bill of Exchange)
- Pagaré (Promissory Note)
Responsibilities
- Manage payment method catalog
- Provide payment method information to other services
- Payment method CRUD operations
Proveedor Service (jea-proveedor-service)
Overview
Manages supplier information and relationships.Technical Details
- Port: Dynamic
- Database: PostgreSQL (
proveedor-jea) - API Routes:
/proveedor/** - Protected: Requires authentication
Key Entities
Proveedor (Supplier)
Responsibilities
- Supplier registration and management
- Supplier information lookup
- Supplier status management
- Supplier contact information
Business Rules
- Suppliers are active by default
- RUC serves as unique identifier
Inter-Service Communication
Service Dependencies
Circuit Breaker Configuration
All transaction services (Venta, Compra, Pedido) implement Resilience4j circuit breakers:Fallback Mechanisms
Each Feign client provides fallback methods for graceful degradation:- Returns default/placeholder data when service is unavailable
- Logs errors for monitoring
- Maintains system availability despite partial failures
API Documentation
All services expose OpenAPI/Swagger documentation:- Swagger UI Path:
/doc/swagger-ui.html - API Docs: SpringDoc OpenAPI enabled
- Access via Gateway:
http://localhost:8085/{service-path}/doc/swagger-ui.html
Next Steps
Infrastructure
Learn about Gateway, Registry, and Config Server
Database Design
Explore database schemas and structure