This is a backend REST API for e-commerce store.
The architecture includes several services connected to their own database. It has an API gateway which is the entry point for the users. All of them are registered to the Eureka server registry.
The API gateway sends the request to the different services based on the request made by the users.
The Communication between services takes place with the help Open Feign Library. I have used the Coreography SAGA Pattern to ensure data consistency.
-
Auth Services : Manages user registration and authentication. Provides endpoints for registering new users and generating JWT tokens upon successful authentication. It integrates with the AuthService to handle user creation and token generation securely
-
Product Services : A RESTful API for managing products, including CRUD operations, stock management, and order processing.
-
Customer Services : Handles customer and address management with features like retrieval, creation, updates, and validation through a RESTful API.
-
Cart Services : Manages customer carts and cart items, allowing retrieval, creation, updates, and deletion to ensure a smooth shopping experience through a RESTful API.
-
Order Services : Handles order and order item management with features like retrieval, creation, updates, and deletion. Implements the Saga pattern to ensure transactional consistency across services.
-
Payment Services : Handles payment processing and retrieval of payment details based on order ID. Ensures secure and reliable transactions.
-
Eureka Server Registry : Acts as a service discovery server that registers and manages all microservices. It enables dynamic service discovery, allowing clients to locate and interact with available services in the ecosystem.
-
API Gateway : Routes requests to appropriate services, applying security filters such as authentication and authorization. Ensures seamless communication between microservices by managing request routing and enforcing security protocols
-
Clone the Repository
Begin by cloning the repository to your local machine:git clone <repository_url> cd <repository_name>
-
Create Build Files for All Services Each service requires a build file (e.g., Dockerfile, build configuration). Ensure you have the necessary build files set up for each service in your project.
-
Navigate to the e-commerce-store Directory Once you've prepared the build files, navigate to the e-commerce-store directory:
cd Ecommerce-store
-
Run Docker Compose To build and start all services, run the following Docker Compose command:
docker-compose up --build
-
POST
/auth/register
Register a new user by providing user details (email, password). -
POST
/auth/token
Authenticate a user and generate a JWT token upon successful authentication with provided credentials (email, password). -
GET
/auth/validate
(Commented out in code)
Validate the provided JWT token (if enabled).
-
GET
/products
Retrieve a list of all products. -
GET
/products/hasproduct/{id}
Check if a product exists by its ID. -
GET
/products/{id}
Retrieve a specific product by its ID. -
POST
/products/reduceitemorder
Reduce the quantity of items ordered. -
POST
/products/restoreStock
Restore the stock for a product. -
POST
/products/add
Add a new product to the catalog. -
DELETE
/products/delete/{id}
Delete a product by its ID. -
POST
/products/update/{id}
Update the details of a product by its ID.
-
GET
/customers
Retrieve a list of all customers. -
GET
/customers/{id}
Retrieve a specific customer by its ID. -
GET
/customers/hascustomer/{id}
Check if a customer exists by their ID. -
POST
/customers/add
Add a new customer. -
POST
/customers/update/{id}
Update the details of a customer by their ID. -
POST
/address/add
Add a new address. -
GET
/address/{customerid}
Retrieve all addresses associated with a specific customer. -
DELETE
/address/deleteaddress
Delete a customer's address. -
POST
/address/updateaddress
Update an address for a customer.
-
GET
/cart
Retrieve all cart details. -
GET
/cart/allcarts
Retrieve all carts. -
GET
/cart/customer/{customerid}
Retrieve the cart associated with a specific customer. -
GET
/cart/cartdetails/{customerId}
Retrieve detailed cart info by customer ID. -
GET
/cart/cartitem/{id}
Retrieve a specific cart item by its ID. -
POST
/cart/addcart/{customerid}
Create a new cart for a customer. -
POST
/cart/addcartitem
Add a new item to the cart. -
DELETE
/cart/clearcart/{customerId}
Clear all items in a customer's cart. -
DELETE
/cart/deleteitem/{cartItemId}
Delete a specific item from the cart. -
POST
/cart/updatecartitem
Update the details of a cart item.
-
GET
/order/orders
Retrieve a list of all orders. -
GET
/order
Retrieve detailed information of all orders. -
GET
/order/order/{id}
Retrieve a specific order by its ID. -
POST
/order/add
Add a new order. -
DELETE
/order/deleteOrder/{orderId}
Delete a specific order by its ID. -
DELETE
/order/deleteOrderItem/{orderItemId}
Remove a specific item from an order. -
PUT
/order/updatestatus/delivered/{orderId}
Change the status of an order to "delivered." -
PUT
/order/updatequantity
Update the quantity of an item in an order.
-
POST
/payment/makepayment
Process a payment. -
POST
/payment/getpaymentinfo/{orderid}
Retrieve payment details for a specific order by its ID.