- πͺ Secure User Registration and Login
- π₯ User Profile Management
- π Token-based Authentication
- π Product Catalog Management & Search
- π Add, Update and Remove Products in Shopping Cart
- π Order Checkout, Shipping and Payment
- Clone this repository:
git clone https://github.com/Michael-Vol/ecommerce-api.git
-
Create a MySQL database and run this SQL script to create the data structure.
-
Add the following env variables to the application.properties file as follows:
spring.datasource.url={YOUR_DATABASE_URL}
spring.datasource.username={YOUR_DATABASE_USERNAME}
spring.datasource.password={YOUR_DATABASE_PASSWORD}
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
ecommerce.api.jwtSecret={YOUR_JWT_SECRET}
- Build and Run the Application:
./mvnw clean install
./mvnw spring-boot:run
Method | Endpoint | Description | Request Body |
---|---|---|---|
POST | api/v1/auth/register | Registers a new user | JSON |
POST | api/v1/auth/login | Authenticates a user | JSON |
POST | api/v1/auth/logout | Logs out a user |
Method | Endpoint | Description | Request Body |
---|---|---|---|
GET | api/v1/users/me | Gets the current user's profile |
Method | Endpoint | Description | Request Body |
---|---|---|---|
POST | /api/v1/products | Creates a new product | JSON |
GET | /api/v1/products | Gets all products | Params |
GET | /api/v1/products/{productId} | Gets a product by id | |
GET | /api/v1/products/search | Searches in product catalog | Params |
PATCH | /api/v1/products/{productId} | Updates a product by id | JSON |
DELETE | /api/v1/products/{productId} | Deletes a product by id |
Method | Endpoint | Description | Request Body |
---|---|---|---|
POST | /api/v1/carts/addToCart | Adds a product to cart | JSON |
GET | /api/v1/carts | Gets the user's cart info | |
PATCH | /api/v1/carts/updateQuantity | Updates an item's quantity | JSON |
DELETE | /api/v1/carts/removeFromCart | Removes an item from cart | JSON |
DELETE | /api/v1/carts/clearCart | Empties the user's cart | |
POST | /api/v1/carts/checkout | Creates an order from the cart items | JSON |
Method | Endpoint | Description | Request Body |
---|---|---|---|
GET | /api/v1/orders/{orderId} | Gets an order by id | |
GET | /api/v1/orders/{orderId}/status | Gets the status of an order by id | |
PATCH | /api/v1/orders/{orderId}/status | Updates an order's status |
{
"firstName": "John",
"lastName": "Appleseed",
"username": "john",
"email": "[email protected]",
"password": "password",
"address": "225 Brickyard Lane Racine, WI 53402"
}
{
"email": "[email protected]",
"password": "password"
}
{
"name": "Apple iPhone 12 Pro Max",
"description": "Apple iPhone 12 Pro Max 128GB Graphite",
"price": 1099.99,
"quantity": 10,
"category": "Electronics",
"brand": "Apple",
"image": "https://i.imgur.com/0oY8F0X.jpg"
}
Query Params:
- page
- size
- sortBy
- direction
Query Params:
- category
- minPrice
- maxPrice
- sortDirection
- sortBy
- page
- pageSize
{
"name": "Apple iPhone 11 Pro Max",
"description": "Apple iPhone 1 Pro Max 128GB Graphite",
"price": 899.99,
"quantity": 10
}
{
"productId": 1,
"quantity": 2
}
{
"productId": 1,
"quantity": 3
}
{
"productId": 1
}
{
"cartId": 6,
"shippingAddress": "169 Tallwood Drive Jackson, NJ 08527",
"billingAddress": "169 Tallwood Drive Jackson, NJ 08527",
"paymentMethod": "CREDIT_CARD"
}