This is the backend for an eCommerce application built with the Ktor framework in Kotlin. It provides RESTful API endpoints to manage products (shoes), orders, reviews, carts, and wishlists, with secure JWT-based authentication for user-specific actions.
- Ktor: Framework for building backend applications.
- Kotlin: Primary language for backend development.
- PostgreSQL: Database for storing persistent data.
- JWT Authentication: Secure authentication for protected routes.
- AWS S3: Image storage for product images.
- Shoe Routes: CRUD and query operations for products (shoes).
- Order Routes: Order creation and retrieval for users.
- Review Routes: Manage reviews for products.
- Cart Routes: Manage shopping cart items.
- Wishlist Routes: Manage wishlist items.
Note: All endpoints require a JWT token in the Authorization
header (e.g., Authorization: Bearer <token>
), unless otherwise specified.
- Endpoint:
POST /shoes/add
- Description: Adds a new product to the inventory.
- Request Body:
{ "name": "Sneaker", "description": "High-quality sneaker", "price": 120.0, "brand": "BrandName", "size": 10, "color": "Red", "stock": 50, "imageUrl": "https://example.com/image.jpg" }
- Response: Returns the created shoe object or an error message.
- Endpoint:
GET /shoes/all
- Description: Retrieves all shoes with optional pagination.
- Query Parameters:
page
(optional): Page number.pageSize
(optional): Number of items per page.
- Response: List of shoes.
- Endpoint:
GET /shoes/{shoeId}
- Description: Retrieves a specific shoe by its ID.
- Path Parameter:
shoeId
- Shoe ID. - Response: Shoe details or error message.
- Endpoint:
DELETE /shoes/{shoeId}
- Description: Deletes a shoe by its ID.
- Path Parameter:
shoeId
- Shoe ID. - Response: Success message or error message.
- Endpoint:
POST /orders/add
- Description: Creates a new order for the authenticated user.
- Request Body: The order details (items and total amount).
- Response: Returns the created order object or an error message.
- Endpoint:
GET /orders/all
- Description: Retrieves all orders for the authenticated user.
- Response: List of orders.
- Endpoint:
GET /orders/active
- Description: Retrieves active orders for the authenticated user.
- Response: List of active orders.
- Endpoint:
GET /orders/completed
- Description: Retrieves completed orders for the authenticated user.
- Response: List of completed orders.
- Endpoint:
GET /orders/{id}
- Description: Retrieves a specific order by its ID.
- Path Parameter:
id
- Order ID. - Response: Order details or error message.
- Endpoint:
POST /reviews/add
- Description: Adds a new review for a product.
- Request Body: The review details (rating, comment, shoeId).
- Response: Returns the added review object or an error message.
- Endpoint:
GET /reviews/shoe/{shoeId}
- Description: Retrieves reviews for a specific shoe.
- Path Parameter:
shoeId
- Shoe ID. - Query Parameters:
page
(optional): Page number.pageSize
(optional): Number of items per page.rating
(optional): Filter reviews by rating.
- Response: List of reviews.
- Endpoint:
GET /reviews/shoe/featured/{shoeId}
- Description: Retrieves featured reviews for a specific shoe.
- Path Parameter:
shoeId
- Shoe ID. - Response: List of featured reviews.
Endpoint: DELETE /reviews/{reviewId}
- Description: Deletes a review by its ID.
- Path Parameter:
reviewId
- Review ID. - Response: Success message or error message.
- Endpoint:
GET /wishlist/my_wishlist
- Description: Retrieves the wishlist for the authenticated user.
- Response: List of items in the wishlist.
- Endpoint:
POST /wishlist/add/{shoeId}
- Description: Adds an item to the authenticated user's wishlist.
- Path Parameter:
shoeId
- Shoe ID. - Response: Success message or error message.
- Endpoint:
DELETE /wishlist/remove/{shoeId}
- Description: Removes an item from the authenticated user's wishlist.
- Path Parameter:
shoeId
- Shoe ID. - Response: Success message or error message.
- Endpoint:
DELETE /wishlist/clear
- Description: Clears all items from the authenticated user's wishlist.
- Response: Success message or error message.
- Endpoint:
GET /cart/my_cart
- Description: Retrieves the cart for the authenticated user.
- Response: List of items in the cart.
- Endpoint:
POST /cart/add/{shoeId}
- Description: Adds an item to the authenticated user's cart.
- Path Parameter:
shoeId
- Shoe ID. - Response: Success message or error message.
- Endpoint:
DELETE /cart/remove/{shoeId}
- Description: Removes an item from the authenticated user's cart.
- Path Parameter:
shoeId
- Shoe ID. - Response: Success message or error message.
- Endpoint:
DELETE /cart/clear
- Description: Clears all items from the authenticated user's cart.
- Response: Success message or error message.