Dev-Dhruba/DriveMart

A Spring Boot application for a Car Dealership.

โ˜… 0Forks 0HTMLGitHub โ†—Compare

README

๐Ÿš— DriveMart

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.


โœ… Features

  • 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 @CreationTimestamp and @UpdateTimestamp

๐Ÿ›  Tech Stack

  • Java: 17+
  • Spring Boot: 3.x
  • Spring Data JPA
  • Hibernate
  • H2 / MySQL Database
  • Swagger (Springdoc OpenAPI)
  • Maven for build automation

๐Ÿ“‚ Project Structure


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


โš™๏ธ Getting Started

โœ… Prerequisites

  • Java 17+
  • Maven 3.8+
  • MySQL (or use H2 in-memory DB)

โœ… Steps to Run

  1. Clone the repository:

    git clone https://github.com//DriveMart.git cd DriveMart

  2. 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

  3. Build and run the app:

    mvn clean install mvn spring-boot:run

  4. Access API Documentation: Open:

    http://localhost:8080/swagger-ui.html
    

๐Ÿ“ฆ API Endpoints

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)


๐Ÿงช Running with H2 (In-memory)

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

๐Ÿ”— Connect

Developed by Sanjeeban Mukhopadhyay GitHub: @sanjeeban5644

Contributors

sanjeeban5644

Issues