System Overview
Sistema de Ventas is a comprehensive sales management system built with a microservices architecture using Spring Boot and Spring Cloud. The system handles the complete lifecycle of sales operations including product catalog management, customer management, sales, purchases, orders, and payments.Architecture Style
The system follows a microservices architecture pattern with the following key characteristics:- Service Independence: Each microservice owns its data and business logic
- Distributed System: Services communicate via REST APIs and service discovery
- Polyglot Persistence: Uses both MySQL and PostgreSQL databases
- Cloud-Native: Built with Spring Cloud for resilience and scalability
- API Gateway Pattern: Single entry point for all client requests
High-Level Architecture
Core Components
Infrastructure Services
- API Gateway (Port 8085): Request routing and authentication
- Service Registry (Port 8090): Service discovery with Eureka
- Config Server: Centralized configuration management
Business Services
8 domain microservices handling:
- Authentication & Authorization
- Product Catalog
- Customer & Supplier Management
- Sales, Purchases & Orders
- Payment Processing
Frontend
Angular-based web application providing:
- User interface for all operations
- Real-time data visualization
- Responsive design
Databases
- MySQL: Auth, Catalog, Sales, Purchases, Orders, Payments
- PostgreSQL: Customers, Suppliers
Key Architectural Patterns
Service Discovery
All microservices register with Eureka Server, enabling dynamic service location and load balancing without hardcoded endpoints.API Gateway
Spring Cloud Gateway provides:- Single entry point for all client requests
- Route-based request forwarding
- Authentication filter for protected endpoints
- CORS configuration
- Load balancing via Eureka integration
Circuit Breaker
Resilience4j circuit breakers protect against cascading failures:- Configured on Feign clients for inter-service communication
- Fallback methods provide graceful degradation
- Health indicators for monitoring
Configuration Management
Centralized configuration with Spring Cloud Config Server:- YAML-based configuration per service
- Environment-specific settings
- Dynamic configuration updates
Database per Service
Each microservice has its own database schema:- Data independence and loose coupling
- Technology diversity (MySQL and PostgreSQL)
- Independent scaling and deployment
Communication Patterns
Synchronous Communication
- REST APIs: All services expose RESTful endpoints
- OpenFeign Clients: Type-safe HTTP clients for inter-service calls
- Load Balancing: Client-side load balancing via Ribbon/Spring Cloud LoadBalancer
Service-to-Service Communication
Services communicate through:- API Gateway for external requests
- Direct Feign Calls for internal requests
- Service Discovery for endpoint resolution
Cross-Cutting Concerns
Security
- JWT-based authentication in Auth Service
- Gateway-level authentication filter
- Role-based access control
Data Management
- JPA/Hibernate for ORM
- Automatic schema generation (ddl-auto: update)
- Transaction management per service
Monitoring & Documentation
- SpringDoc OpenAPI/Swagger UI per service
- Eureka dashboard for service health
- Circuit breaker health indicators
Technology Stack
Backend Framework
- Spring Boot 2.x/3.x
- Spring Cloud
- Spring Data JPA
Service Infrastructure
- Eureka (Service Registry)
- Spring Cloud Gateway
- Spring Cloud Config
- Resilience4j
Data & APIs
- MySQL Database
- PostgreSQL Database
- OpenFeign
- SpringDoc OpenAPI
Deployment Architecture
The system is designed for:- Local Development: All services run on localhost with dynamic ports
- Container Deployment: Docker-ready with MySQL initialization scripts
- Cloud Deployment: Cloud-native patterns for Kubernetes or cloud platforms
Next Steps
Microservices Details
Explore each microservice’s responsibilities and endpoints
Infrastructure
Learn about service registry, gateway, and config server
Database Design
Understand database schemas and relationships
Data Models
Review entity relationships and domain models