sgivu-vehicle) manages the vehicle catalog, including vehicle data, images, and media storage using AWS S3.
Service Overview
Port
8083
Database
PostgreSQL
Storage
AWS S3
Role
Vehicle Catalog
Key Features
- Vehicle catalog management (CRUD operations)
- Image and media storage with AWS S3
- Multipart file upload support (up to 100MB)
- Database migration with Flyway
- RESTful API with OpenAPI documentation
- Internal service authentication
- CORS configuration for frontend access
Base Configuration
Server Settings
JPA Configuration
Disabling open-in-view enforces explicit transaction boundaries and prevents lazy loading issues.
File Upload Configuration
Multipart Settings
Upload Limits
Upload Limits
- max-file-size: 10MB: Individual file size limit
- max-request-size: 100MB: Total request size (supports multiple files)
- Allows batch upload of vehicle images
- Prevents memory exhaustion from large uploads
Local Storage Destination
This local folder is used for temporary storage or development. Production uses S3 exclusively.
AWS S3 Configuration
S3 Settings
AWS Configuration Details
AWS Configuration Details
- vehicles-bucket: S3 bucket name for vehicle images
- allowed-origins: CORS origins for S3 pre-signed URLs
- access.key: AWS access key ID
- secret.key: AWS secret access key
- region: AWS region (e.g., us-east-1, eu-west-1)
S3 Bucket Policy
Your S3 bucket should have:- Public read access for vehicle images (or use pre-signed URLs)
- CORS configuration matching
allowed-origins - Lifecycle policies for managing old images
Example S3 CORS Configuration
Database Configuration
Flyway Migration
- Development
- Production
Service Integration
Eureka Registration
Service Discovery Map
Internal Service Authentication
The Purchase-Sale Service uses this secret to query vehicle data.
Observability
Actuator Endpoints
- Development
- Production
Distributed Tracing
Logging
AWS SDK Logging
AWS SDK Logging
The AWS SDK logger is set to
info level to:- Show important S3 operations
- Avoid verbose DEBUG logs
- Maintain visibility into AWS API calls
API Documentation
- Production
Required Environment Variables
All Environments
| Variable | Description | Example |
|---|---|---|
SERVICE_INTERNAL_SECRET_KEY | Shared secret for internal APIs | your-secret-key |
AWS_VEHICLES_BUCKET | S3 bucket name | sgivu-vehicles |
AWS_ACCESS_KEY | AWS access key ID | AKIAIOSFODNN7EXAMPLE |
AWS_SECRET_KEY | AWS secret access key | wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY |
AWS_REGION | AWS region | us-east-1 |
Development
| Variable | Description | Default |
|---|---|---|
DEV_VEHICLE_DB_HOST | Database host | host.docker.internal |
DEV_VEHICLE_DB_PORT | Database port | 5432 |
DEV_VEHICLE_DB_NAME | Database name | Required |
DEV_VEHICLE_DB_USERNAME | Database username | Required |
DEV_VEHICLE_DB_PASSWORD | Database password | Required |
Production
| Variable | Description |
|---|---|
PROD_VEHICLE_DB_HOST | Database host |
PROD_VEHICLE_DB_PORT | Database port |
PROD_VEHICLE_DB_NAME | Database name |
PROD_VEHICLE_DB_USERNAME | Database username |
PROD_VEHICLE_DB_PASSWORD | Database password |
OPENAPI_SERVER_URL | Public API docs URL |
Optional
| Variable | Description | Default |
|---|---|---|
PORT | Service port | 8083 |
EUREKA_URL | Eureka server URL | http://sgivu-discovery:8761/eureka |
AWS_S3_ALLOWED_ORIGINS | CORS origins | http://localhost:4200,https://localhost:4200 |
API Endpoints
Typical Vehicle Service endpoints:All endpoints require authentication through the gateway.
Vehicle Data Model
Typical vehicle entity includes:- Basic info (make, model, year, VIN)
- Specifications (engine, transmission, color)
- Pricing and availability
- Image URLs (stored in S3)
- Created/updated timestamps
S3 Integration Patterns
Upload Flow
- Client uploads images via POST
/api/vehicles/{id}/images - Service receives multipart file
- Service uploads to S3 with unique key
- S3 URL stored in database
- Response includes image URL
Pre-signed URLs
For secure direct uploads:Image Deletion
When deleting a vehicle or image:- Delete database record
- Delete S3 object
- Handle failures gracefully (eventual consistency)
Consider implementing soft deletes and periodic cleanup jobs for orphaned S3 objects.
Security Considerations
S3 Bucket Security
- Use least privilege IAM policies
- Enable S3 bucket versioning
- Configure server-side encryption (SSE-S3 or SSE-KMS)
- Enable access logging
- Block public access unless necessary
File Upload Security
- Validate file types (only allow images)
- Scan for malware
- Generate unique file names (prevent overwrite)
- Limit file sizes
Performance Optimization
S3 Performance
- Use CloudFront CDN for image delivery
- Implement caching strategies
- Compress images before upload
- Use S3 Transfer Acceleration for large files
Database Performance
- Index search columns (make, model, year)
- Use pagination for list endpoints
- Cache frequently accessed vehicles
Configuration Files
sgivu-vehicle.yml- Base configurationsgivu-vehicle-dev.yml- Development overridessgivu-vehicle-prod.yml- Production overrides
Related Services
Purchase-Sale
Retrieves vehicle data
Auth Service
Token validation
Gateway
API routing