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 to | Auth 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:
| Origin | Typical use case |
|---|
http://localhost:5173 | Vite dev server (npm run dev) |
http://localhost:3000 | Alternate local dev port |
http://127.0.0.1:5173 | Loopback variant |
http://localhost | nginx 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.
| Parameter | Value | Meaning |
|---|
sliding-window-size | 10 | Number of recent calls evaluated |
failure-rate-threshold | 50% | Opens the circuit when ≥50% of calls fail |
wait-duration-in-open-state | 30s | How long the circuit stays open before half-opening |
permitted-calls-in-half-open-state | 3 | Probe 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.
| Variable | Default | Description |
|---|
VITE_API_URL | http://localhost:8080/api | Base 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
| Service | Internal port | Host port |
|---|
api-gateway | 8080 | 8080 |
auth-service | 8081 | 8081 |
ms-inventario | 8082 | 8082 |
ms-pedidos | 8083 | 8083 |
ms-envios | 8084 | 8084 |
notification-service | 8085 | 8085 |
frontend (nginx) | 80 | 5173 |
Actuator endpoints
Spring Boot Actuator is enabled on the gateway and auth-service for health monitoring:
| Service | Endpoint | Exposed metrics |
|---|
api-gateway | http://localhost:8080/actuator/health | health, info |
auth-service | http://localhost:8081/actuator/health | health, info, metrics |
ms-inventario | http://localhost:8082/actuator/health | health, info, metrics |
ms-pedidos | http://localhost:8083/actuator/health | health, info, metrics |
ms-envios | http://localhost:8084/actuator/health | health, 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.