A Spring Boot REST API application for managing automotive dealers, vehicles, and payment processing.
- Dealer Management: Full CRUD operations for managing dealers with subscription types (BASIC/PREMIUM)
- Vehicle Management: CRUD operations for vehicles with dealer association
- Premium Filtering: Special endpoint to fetch vehicles belonging only to PREMIUM dealers
- Payment Processing: Simulated payment gateway with automatic status updates
- JWT Authentication: Secure payment endpoints with JWT token-based authentication
- API Documentation: Swagger UI for interactive API testing
- PostgreSQL Database: Persistent data storage with JPA/Hibernate
- Java 17 or higher
- Maven 3.6+
- Docker and Docker Compose (for PostgreSQL)
- Postman (optional, for API testing)
docker-compose up -d
This will start PostgreSQL on port 5432 with:
- Database:
dealerdb
- Username:
postgres
- Password:
password
mvn clean install
mvn spring-boot:run
The application will start on http://localhost:8080
Access Swagger UI at: http://localhost:8080/swagger-ui.html
Endpoint: POST /api/auth/login
Request Body:
{
"username": "admin",
"password": "admin123"
}
Response:
{
"token": "eyJhbGciOiJIUzI1NiJ9...",
"type": "Bearer",
"username": "admin"
}
Use this token in the Authorization
header for secured endpoints:
Authorization: Bearer <your-token>
GET /api/dealers
- Get all dealersGET /api/dealers/{id}
- Get dealer by IDPOST /api/dealers
- Create new dealerPUT /api/dealers/{id}
- Update dealerDELETE /api/dealers/{id}
- Delete dealer
GET /api/vehicles
- Get all vehiclesGET /api/vehicles/{id}
- Get vehicle by IDGET /api/vehicles/dealer/{dealerId}
- Get vehicles by dealerGET /api/vehicles/premium
- Get all vehicles of PREMIUM dealersPOST /api/vehicles
- Create new vehiclePUT /api/vehicles/{id}
- Update vehicleDELETE /api/vehicles/{id}
- Delete vehicle
POST /api/payment/initiate
- Initiate payment (auto-updates to SUCCESS after 5 seconds)GET /api/payment/{id}
- Get payment by IDGET /api/payment
- Get all paymentsGET /api/payment/dealer/{dealerId}
- Get payments by dealer
curl -X POST http://localhost:8080/api/dealers \
-H "Content-Type: application/json" \
-d '{
"name": "Premium Auto Dealer",
"email": "premium@dealer.com",
"subscriptionType": "PREMIUM"
}'
curl -X POST http://localhost:8080/api/vehicles \
-H "Content-Type: application/json" \
-d '{
"dealerId": 1,
"model": "Toyota Camry 2024",
"price": 35000.00,
"status": "AVAILABLE"
}'
curl -X POST http://localhost:8080/api/payment/initiate \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your-jwt-token>" \
-d '{
"dealerId": 1,
"amount": 5000.00,
"method": "CARD"
}'
- Client sends payment request to
/api/payment/initiate
- System creates payment record with status
PENDING
- Response is sent immediately to client
- After 5 seconds, system automatically updates status to
SUCCESS
- Client can check payment status using GET endpoint
src/main/java/com/dealersautocenter/
├── controller/ # REST API endpoints
├── service/ # Business logic
├── repository/ # Data access layer
├── entity/ # JPA entities
├── dto/ # Data transfer objects
├── config/ # Configuration classes
├── security/ # JWT security components
└── exception/ # Exception handling
src/main/resources/
├── application.yml # Application configuration
- Navigate to
http://localhost:8080/swagger-ui.html
- For secured endpoints, click "Authorize" and enter JWT token
- Test endpoints directly from the browser
Import the included Postman collection for pre-configured requests.
- Spring Boot 3.2.0
- Spring Security with JWT
- Spring Data JPA
- PostgreSQL
- Swagger/OpenAPI 3.0
- Docker & Docker Compose
- Maven
- GitHub Repository: [Your Repository URL]
- Deployment: [Your Deployment URL]
- Email: myreport@dealersautocenter.com
- Subject: Backend Task / [Your Name]