sgivu-user) manages user accounts, profiles, and related operations in the SGIVU platform.
Service Overview
Port
8081
Database
PostgreSQL
Migration
Flyway
Role
User Management
Key Features
- User account management (CRUD operations)
- User profile data storage
- Integration with Auth Service for authentication
- Database migration with Flyway
- RESTful API with OpenAPI documentation
- Internal service authentication
Base Configuration
Server Settings
JPA Configuration
open-in-view: false ensures all database operations happen within transaction boundaries, preventing lazy loading exceptions.Flyway Migration
Flyway Configuration Details
Flyway Configuration Details
- enabled: true: Automatic migrations on startup
- locations: Migration scripts location
- baseline-on-migrate: Initialize versioning on existing databases
- baseline-version: 0: Start versioning from 0
- validate-on-migrate: true: Verify migration checksums
Database Configuration
- Development
- Production
- SQL logging enabled with formatting
- Seed data included (
classpath:db/seed) - Flyway clean allowed for testing
- Baseline on migrate for existing databases
Service Integration
Eureka Registration
The random value in the instance ID allows running multiple instances for load balancing.
Service Discovery Map
Internal Service Authentication
This shared secret authenticates internal API calls from other services (particularly Auth Service).
Observability
Actuator Endpoints
- Development
- Production
Distributed Tracing
Samples 10% of requests to balance observability with performance overhead.
Logging
API Documentation
- Production
Database Schema Management
Migration Strategy
- Development: Flyway applies migrations and seed data on startup
- Production: Flyway applies migrations only (no seed data)
Migration Locations
- Development
- Production
Example Migration Structure
Repeatable migrations (prefix
R__) run on every startup if their checksum changes.Required Environment Variables
All Environments
| Variable | Description | Example |
|---|---|---|
SERVICE_INTERNAL_SECRET_KEY | Shared secret for internal APIs | your-secret-key |
Development
| Variable | Description | Default |
|---|---|---|
DEV_USER_DB_HOST | Database host | host.docker.internal |
DEV_USER_DB_PORT | Database port | 5432 |
DEV_USER_DB_NAME | Database name | Required |
DEV_USER_DB_USERNAME | Database username | Required |
DEV_USER_DB_PASSWORD | Database password | Required |
Production
| Variable | Description |
|---|---|
PROD_USER_DB_HOST | Database host |
PROD_USER_DB_PORT | Database port |
PROD_USER_DB_NAME | Database name |
PROD_USER_DB_USERNAME | Database username |
PROD_USER_DB_PASSWORD | Database password |
OPENAPI_SERVER_URL | Public API docs URL |
Optional
| Variable | Description | Default |
|---|---|---|
PORT | Service port | 8081 |
EUREKA_URL | Eureka server URL | http://sgivu-discovery:8761/eureka |
SGIVU_AUTH_URL | Auth service URL | http://sgivu-auth:9000 |
FLYWAY_BASELINE_ON_MIGRATE | Baseline existing DB | false |
API Endpoints
Typical User Service endpoints (accessed via gateway):All endpoints require authentication via the gateway’s OAuth2 flow.
Security
OAuth2 Resource Server
The service validates JWT tokens from the Auth Service:Internal API Protection
Internal endpoints use the shared secret key:Performance Considerations
Database Connection Pooling
Spring Boot auto-configures HikariCP for connection pooling:Adjust pool sizes based on expected load and database resources.
JPA Optimization
Configuration Files
sgivu-user.yml- Base configurationsgivu-user-dev.yml- Development overridessgivu-user-prod.yml- Production overrides
Related Services
Auth Service
Authenticates users
Gateway
Routes user API requests
Purchase-Sale
Retrieves user data