Service Architecture
Auth Service
OAuth2/OIDC authorization server on port 9000
Gateway Service
API Gateway with session management on port 8080
Discovery Service
Eureka service registry on port 8761
User Service
User management microservice on port 8081
Client Service
Client management microservice on port 8082
Vehicle Service
Vehicle catalog with S3 integration on port 8083
Purchase-Sale Service
Transaction orchestration service on port 8084
Service Port Allocation
| Service | Port | Purpose | Database |
|---|---|---|---|
| sgivu-auth | 9000 | OAuth2 Authorization Server | PostgreSQL |
| sgivu-gateway | 8080 | API Gateway & Session Management | Redis |
| sgivu-discovery | 8761 | Eureka Service Registry | None |
| sgivu-user | 8081 | User Management | PostgreSQL |
| sgivu-client | 8082 | Client Management | PostgreSQL |
| sgivu-vehicle | 8083 | Vehicle Catalog & AWS S3 | PostgreSQL |
| sgivu-purchase-sale | 8084 | Transaction Orchestration | PostgreSQL |
Common Configuration Patterns
Eureka Service Discovery
Most services register with Eureka for service discovery:The
instance-id includes a random value to support multiple instances of the same service.Database Configuration
All data services use PostgreSQL with Flyway migrations:- Development
- Production
Service-to-Service Authentication
All microservices use a shared secret for internal API calls:This secret must be the same across all services to enable secure service-to-service communication.
Distributed Tracing
All services integrate with Zipkin for distributed tracing:Service Registry Pattern
Services maintain a map of other services they depend on:Actuator Endpoints
- Development
- Production
OpenAPI Documentation
Each service exposes its API documentation through the gateway:Environment Variables
Common to All Services
SERVICE_INTERNAL_SECRET_KEY- Shared secret for service-to-service authenticationEUREKA_URL- Eureka server URL (default:http://sgivu-discovery:8761/eureka)PORT- Service port (overrides default)
Profile-Specific
Each service requires database credentials for its profile: Development:DEV_{SERVICE}_DB_HOSTDEV_{SERVICE}_DB_PORTDEV_{SERVICE}_DB_NAMEDEV_{SERVICE}_DB_USERNAMEDEV_{SERVICE}_DB_PASSWORD
PROD_{SERVICE}_DB_HOSTPROD_{SERVICE}_DB_PORTPROD_{SERVICE}_DB_NAMEPROD_{SERVICE}_DB_USERNAMEPROD_{SERVICE}_DB_PASSWORD
Configuration Layering
Spring Cloud Config uses a three-tier configuration strategy:- Base configuration (
{service-name}.yml) - Common settings across all environments - Profile configuration (
{service-name}-{profile}.yml) - Environment-specific overrides - Environment variables - Runtime overrides
Configuration Resolution Order
Configuration Resolution Order
Spring Boot resolves configuration in this order (higher priority wins):
- Environment variables
- Profile-specific YAML (
-dev,-prod) - Base YAML file
- Application defaults
Service Dependencies
Next Steps
Auth Service
Configure OAuth2 authorization
Gateway Service
Set up API gateway and routing
Discovery Service
Configure service registry
Business Services
Configure microservices