Documentation Index
Fetch the complete documentation index at: https://mintlify.com/stevenrq/sgivu/llms.txt
Use this file to discover all available pages before exploring further.
Overview
SGIVU uses Docker Compose to orchestrate all microservices, databases, and supporting infrastructure. The compose setup is located ininfra/compose/sgivu-docker-compose/ and provides both development and production configurations.
Compose Files
docker-compose.dev.yml
Development configuration with:- All services with exposed ports for direct access
- Native profile for Config Server (loads from local filesystem)
- Volume mount for config repository:
../../../../sgivu-config-repo:/config-repo - Uses
.env.devenvironment file
docker-compose.yml
Production configuration with:- Minimal port exposure (only Gateway:8080 and Auth:9000)
- Git profile for Config Server (loads from GitHub repository)
- Uses
.envenvironment file extra_hostsconfiguration to resolve EC2 hostname internally
Quick Start
Development Stack
Production Stack
Stop Stack
Service Definitions
Infrastructure Services
sgivu-postgres
sgivu_auth_db: OAuth2 clients, authorizations, consentsgivu_user_db: Users, roles, permissionssgivu_client_db: Customer/client managementsgivu_vehicle_db: Vehicle inventorysgivu_purchase_sale_db: Transaction recordssgivu_ml_db: ML model artifacts and predictions
POSTGRES_HOST=sgivu-postgresPOSTGRES_DB=postgresPOSTGRES_USER=postgresPOSTGRES_PASSWORD=<your-password>
sgivu-mysql
MYSQL_HOST=sgivu-mysqlMYSQL_ROOT_PASSWORD=<your-password>MYSQL_DATABASE=sgivu_zipkin_dbMYSQL_USER=zipkinMYSQL_PASSWORD=<your-password>
MySQL is not used by any business services. All application data is stored in PostgreSQL.
sgivu-redis
sgivu-gateway stores HTTP sessions containing OAuth2 tokens in Redis, enabling horizontal scaling while maintaining session state.
Configuration:
- Session namespace:
spring:session:sgivu-gateway - Store type:
spring.session.store-type=redis - Dependencies:
spring-session-data-redis,spring-boot-starter-data-redis-reactive
REDIS_HOST=sgivu-redisREDIS_PORT=6379REDIS_PASSWORD=<your-password>(must match in both container and Gateway config)
Core Services
sgivu-config
- native: Loads configuration from local filesystem (development)
- git: Loads configuration from GitHub repository (production)
GET /{service}/{profile}: Retrieve configuration for a service- Example:
http://sgivu-config:8888/sgivu-gateway/dev
sgivu-discovery
GET /eureka/apps: List all registered services- Web UI:
http://sgivu-discovery:8761
- All services configure
eureka.client.service-url.defaultZone=http://sgivu-discovery:8761/eureka - Gateway uses
lb://service-namefor load-balanced routing
sgivu-zipkin
sgivu_zipkin_db)
Environment Variables:
STORAGE_TYPE=mysqlMYSQL_HOST=sgivu-mysqlMYSQL_DB=sgivu_zipkin_dbMYSQL_USER=zipkinMYSQL_PASS=<your-password>
http://localhost:9411
Business Services
sgivu-auth
- JWT issuance with RSA signing (keystore.jks)
- OAuth2 client registration
- User authentication via sgivu-user service
- Spring Session JDBC for authorization consent
/.well-known/openid-configuration: OIDC discovery/oauth2/authorize: Authorization endpoint/oauth2/token: Token endpoint/oauth2/jwks: JSON Web Key Set/login: Login page/actuator/health: Health check
sgivu_auth_db (PostgreSQL)
Critical Environment Variables:
ISSUER_URL: Must match JWTissclaimJWT_KEYSTORE_LOCATION=classpath:keystore.jksJWT_KEYSTORE_PASSWORDJWT_KEY_ALIAS=sgivu-jwtJWT_KEY_PASSWORDSGIVU_GATEWAY_SECRET: OAuth2 client secret (BCrypt hashed in DB)
sgivu-gateway
- OAuth2 Client (authorization_code + PKCE)
- Token relay to downstream services
- Circuit breaker with Resilience4j
- Session management (Redis-backed)
- Route rewriting for Swagger UI
/auth/session: Session info for SPA/v1/*: Business APIs (routes to microservices)/docs/{service}/*: Swagger UI proxy/actuator/health: Health check
GatewayRoutesConfig.java):
/v1/users/**→lb://sgivu-user/v1/persons/**→lb://sgivu-user/v1/clients/**→lb://sgivu-client/v1/vehicles/**→lb://sgivu-vehicle/v1/purchase-sales/**→lb://sgivu-purchase-sale/v1/ml/**→http://sgivu-ml:8000
sgivu-user
- User CRUD with person associations
- Role and permission management
- Internal endpoint for Auth Server credential validation
GET /api/v1/users: List usersPOST /api/v1/users: Create userGET /api/v1/internal/users/by-username/{username}: Internal (requiresX-Internal-Service-Key)/actuator/health: Health check
sgivu_user_db (PostgreSQL)
Migrations: V1__initial_schema.sql, seed data in R__seed_data.sql (creates steven admin user)
sgivu-client
- Person and company CRUD
- Address management
- Multi-criteria search
GET /api/v1/clients/persons: List person clientsGET /api/v1/clients/companies: List company clients/actuator/health: Health check
sgivu_client_db (PostgreSQL)
sgivu-vehicle
- Vehicle CRUD (make, model, year, VIN, etc.)
- Image upload to S3
- Pre-signed URL generation for image access
- Vehicle status tracking
GET /api/v1/vehicles: List vehiclesPOST /api/v1/vehicles: Create vehiclePOST /api/v1/vehicles/{id}/images: Upload images/actuator/health: Health check
sgivu_vehicle_db (PostgreSQL)
AWS Integration:
- S3 bucket:
AWS_VEHICLES_BUCKET=sgivu-vehicle-images - Region:
AWS_REGION=us-east-1 - CORS:
AWS_S3_ALLOWED_ORIGINS
sgivu-purchase-sale
- Purchase contract creation
- Sale contract creation
- Transaction history
- Integration with vehicle and client services
GET /api/v1/purchase-sales: List transactionsPOST /api/v1/purchase-sales/purchases: Create purchasePOST /api/v1/purchase-sales/sales: Create sale/actuator/health: Health check
sgivu_purchase_sale_db (PostgreSQL)
sgivu-ml
- Demand prediction by vehicle segment
- Model retraining with historical data
- Model metadata and versioning
- JWT validation via OIDC
POST /v1/ml/predict: Generate predictionPOST /v1/ml/predict-with-history: Prediction with historical contextPOST /v1/ml/retrain: Trigger model retrainingGET /v1/ml/models/latest: Model metadataGET /healthor/actuator/health: Health checkGET /docs: FastAPI OpenAPI docs
sgivu_ml_db (PostgreSQL)
Configuration (Pydantic Settings):
ENVIRONMENT=prodSGIVU_AUTH_DISCOVERY_URL=http://sgivu-auth:9000/.well-known/openid-configurationMODEL_DIR=modelsMODEL_NAME=demand_forecasterREQUEST_TIMEOUT_SECONDS=15
Environment Variables
Master Reference
Seeinfra/compose/sgivu-docker-compose/ENV-REFERENCE.md for complete documentation.
Critical Variables
Profile Selection
{service}-prod.yml or {service}-dev.yml from Config Server.
JWT Configuration
OAuth2 Client Secret
sgivu_auth_db. Changing after initial setup requires deleting client registration.
Internal Service Communication
X-Internal-Service-Key header.
Redis Configuration
REDIS_PASSWORD must match in both:
- Redis container
--requirepasscommand - Gateway
spring.data.redis.password
Frontend URLs
- CORS configuration in Auth and Gateway
- OAuth2 redirect URIs
- Post-logout redirect URIs
AWS Configuration
Database Configuration
PostgreSQL (shared instance):Management Scripts
run.bash
Unified script to launch the stack:rebuild-service.bash
Rebuild and restart a single service without affecting others:- Builds/pulls latest image
- Publishes image (if applicable)
- Recreates only that container
build-and-push-images.bash
Build and publish all service images:- Traverses all services in
apps/backend/,apps/frontend/,apps/ml/ - Invokes
build-image.bashfor each service - Pushes to Docker Hub (
stevenrq/*namespace)
Networking
Bridge Network
sgivu-network. Services reference each other by container name (e.g., http://sgivu-auth:9000).
Extra Hosts (Production)
In production, services need to reach the EC2 hostname (for OAuth2 flows through Nginx):In development, this is not needed. Services communicate directly via Docker network.
Volume Management
Persistent Volumes
Backup Volumes
Clean Volumes
Troubleshooting
Service Dependency Issues
Problem: Services fail to start due to missing dependencies Solution: Verify startup order withdepends_on. Wait for Config and Discovery before starting other services:
Config Validation
Port Already Allocated
Variable Substitution
Problem: Variables not replaced (show as${VAR_NAME})
Solution: Ensure .env file is in same directory as docker-compose.yml and contains all required variables:
Next Steps
- Deployment Architecture: Overall infrastructure design
- Nginx Configuration: Reverse proxy setup
- Monitoring: Health checks and observability
- Environment Reference: Complete variable documentation