DriveMart is a Spring Boot application that provides REST APIs to manage cars, brands, colors, and engines. It demonstrates modern backend development practices using Spring Boot, JPA, Hibernate, and Swagger.
- CRUD Operations for:
- Car
- Brand
- Color
- Engine
- Relationships:
Many-to-One(Car โ Brand)One-to-Many(Brand โ Car)Many-to-Many(Car โ Color)
- Database Support:
- Works with MySQL, PostgreSQL, or H2 (for testing)
- Swagger Integration for API documentation
- Timestamps with
@CreationTimestampand@UpdateTimestamp
- Java: 17+
- Spring Boot: 3.x
- Spring Data JPA
- Hibernate
- H2 / MySQL Database
- Swagger (Springdoc OpenAPI)
- Maven for build automation
DriveMart/
โโโ src/main/java/com/sanjeeban/DriveMart/
โ โโโ controller/ # REST Controllers
โ โโโ service/ # Service Layer
โ โโโ repository/ # JPA Repositories
โ โโโ entity/ # JPA Entities (Car, Brand, Color, Engine)
โ โโโ DriveMartApplication.java
โโโ src/main/resources/
โ โโโ application.properties
โ โโโ data.sql # Initial data (optional)
โ โโโ schema.sql # Custom schema (optional)
โโโ pom.xml
- Java 17+
- Maven 3.8+
- MySQL (or use H2 in-memory DB)
-
Clone the repository:
git clone https://github.com//DriveMart.git cd DriveMart
-
Configure the database: In
src/main/resources/application.properties, update:properties spring.datasource.url=jdbc:mysql://localhost:3306/drivemart_db spring.datasource.username=root spring.datasource.password=yourpassword spring.jpa.hibernate.ddl-auto=update
-
Build and run the app:
mvn clean install mvn spring-boot:run
-
Access API Documentation: Open:
http://localhost:8080/swagger-ui.html
| Method | Endpoint | Description |
|---|---|---|
| GET | /cars |
Get all cars |
| POST | /cars |
Add a new car |
| GET | /brands |
Get all brands |
| POST | /brands |
Add a new brand |
| GET | /colors |
Get all colors |
| POST | /colors |
Add a new color |
| GET | /engines |
Get all engines |
| POST | /engines |
Add a new engine |
(Full API details available in Swagger UI)
Add this in application.properties for quick testing:
properties spring.datasource.url=jdbc:h2:mem:drivemart_db spring.datasource.driverClassName=org.h2.Driver spring.datasource.username=sa spring.datasource.password= spring.jpa.hibernate.ddl-auto=create spring.h2.console.enabled=true
Then access H2 console:
http://localhost:8080/h2-console
Developed by Sanjeeban Mukhopadhyay GitHub: @sanjeeban5644