Skip to main content

Overview

Sistema de Ventas is a modern, enterprise-grade sales management system designed using microservices architecture. The platform enables complete management of sales operations including customer management, product catalog, inventory control, purchase orders, sales transactions, and payment processing.

8 Microservices

Modular business logic services with independent databases

Angular 18 Frontend

Modern SPA with Material Design components

Spring Cloud Infrastructure

Service discovery, API gateway, and centralized configuration

JWT Security

Secure authentication and authorization across all services

Architecture

The system follows a microservices architecture pattern with the following components:

Core Microservices

1

Authentication Service (jea-auth)

Handles user authentication, JWT token generation and validation, role-based access control
2

Catalog Service (jea-catalogo)

Manages product catalog, categories, pricing, and product inventory levels
3

Customer Service (jea-cliente)

Customer information management and customer relationships
4

Sales Service (jea-venta)

Sales transaction processing with automatic tax calculation (IGV)
5

Purchase Service (jea-compra)

Purchase order management and supplier transactions
6

Order Service (jea-pedidos)

Customer order processing and order lifecycle management
7

Payment Service (jea-pagos)

Payment method configuration and payment processing
8

Supplier Service (jea-proveedor)

Supplier management and supplier relationships

Infrastructure Services

Registry Server

Eureka Server (Port 8090)Service discovery and registration for all microservices

Config Server

Spring Cloud Config (Port 7070)Centralized configuration management via Git repository

API Gateway

Spring Cloud Gateway (Port 8085)Single entry point with JWT authentication and CORS configuration

Technology Stack

Backend Technologies

  • Spring Boot 2.5.4 - Microservices framework
  • Spring Cloud 2020.0.3 - Distributed system patterns
  • Spring Data JPA - Data persistence layer
  • MySQL 8.0 - Relational database
  • JWT (jjwt 0.9.1) - Token-based authentication
  • OpenFeign - Declarative REST client
  • Resilience4j - Circuit breaker pattern
  • Eureka Client - Service registration
  • Java 17 - Runtime environment

Frontend Technologies

  • Angular 18.2 - Frontend framework
  • Angular Material 18.2 - UI component library
  • RxJS 7.8 - Reactive programming
  • Chart.js 4.5 - Data visualization
  • jsPDF 2.5 - PDF generation
  • TypeScript 5.5 - Type-safe JavaScript

Key Features

Automated Business Logic

The system includes intelligent automation for common business operations:
  • Automatic Series & Number Generation - Sales and purchase documents automatically generate unique series and sequential numbers
  • Tax Calculation - IGV (Value Added Tax) automatically calculated on all transactions
  • Inventory Management - Stock levels automatically updated on sales and purchases
  • Timestamp Tracking - Automatic creation and update timestamps for all entities

Inter-Service Communication

The system uses Spring Cloud OpenFeign for synchronous service-to-service communication:
@FeignClient(name = "jea-catalogo-service", path = "/producto")
public interface ProductoFeign {
    
    @GetMapping("/{id}")
    @CircuitBreaker(name = "orderByIdCB", fallbackMethod = "fallbackProductById")
    public ResponseEntity<Producto> listarProducto(@PathVariable Long id);
    
    @PutMapping("/{id}/cantidad")
    @CircuitBreaker(name = "orderByIdCB", fallbackMethod = "fallbackProductById")
    ResponseEntity<Producto> actualizarCantidad(@PathVariable Long id, 
                                                @RequestBody Integer nuevaCantidad);
    
    default ResponseEntity<Producto> fallbackProductById(Long id, Exception e) {
        Producto productDto = new Producto();
        productDto.setNombre("Servicio no disponible de producto");
        return ResponseEntity.ok(productDto);
    }
}

Gateway Routing

All client requests flow through the API Gateway which provides routing, authentication, and CORS handling:
spring:
  cloud:
    gateway:
      routes:
        - id: jea-auth-service
          uri: lb://jea-auth-service
          predicates:
            - Path=/auth/**, /usuario/**, /rol/**
        
        - id: jea-catalogo-service
          uri: lb://jea-catalogo-service
          predicates:
            - Path=/categoria/**, /producto/**, /imagenes/**
          filters:
            - AuthFilter
Most service routes require JWT authentication via the AuthFilter, except public endpoints like /auth/login and /imagenes/**

Database Architecture

Each microservice maintains its own MySQL database following the database-per-service pattern:
ServiceDatabasePurpose
jea-authauth-jeaUsers, roles, and access control
jea-catalogocatalogo-msProducts and categories
jea-clientejeaclienteCustomer information
jea-ventajeaventaSales transactions
jea-comprajeacompraPurchase orders
jea-pagosjeapagosPayment methods
jea-proveedorjeaproveedorSupplier information
jea-pedidosjeapedidosCustomer orders

Security Model

The system implements a comprehensive security model:

JWT Authentication Flow

  1. Login - User authenticates via /auth/login endpoint
  2. Token Generation - JWT token created with 1-hour expiration
  3. Token Validation - Gateway validates tokens before routing requests
  4. Service Access - Protected services receive validated requests
public String createToken(AuthUser authUser) {
    Map<String, Object> claims = new HashMap<>();
    claims = Jwts.claims().setSubject(authUser.getUserName());
    claims.put("id", authUser.getId());
    Date now = new Date();
    Date exp = new Date(now.getTime() + 3600000); // 1 hour
    return Jwts.builder()
            .setClaims(claims)
            .setIssuedAt(now)
            .setExpiration(exp)
            .signWith(SignatureAlgorithm.HS256, secret)
            .compact();
}

Role-Based Access Control

The authentication service manages users, roles, and access permissions through a flexible many-to-many relationship model.

System Benefits

Scalability

Independent scaling of microservices based on load

Resilience

Circuit breakers and fallback mechanisms prevent cascade failures

Maintainability

Clear separation of concerns and modular architecture

Technology Freedom

Each service can adopt different technologies as needed

Next Steps

Quickstart Guide

Set up and run the complete system locally

Features Overview

Explore detailed capabilities of each service

Build docs developers (and LLMs) love