E-Commerce Backend API
Spring Boot | MySQL | JWT Authentication | Stripe Sandbox | Swagger | Postman Tested
This is a backend-only e-commerce REST API built using Spring Boot, MySQL, JWT authentication, and Stripe sandbox for payments. It includes APIs for user authentication, product management, cart, orders, reviews, ratings, and payments. All endpoints are secured with JWT and fully documented via Swagger UI.
--- Features --- JWT Authentication & Security
Signup & Signin with JWT
Role-based access (User & Admin)
Password encryption via Spring Security
-- Product Management (Admin Only)
Create, update, delete, and fetch products
Get all products or fetch by ID
-- Cart & Orders
Add or remove products from the cart
Place orders & track order status
Admin can manage, confirm, cancel, or ship orders
-- Ratings & Reviews
Users can post reviews and ratings for products
Fetch ratings & reviews per product
--- Stripe Payment Integration
Integrated Stripe Sandbox API
Payment success & failure tracking
Order payment flow managed securely
----Swagger UI for API Testing
Fully documented REST APIs
Interactive testing interface for developers
-- Tech Stack Technology Purpose Java 17+ Core backend language Spring Boot REST API framework Spring Security + JWT Authentication & authorization MySQL Relational database Hibernate / JPA ORM for database operations Stripe Sandbox Payment gateway integration Swagger API documentation Postman API testing Maven Dependency management
-- API Documentation (Swagger)
After running the project, open Swagger UI: http://localhost:5454/swagger-ui/index.html
OpenAPI JSON docs: http://localhost:5454/v3/api-docs
API Endpoints
- Auth Controller
Method Endpoint Description
POST /auth/signup Register a new user
POST /auth/signin Login & get JWT token
- User Controller
Method Endpoint Description
GET /api/users/profile Fetch user profile (JWT required)
- Product Controller
Method Endpoint Description
GET /api/products Get all products
GET /api/products/id/{id} Get product by ID
- Admin Product Controller (JWT - Admin Only)
Method Endpoint Description
POST /api/admin/products/creates Create a product
POST /api/admin/products/ Add product (alternate)
PUT /api/admin/products/{id}/update Update product
GET /api/admin/products/all Get all products
DELETE /api/admin/products/{id}/delete Delete product
- Cart Controller
Method Endpoint Description
PUT /api/cart/add Add product to cart (JWT required)
GET /api/cart/ Get user’s cart (JWT required)
- Cart Item Controller
Method Endpoint Description
GET /api/cart/item/{id} Get specific cart item
PUT /api/cart/item/{id} Update cart item quantity
DELETE /api/cart/item/{id} Remove cart item
- Order Controller
Method Endpoint Description
POST /api/orders/ Place a new order
GET /api/orders/{id} Get order by ID
GET /api/orders/user Get all orders of logged-in user
- Admin Order Controller (JWT - Admin Only)
Method Endpoint Description
PUT /api/admin/orders/{id}/ship Mark order as shipped
PUT /api/admin/orders/{id}/deliver Mark order as delivered
PUT /api/admin/orders/{id}/confirmed Confirm order
PUT /api/admin/orders/{id}/cancel Cancel order
GET /api/admin/orders/ Get all orders
DELETE /api/admin/orders/{id}/delete Delete an order
- Review Controller
Method Endpoint Description
POST /api/reviews/create Create a review
GET /api/reviews/product/{id} Get reviews for a product
- Rating Controller
Method Endpoint Description
POST /api/ratings/create Create rating for product
GET /api/ratings/product/{id} Get ratings for product
- Payment Controller (Stripe Sandbox)
Method Endpoint Description
POST /api/payments/{orderId} Initiate Stripe payment
GET /api/payments/success Payment success callback
GET /api/payments/failed Payment failure callback
-- Stripe Test Cards
Card Number Expiry CVC Result
4242 4242 4242 4242 12/34 123 --- Payment Successful
4000 0000 0000 9995 12/34 123 -- 3D Secure Required
4000 0000 0000 0002 12/34 123 -- Payment Declined