Skip to content

πŸ›’ An Ecommerce API for handling the back-end logic of an e-shop. Provides support for user accounts, cart management, product handling, transactions and many more

License

Notifications You must be signed in to change notification settings

Michael-Vol/ecommerce-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

47 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Spring Boot Ecommerce API

A RESTful API for an e-commerce application built with Spring Boot.

πŸ“ƒ Features

  • πŸšͺ 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

πŸš€ Getting Started

  1. Clone this repository:
git clone https://github.com/Michael-Vol/ecommerce-api.git
  1. Create a MySQL database and run this SQL script to create the data structure.

  2. 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}
  1. Build and Run the Application:
./mvnw clean install
./mvnw spring-boot:run

🌐 API Endpoints

πŸ” Authentication

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

πŸ‘₯ User Profile Management

Method Endpoint Description Request Body
GET api/v1/users/me Gets the current user's profile

πŸ“‚ Product Catalog Management

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

πŸ›’ Shopping Cart Management

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

πŸ“„ Order Management

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

Sample JSON Request Bodies

{
  "firstName": "John",
  "lastName": "Appleseed",
  "username": "john",
  "email": "john@example.com",
  "password": "password",
  "address": "225 Brickyard Lane Racine, WI 53402"
}
{
  "email": "john@example.com",
  "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"
}

About

πŸ›’ An Ecommerce API for handling the back-end logic of an e-shop. Provides support for user accounts, cart management, product handling, transactions and many more

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages