Skip to main content
This guide covers the complete setup process for all backend microservices in Sistema de Ventas.

Service Architecture Overview

Sistema de Ventas follows a microservices architecture with:
  • 2 Infrastructure Services: Config Server, Eureka Registry
  • 1 API Gateway: Spring Cloud Gateway
  • 8 Business Services: Auth, Catalogo, Cliente, Venta, Compra, Pedidos, Pagos, Proveedor

Service Dependencies

Spring Boot Version Matrix

ServiceSpring BootSpring CloudJavaDatabase
Config Server3.5.02025.0.0-RC117-
Registry Server3.5.02025.0.0-RC117-
Gateway Server3.3.32023.0.317-
Auth Service2.5.42020.0.317MySQL
Cliente Service3.1.32022.0.217PostgreSQL
Catalogo Service3.1.32022.0.217MySQL
Venta Service3.1.32022.0.217MySQL
Compra Service3.1.32022.0.217MySQL
Pedidos Service3.1.32022.0.217MySQL
Pagos Service3.1.32022.0.217MySQL
Proveedor Service3.1.32022.0.217MySQL

Prerequisites

Before starting, ensure:

Clone Repository

git clone https://github.com/Erick-Franco/Sistema-ventas-ms.git
cd Sistema-ventas-ms

Infrastructure Services

Step 1: Start Config Server

The Config Server must start first as it provides configuration to all other services.
1

Navigate to Config Server

cd jea-config-server
2

Review Configuration

The Config Server is configured to read from GitHub:
config-server/src/main/resources/application.yml
server:
  port: 7070
spring:
  application:
    name: config-server
  cloud:
    config:
      server:
        git:
          uri: https://github.com/Erick-Franco/Sistema-ventas-ms.git
          searchPaths: config-data
          default-label: main
  security:
    user:
      name: root
      password: 123456
3

Build and Run

# Clean and install
mvn clean install -DskipTests

# Run the service
mvn spring-boot:run
4

Verify Config Server

# Check health
curl http://localhost:7070/actuator/health

# Test configuration endpoint
curl http://root:123456@localhost:7070/jea-auth-service/default
Expected: Configuration JSON response
Keep this terminal open. Config Server must run continuously.

Step 2: Start Eureka Registry Server

1

Navigate to Registry Server

Open a new terminal:
cd jea-registry-server
2

Review Configuration

registry-server/config-data/jea-registry-service.yml
server:
  port: 8090
eureka:
  instance:
    hostname: localhost
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://localhost:8090/eureka/
3

Build and Run

mvn clean install -DskipTests
mvn spring-boot:run
4

Verify Registry Server

Open browser: http://localhost:8090You should see the Eureka Dashboard.
Keep this terminal open. All microservices register with Eureka.

Step 3: Start API Gateway

1

Navigate to Gateway

Open a new terminal:
cd jea-gateway-server
2

Review Gateway Configuration

The gateway routes all requests to microservices:
config-data/jea-gateway-service.yml
server:
  port: 8085

spring:
  cloud:
    gateway:
      globalcors:
        corsConfigurations:
          '[/**]':
            allowedOrigins: "http://localhost:4200"
            allowedHeaders: "*"
            allowedMethods:
              - GET
              - POST
              - PUT
              - DELETE
      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
3

Build and Run

mvn clean install -DskipTests
mvn spring-boot:run
4

Verify Gateway

# Check gateway health
curl http://localhost:8085/actuator/health
Check Eureka Dashboard - Gateway should be registered.

Business Microservices

Step 4: Start Auth Service

The Auth service handles user authentication and JWT token generation.
1

Navigate to Auth Service

Open a new terminal:
cd jea-auth
2

Review Auth Configuration

config-data/jea-auth-service.yml
server:
  port: ${PORT:${SERVERS_PORT:0}}  # Dynamic port

spring:
  application:
    name: jea-auth-service
  datasource:
    url: jdbc:mysql://localhost:3306/auth-jea
    username: root
    password: ""
    driver-class-name: com.mysql.cj.jdbc.Driver
  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true

jwt:
  secret: secret
3

Update Dependencies

mvn clean install -DskipTests
4

Run Auth Service

mvn spring-boot:run
The service will:
  • Connect to Config Server
  • Register with Eureka
  • Create database tables automatically
  • Start on a dynamic port
5

Verify Auth Service

Check Eureka Dashboard at http://localhost:8090jea-auth-service should appear in registered instances.

Step 5: Start Remaining Business Services

Start each service in a new terminal:
cd jea-catalogo
mvn clean install -DskipTests
mvn spring-boot:run
Configuration:
  • Database: catalogo-ms (MySQL)
  • Dynamic port allocation
  • Swagger UI: /doc/swagger-ui.html

Startup Order Summary

CRITICAL: Services must start in this order:
1

Infrastructure Layer

  1. Config Server (port 7070) - Wait 30 seconds
  2. Eureka Registry (port 8090) - Wait 30 seconds
  3. API Gateway (port 8085) - Wait 20 seconds
2

Business Layer

  1. Auth Service - Wait for Eureka registration
  2. All other services (can start in parallel)

Verify Complete Deployment

Check Eureka Dashboard

Visit: http://localhost:8090 You should see all services registered:
  • JEA-GATEWAY-SERVICE
  • JEA-AUTH-SERVICE
  • JEA-CATALOGO-SERVICE
  • JEA-CLIENTE-SERVICE
  • JEA-VENTA-SERVICE
  • JEA-COMPRA-SERVICE
  • JEA-PEDIDO-SERVICE
  • JEA-PAGOS-SERVICE
  • JEA-PROVEEDOR-SERVICE

Test Gateway Routes

# Gateway health
curl http://localhost:8085/actuator/health

Service Configuration Details

Database Connections

# Auth, Catalogo, Venta, Compra, Pedidos, Pagos, Proveedor
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/<database-name>
    username: root
    password: ""
    driver-class-name: com.mysql.cj.jdbc.Driver

Eureka Client Configuration

All services connect to Eureka:
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8090/eureka
  instance:
    hostname: localhost
    instance-id: ${spring.application.name}:${spring.application.instance_id:${random.value}}

Circuit Breaker Configuration

Venta, Compra, and Pedidos services use Resilience4j:
resilience4j.circuitbreaker:
  instances:
    orderByIdCB:
      registerHealthIndicator: true
      slidingWindowSize: 10
      permittedNumberOfCallsInHalfOpenState: 3
      slidingWindowType: TIME_BASED
      minimumNumberOfCalls: 4
      waitDurationInOpenState: 5s
      failureRateThreshold: 50
      eventConsumerBufferSize: 10

Troubleshooting

Issue: Could not locate PropertySource errorSolutions:
  1. Ensure Config Server is running on port 7070
  2. Check bootstrap.yml has correct config server URL:
    spring:
      cloud:
        config:
          uri: http://localhost:7070
    
  3. Verify config-data folder exists in GitHub repo
Issue: Service doesn’t appear in Eureka dashboardSolutions:
  1. Check Eureka is running: http://localhost:8090
  2. Verify application.yml has eureka client config
  3. Check logs for connection errors
  4. Wait 30-60 seconds for registration
Issue: Communications link failure or Access deniedSolutions:
  1. Verify database exists: SHOW DATABASES;
  2. Check username/password in service config
  3. Ensure MySQL/PostgreSQL is running
  4. Test connection: mysql -u root -p
Issue: Port 8085 is already in useSolutions:
# Find process using port
lsof -i :8085

# Kill process
kill -9 <PID>

# Or use different port
mvn spring-boot:run -Dspring-boot.run.arguments=--server.port=8086
Issue: Dependencies not resolvingSolutions:
# Clear Maven cache
mvn dependency:purge-local-repository

# Force update
mvn clean install -U

# Skip tests
mvn clean install -DskipTests

Production Deployment

Build Production JARs

1

Build All Services

# Build all services
for dir in jea-*/; do
  echo "Building $dir"
  cd "$dir"
  mvn clean package -DskipTests
  cd ..
done
2

Create Deployment Directory

mkdir -p deployment/jars

# Copy all JARs
find . -name "*.jar" -path "*/target/*" -exec cp {} deployment/jars/ \;
3

Run with Production Profiles

# Config Server
java -jar -Dspring.profiles.active=prod jea-config-server-0.0.1-SNAPSHOT.jar

# Eureka Registry
java -jar -Dspring.profiles.active=prod jea-registry-server-0.0.1-SNAPSHOT.jar

# Gateway
java -jar -Dspring.profiles.active=prod jea-gateway-server-0.0.1-SNAPSHOT.jar

Environment Variables

Use environment variables for production:
export SPRING_PROFILES_ACTIVE=prod
export CONFIG_SERVER_URI=http://config-server:7070
export EUREKA_URI=http://eureka-server:8090/eureka
export DB_HOST=mysql-server
export DB_PASSWORD=secure_password

java -jar jea-auth-0.0.1-SNAPSHOT.jar

Automated Startup Script

Create start-all.sh:
start-all.sh
#!/bin/bash

echo "Starting Config Server..."
cd jea-config-server && mvn spring-boot:run &
sleep 30

echo "Starting Eureka Registry..."
cd ../jea-registry-server && mvn spring-boot:run &
sleep 30

echo "Starting API Gateway..."
cd ../jea-gateway-server && mvn spring-boot:run &
sleep 20

echo "Starting Auth Service..."
cd ../jea-auth && mvn spring-boot:run &
sleep 10

echo "Starting Business Services..."
cd ../jea-catalogo && mvn spring-boot:run &
cd ../jea-cliente && mvn spring-boot:run &
cd ../jea-venta && mvn spring-boot:run &
cd ../jea-compra && mvn spring-boot:run &
cd ../jea-pedidos && mvn spring-boot:run &
cd ../jea-pagos && mvn spring-boot:run &
cd ../jea-proveedor && mvn spring-boot:run &

echo "All services started! Check Eureka: http://localhost:8090"
chmod +x start-all.sh
./start-all.sh

Next Steps

Frontend Setup

Configure and run Angular frontend

Docker Deployment

Deploy using Docker containers

Build docs developers (and LLMs) love