Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

E-Commerce Backend

A robust E-Commerce backend REST API built with Java Spring Boot. This project enables product management, product search, and order processing capabilities.

🚀 Tech Stack

  • Language: Java 21
  • Framework: Spring Boot 4.0.2
  • Database: PostgreSQL
  • Persistence: Spring Data JPA
  • Tools: Lombok, Maven

✨ Features

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

📂 Project Structure

The source code is located in the SpringEcom/ directory.

Note: This repository contains the backend code only.

🛠️ Setup & Installation

Prerequisites

  • Java JDK 21 or later
  • Maven
  • PostgreSQL installed and running

Installation Steps

  1. Clone the repository and navigate to the project directory.
  2. Navigate to the backend source folder:
    cd SpringEcom
  3. 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
  4. Build the project:
    mvn clean install
  5. Run the application:
    mvn spring-boot:run
    The server will start at http://localhost:8080.

🧪 Testing with Postman

You can test the API endpoints using Postman or any other API client. Import the following endpoints to your collection.

1. Basic Test

  • Health Check / Greeting
    • Method: GET
    • URL: http://localhost:8080/hello

2. Product Management (/api)

  • Get All Products

    • Method: GET
    • URL: http://localhost:8080/api/products
  • Get Product by ID

    • Method: GET
    • URL: http://localhost:8080/api/product/{id}
    • Example: http://localhost:8080/api/product/1
  • 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.
  • Update Product

    • Method: PUT
    • URL: http://localhost:8080/api/product/{id}
    • Body type: form-data
    • Key-Value Pairs: Similar to "Add Product".
  • Delete Product

    • Method: DELETE
    • URL: http://localhost:8080/api/product/{id}
  • Get Product Image

    • Method: GET
    • URL: http://localhost:8080/api/product/{productId}/image
  • Search Products

    • Method: GET
    • URL: http://localhost:8080/api/products/search?keyword={keyword}
    • Example: http://localhost:8080/api/products/search?keyword=laptop

3. Order Management (/api)

  • 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"
      }
  • Get All Orders

    • Method: GET
    • URL: http://localhost:8080/api/orders

🤝 Contributing

Contributions are welcome! Please open an issue or submit a pull request.

📄 License

This project is licensed under the MIT License.

About

This is a Backend Only Project

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages