Skip to main content
SmartLogix follows a twelve-factor approach to configuration: every tunable value is read from environment variables at startup, with sensible defaults defined in each service’s application.properties. The docker-compose.yml file is the single place you override those defaults for a Docker deployment.

Configuration approach

Each Spring Boot service reads its settings from application.properties using the ${VAR_NAME:default} syntax. When you pass an environment variable through docker-compose.yml, it takes precedence over the embedded default. No configuration files need to be edited; you only need to set the right environment variables.
All service-to-service URLs use Docker Compose service names as hostnames (for example http://ms-inventario:8082). These names resolve automatically inside the smartlogix-net bridge network and must not be changed without also updating the gateway routing config.

API gateway routing

The API gateway (api-gateway, port 8080) is the single entry point for all client requests. It is built with Spring Cloud Gateway MVC and uses a stripPrefix(1) filter on every route, which removes the /api prefix before forwarding to the downstream service.
Incoming path (client)Forwarded toAuth required
POST /api/auth/**http://auth-service:8081/auth/**No
GET/POST /api/inventario/**http://ms-inventario:8082/inventario/**Yes (JWT)
GET/POST /api/pedidos/**http://ms-pedidos:8083/pedidos/**Yes (JWT)
GET/POST /api/envios/**http://ms-envios:8084/envios/**Yes (JWT)
The AuthFilter intercepts every protected route and validates the Authorization: Bearer <token> header using the shared JWT_SECRET. Requests without a valid token receive a 401 Unauthorized response from the gateway before reaching the downstream service.
The /api/auth/** route is intentionally public so that clients can obtain a token without already having one. All other routes require a valid JWT.

CORS configuration

CORS is configured on the gateway for browser clients. The following origins are permitted:
OriginTypical use case
http://localhost:5173Vite dev server (npm run dev)
http://localhost:3000Alternate local dev port
http://127.0.0.1:5173Loopback variant
http://localhostnginx in Docker (port 80)
Allowed HTTP methods: GET, POST, PUT, PATCH, DELETE, OPTIONS. All request headers are permitted (*). The Authorization header is explicitly exposed in responses. Pre-flight responses are cached for 3600 seconds.
If you deploy the frontend to a different origin (for example a staging domain), add that origin to the allowedOriginPatterns list in SecurityConfig.java and rebuild the gateway image.

Circuit breaker (ms-pedidos)

The orders service (ms-pedidos) uses Resilience4j to protect calls to ms-inventario. The circuit breaker opens when too many calls fail, preventing a cascade failure from propagating to orders.
ParameterValueMeaning
sliding-window-size10Number of recent calls evaluated
failure-rate-threshold50%Opens the circuit when ≥50% of calls fail
wait-duration-in-open-state30sHow long the circuit stays open before half-opening
permitted-calls-in-half-open-state3Probe calls allowed while the circuit is half-open
The downstream URL for the inventory service is set via the property inventario.service.url=http://ms-inventario:8082 in ms-pedidos/application.properties.

Frontend configuration

The React frontend communicates with the backend through the API gateway. The gateway’s base URL is injected at build time via the VITE_API_URL environment variable.
VariableDefaultDescription
VITE_API_URLhttp://localhost:8080/apiBase URL prepended to every API request
In production, set VITE_API_URL to your public gateway URL and rebuild the frontend image with docker compose up -d --build frontend. The nginx server inside the frontend container handles SPA routing with try_files $uri $uri/ /index.html, so deep-linking to any React route works correctly. Static assets (JS, CSS, images) are served with a one-year Cache-Control: public, immutable header because Vite appends content hashes to all filenames.

Port assignments

ServiceInternal portHost port
api-gateway80808080
auth-service80818081
ms-inventario80828082
ms-pedidos80838083
ms-envios80848084
notification-service80858085
frontend (nginx)805173

Actuator endpoints

Spring Boot Actuator is enabled on the gateway and auth-service for health monitoring:
ServiceEndpointExposed metrics
api-gatewayhttp://localhost:8080/actuator/healthhealth, info
auth-servicehttp://localhost:8081/actuator/healthhealth, info, metrics
ms-inventariohttp://localhost:8082/actuator/healthhealth, info, metrics
ms-pedidoshttp://localhost:8083/actuator/healthhealth, info, metrics
ms-envioshttp://localhost:8084/actuator/healthhealth, info, metrics
Use the /actuator/health endpoint in your container orchestration platform’s liveness and readiness probes to ensure traffic is only sent to fully started service instances.