A robust E-Commerce backend REST API built with Java Spring Boot. This project enables product management, product search, and order processing capabilities.
- Language: Java 21
- Framework: Spring Boot 4.0.2
- Database: PostgreSQL
- Persistence: Spring Data JPA
- Tools: Lombok, Maven
- Product Management: CRUD operations for products including image handling.
- Search: Full-text search capability for products.
- Order Processing: Place and retrieve orders.
- Media Support: Image upload and retrieval for products.
- RESTful Architecture: Follows standard REST principles.
The source code is located in the SpringEcom/ directory.
Note: This repository contains the backend code only.
- Java JDK 21 or later
- Maven
- PostgreSQL installed and running
- Clone the repository and navigate to the project directory.
- Navigate to the backend source folder:
cd SpringEcom - Configure your database connection:
- Open
src/main/resources/application.properties. - Update the following properties with your PostgreSQL credentials:
spring.datasource.url=jdbc:postgresql://localhost:5432/your_database_name spring.datasource.username=your_username spring.datasource.password=your_password
- Open
- Build the project:
mvn clean install
- Run the application:
The server will start at
mvn spring-boot:run
http://localhost:8080.
You can test the API endpoints using Postman or any other API client. Import the following endpoints to your collection.
- Health Check / Greeting
- Method:
GET - URL:
http://localhost:8080/hello
- Method:
-
Get All Products
- Method:
GET - URL:
http://localhost:8080/api/products
- Method:
-
Get Product by ID
- Method:
GET - URL:
http://localhost:8080/api/product/{id} - Example:
http://localhost:8080/api/product/1
- Method:
-
Add Product
- Method:
POST - URL:
http://localhost:8080/api/product - Body type:
form-data - Key-Value Pairs:
product: (Text/JSON) e.g.,{"name": "Laptop", "brand": "BrandX", "price": 1200, "category": "Electronics", "releaseDate": "2024-01-01", "productAvailable": true, "stockQuantity": 10}imageFile: (File) Select an image file to upload.
- Method:
-
Update Product
- Method:
PUT - URL:
http://localhost:8080/api/product/{id} - Body type:
form-data - Key-Value Pairs: Similar to "Add Product".
- Method:
-
Delete Product
- Method:
DELETE - URL:
http://localhost:8080/api/product/{id}
- Method:
-
Get Product Image
- Method:
GET - URL:
http://localhost:8080/api/product/{productId}/image
- Method:
-
Search Products
- Method:
GET - URL:
http://localhost:8080/api/products/search?keyword={keyword} - Example:
http://localhost:8080/api/products/search?keyword=laptop
- Method:
-
Place Order
- Method:
POST - URL:
http://localhost:8080/api/orders/place - Body type:
raw(JSON) - Example Body:
{ "items": [ { "productId": 1, "quantity": 2 }, { "productId": 2, "quantity": 1 } ], "totalPrice": 2500, "customerEmail": "user@example.com" }
- Method:
-
Get All Orders
- Method:
GET - URL:
http://localhost:8080/api/orders
- Method:
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.