Variate JDBC API is a Spring Boot-based e-commerce backend application that provides a RESTful API for managing categories, products, orders, order items, payments, and reviews. The application integrates with PostgreSQL as its primary database and supports JWT-based authentication for secure access.
- Category Management: Create, read, update, patch, and delete product categories.
- Product Management: Handle products under different categories, including information such as price, description, and stock availability.
- Order Management: Create, update, and manage customer orders.
- Order Item Management: Handle individual items within customer orders.
- Payment Management: Manage payment details related to customer orders.
- Review Management: Customers can add, update, and manage reviews for products.
- JWT Authentication: Secure API access using JSON Web Tokens (JWT).
- Swagger Documentation: Explore and interact with the API using Swagger UI.
- Java 22
- Spring Boot 3.3.3
- JDBC for direct database access and SQL queries
- Spring Security with JWT for authentication and authorization
- PostgreSQL as the primary database
- H2 for in-memory testing
- ModelMapper for DTO conversions
- Swagger/OpenAPI for API documentation
- Maven for dependency management and build automation
This project uses PostgreSQL as the database. The default configuration assumes a database named variatespring
. Ensure PostgreSQL is installed and running in your local environment, and update the credentials in the application.properties
file as needed.
Example application.properties
configuration:
spring.datasource.url=jdbc:postgresql://localhost:5432/variatespring
spring.datasource.username=yourUsername
spring.datasource.password=yourPassword
POST /api/categories
: Create a new categoryGET /api/categories/{id}
: Retrieve a category by IDGET /api/categories
: List all categoriesPUT /api/categories/{id}
: Update a category by IDPATCH /api/categories/{id}
: Partially update a categoryDELETE /api/categories/{id}
: Delete a category
POST /api/products
: Create a new productGET /api/products/{id}
: Retrieve a product by IDGET /api/products
: List all productsPUT /api/products/{id}
: Update a productPATCH /api/products/{id}
: Partially update a productDELETE /api/products/{id}
: Delete a product
POST /api/orders
: Create a new orderGET /api/orders/{id}
: Retrieve an order by IDGET /api/orders
: List all ordersPUT /api/orders/{id}
: Update an orderPATCH /api/orders/{id}
: Partially update an orderDELETE /api/orders/{id}
: Delete an order
POST /api/order-items
: Create a new order itemGET /api/order-items/{id}
: Retrieve an order item by IDGET /api/order-items
: List all order itemsPUT /api/order-items/{id}
: Update an order itemPATCH /api/order-items/{id}
: Partially update an order itemDELETE /api/order-items/{id}
: Delete an order item
POST /api/payments
: Create a new paymentGET /api/payments/{id}
: Retrieve a payment by IDGET /api/payments
: List all paymentsPUT /api/payments/{id}
: Update a paymentPATCH /api/payments/{id}
: Partially update a paymentDELETE /api/payments/{id}
: Delete a payment
POST /api/reviews
: Create a new reviewGET /api/reviews/{id}
: Retrieve a review by IDGET /api/reviews
: List all reviewsPUT /api/reviews/{id}
: Update a reviewPATCH /api/reviews/{id}
: Partially update a reviewDELETE /api/reviews/{id}
: Delete a review
JWT-based authentication is used for securing the API. Publicly accessible endpoints include:
/api/auth/login
/api/auth/register
/swagger-ui/**
/v3/api-docs/**
All other endpoints require a valid JWT token to access.
Explore the API using Swagger UI. You can access the interactive API documentation via the following links:
- Swagger UI:
http://localhost:8080/swagger-ui/index.html
- OpenAPI Docs:
http://localhost:8080/v3/api-docs
To run the application locally:
-
Clone the repository:
git clone https://github.com/7irelo/variate-jdbc-api.git
-
Navigate to the project directory:
cd variate-jdbc-api
-
Configure your PostgreSQL database credentials in
application.properties
. -
Run the application using Maven:
./mvnw spring-boot:run
For local development, the project utilizes Maven for managing dependencies. You can take advantage of tools like spring-boot-devtools
for live reloading during development.
spring-boot-starter-web
: Provides RESTful web servicesspring-boot-starter-jdbc
: For database access using JDBCspring-boot-starter-security
: To handle security featurespostgresql
: PostgreSQL JDBC Drivermodelmapper
: For mapping entities to DTOs and vice versajjwt
: For JWT-based authenticationspringdoc-openapi-ui
: For auto-generated Swagger documentation
We welcome contributions to improve the project! To contribute:
- Fork the repository.
- Create your feature branch:
git checkout -b feature/new-feature
. - Commit your changes:
git commit -m 'Add a new feature'
. - Push to the branch:
git push origin feature/new-feature
. - Open a pull request and provide a description of your changes.
This project is licensed under the MIT License.