The Vehicle Management Service is a fully implemented microservice responsible for managing vehicle information for the TechTorque auto repair system. It allows authenticated customers to register, view, update, and delete their vehicles, as well as manage vehicle photos and view service history.
- Total Endpoints: 11 (100% implemented)
- Business Logic: Fully implemented
- Security: Role-based access control (RBAC) with JWT
- Data Seeder: Comprehensive seed data for development
- Photo Management: Full CRUD with file storage
- Documentation: OpenAPI/Swagger complete
- โ Register new vehicle with VIN validation
- โ List all customer vehicles
- โ Get vehicle details with service history
- โ Update vehicle information (mileage, color, license plate)
- โ Delete vehicle with cascading photo deletion
- โ Duplicate VIN detection
- โ Ownership verification on all operations
- โ Upload multiple vehicle photos
- โ List all photos for a vehicle
- โ Retrieve specific photo file
- โ Delete individual photos
- โ Delete all vehicle photos
- โ Image validation (type, size)
- โ Organized file storage by vehicle ID
- โ Service history endpoint (ready for inter-service communication)
- โ Prepared for WebClient integration with Project Service
- โ Graceful degradation when service unavailable
- โ JWT-based authentication via API Gateway
- โ Role-based access (CUSTOMER role required)
- โ Ownership verification on all operations
- โ VIN format validation (17 characters, no I, O, Q)
- โ Year validation (1900-2100)
- โ Mileage validation (non-negative)
- โ Image file type validation
- โ 6 sample vehicles across 3 customers
- โ Realistic data (Toyota, Honda, BMW, Mercedes, Nissan, Mazda)
- โ Valid VIN numbers
- โ Profile-based seeding (dev only)
- โ Duplicate prevention
- โ Shared constants for cross-service consistency
Register a new vehicle for the authenticated customer.
Request Body:
{
"make": "Toyota",
"model": "Camry",
"year": 2022,
"vin": "4T1B11HK5NU123456",
"licensePlate": "ABC-1234",
"color": "Silver",
"mileage": 15000
}Response: 201 Created
{
"message": "Vehicle added",
"vehicleId": "uuid-here"
}Validations:
- VIN: 17 characters, alphanumeric, no I/O/Q
- Year: 1900-2100
- Mileage: Non-negative
- All required fields must be present
List all vehicles for the authenticated customer.
Response: 200 OK
[
{
"id": "vehicle-uuid",
"make": "Toyota",
"model": "Camry",
"year": 2022,
"licensePlate": "ABC-1234",
"color": "Silver",
"mileage": 15000
}
]Get detailed information for a specific vehicle.
Response: 200 OK
{
"id": "vehicle-uuid",
"customerId": "customer-uuid",
"make": "Toyota",
"model": "Camry",
"year": 2022,
"vin": "4T1B11HK5NU123456",
"licensePlate": "ABC-1234",
"color": "Silver",
"mileage": 15000,
"createdAt": "2024-05-01T10:00:00",
"updatedAt": "2024-11-01T15:30:00"
}Update vehicle information (partial update supported).
Request Body:
{
"color": "Blue",
"mileage": 18000,
"licensePlate": "XYZ-9876"
}Response: 200 OK
{
"message": "Vehicle updated",
"vehicleId": "vehicle-uuid"
}Delete a vehicle and all associated photos.
Response: 200 OK
{
"message": "Vehicle removed",
"vehicleId": "vehicle-uuid"
}Upload photos for a vehicle (multipart/form-data).
Request: Multiple files with parameter name "files"
Response: 200 OK
{
"photoIds": ["photo-uuid-1", "photo-uuid-2"],
"urls": [
"/api/v1/vehicles/{vehicleId}/photos/filename1.jpg",
"/api/v1/vehicles/{vehicleId}/photos/filename2.jpg"
]
}Limits:
- Max file size: 10MB per file
- Max request size: 50MB
- Allowed types: image/* only
List all photos for a vehicle.
Response: 200 OK
[
{
"id": "photo-uuid",
"vehicleId": "vehicle-uuid",
"fileName": "vehicle_uuid_filename.jpg",
"fileUrl": "/api/v1/vehicles/{vehicleId}/photos/filename.jpg",
"fileSize": 1024000,
"contentType": "image/jpeg",
"uploadedAt": "2024-11-01T12:00:00"
}
]Retrieve a specific photo file.
Response: 200 OK (binary image data)
- Content-Type: image/jpeg (or detected type)
- Content-Disposition: inline
Delete a specific photo.
Response: 200 OK
{
"message": "Photo deleted successfully"
}Get service history for a vehicle (from Project Service).
Response: 200 OK
[
{
"serviceId": "service-uuid",
"date": "2024-10-15T09:00:00",
"type": "Oil Change",
"cost": 5000
}
]Note: Currently returns empty array. Will be populated when Project Service integration is complete.
All endpoints require authentication via JWT token in the Authorization header (Bearer token). The API Gateway validates the token and forwards the user ID in the X-User-Subject header.
Required Role: CUSTOMER
Ownership Verification: All operations verify that the vehicle belongs to the authenticated customer.
CREATE TABLE vehicles (
id VARCHAR(255) PRIMARY KEY,
customer_id VARCHAR(255) NOT NULL,
make VARCHAR(255) NOT NULL,
model VARCHAR(255) NOT NULL,
year INTEGER NOT NULL,
vin VARCHAR(17) UNIQUE NOT NULL,
license_plate VARCHAR(255) NOT NULL,
color VARCHAR(255),
mileage INTEGER,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL
);CREATE TABLE vehicle_photos (
id VARCHAR(255) PRIMARY KEY,
vehicle_id VARCHAR(255) NOT NULL,
file_name VARCHAR(255) NOT NULL,
file_path VARCHAR(1024) NOT NULL,
file_url VARCHAR(1024) NOT NULL,
file_size BIGINT NOT NULL,
content_type VARCHAR(255) NOT NULL,
uploaded_at TIMESTAMP NOT NULL,
FOREIGN KEY (vehicle_id) REFERENCES vehicles(id) ON DELETE CASCADE
);The service includes comprehensive seed data for development and testing:
- 2022 Toyota Camry (Silver, 15,000 km, VIN: 4T1B11HK5NU123456)
- 2021 Honda Accord (Black, 28,000 km, VIN: 1HGCV1F36LA123789)
- 2023 BMW X5 (White, 8,500 km, VIN: 5UXCR6C53N9A12345)
- 2020 Mercedes-Benz C 300 (Blue, 42,000 km, VIN: 55SWF4KB7LU123456)
- 2022 Nissan Altima (Red, 18,500 km, VIN: 1N4BL4BV5NC123456)
- 2019 Mazda CX-5 (Gray, 55,000 km, VIN: JM3KFBCM5K0123456)
Note: Seed data only loads in dev profile. Customer IDs are defined in SeedDataConstants.java and should match the Authentication Service seed data.
- Java 17+
- Maven 3.6+
- PostgreSQL database
- API Gateway (for JWT validation)
# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=techtorque_vehicles
DB_USER=techtorque
DB_PASS=techtorque123
DB_MODE=update
# Application Profile
SPRING_PROFILE=dev
# File Upload Directory
UPLOAD_DIR=uploads/vehicle-photoscd Vehicle_Service/vehicle-service
./mvnw spring-boot:rundocker-compose up vehicle-service- Service: http://localhost:8082
- Swagger UI: http://localhost:8082/swagger-ui/index.html
- Health Check: http://localhost:8082/actuator/health
- API Base: http://localhost:8080/api/v1/vehicles (via Gateway)
- Start the service
- Open http://localhost:8082/swagger-ui/index.html
- Authenticate using a JWT token from the Auth service
- Test each endpoint with sample data
- Register a new vehicle
- List all vehicles
- Get vehicle details
- Upload a photo
- List photos
- Update vehicle mileage
- Delete the vehicle
- โ VIN uniqueness enforced (409 Conflict on duplicate)
- โ Ownership verification (403 Forbidden if not owner)
- โ Vehicle not found (404 Not Found)
- โ Invalid VIN format (400 Bad Request)
- โ Non-image file upload (400 Bad Request)
- โ File size exceeded (413 Payload Too Large)
vehicle-service/
โโโ src/main/java/com/techtorque/vehicle_service/
โ โโโ config/
โ โ โโโ DatabasePreflightInitializer.java
โ โ โโโ GatewayHeaderFilter.java
โ โ โโโ SecurityConfig.java
โ โโโ constants/
โ โ โโโ SeedDataConstants.java
โ โโโ controller/
โ โ โโโ VehicleController.java
โ โโโ dto/
โ โ โโโ ApiResponseDto.java
โ โ โโโ PhotoUploadResponseDto.java
โ โ โโโ ServiceHistoryDto.java
โ โ โโโ VehicleListResponseDto.java
โ โ โโโ VehicleRequestDto.java
โ โ โโโ VehicleResponseDto.java
โ โ โโโ VehicleUpdateDto.java
โ โโโ entity/
โ โ โโโ Vehicle.java
โ โ โโโ VehiclePhoto.java
โ โโโ exception/
โ โ โโโ DuplicateVinException.java
โ โ โโโ ErrorResponse.java
โ โ โโโ GlobalExceptionHandler.java
โ โ โโโ PhotoUploadException.java
โ โ โโโ UnauthorizedVehicleAccessException.java
โ โ โโโ VehicleNotFoundException.java
โ โโโ mapper/
โ โ โโโ VehicleMapper.java
โ โโโ repository/
โ โ โโโ VehiclePhotoRepository.java
โ โ โโโ VehicleRepository.java
โ โโโ seeder/
โ โ โโโ VehicleDataSeeder.java
โ โโโ service/
โ โ โโโ PhotoStorageService.java
โ โ โโโ ServiceHistoryService.java
โ โ โโโ VehicleService.java
โ โโโ service/impl/
โ โโโ PhotoStorageServiceImpl.java
โ โโโ ServiceHistoryServiceImpl.java
โ โโโ VehicleServiceImpl.java
โโโ src/main/resources/
โโโ application.properties
- Service History: WebClient configuration prepared, awaiting Project Service availability
- Notifications: Vehicle-related events can trigger notifications when Notification Service is ready
- Analytics: Vehicle usage patterns, maintenance schedules
- Vehicle specifications (engine, transmission, fuel type)
- Maintenance schedule tracking
- Document storage (registration, insurance)
- Recall notifications
- Vehicle valuation tracking
- Service reminders based on mileage
- Cloud storage for photos (AWS S3, Azure Blob)
- Indexing: Indexes on
customer_id,vin, andvehicle_idcolumns - Caching: Consider Redis for frequently accessed vehicle data
- File Storage: Local filesystem for dev; cloud storage for production
- Pagination: Consider adding pagination for vehicle lists (large customers)
- Service History: Returns empty array until Project Service integration is complete
- Customer ID Coordination: Ensure
SeedDataConstants.javamatches Auth Service UUIDs - Photo Retrieval: Photos served from local filesystem; consider CDN for production
- No Pagination: Vehicle and photo lists return all records (add pagination for large datasets)
Assigned Team: Akith, Pramudi
Service Port: 8082
API Gateway Route: /api/v1/vehicles
For issues or questions, refer to the project documentation or contact the development team.
Last Updated: November 5, 2025
Implementation Status: โ
COMPLETE & PRODUCTION READY