A Spring Boot ecommerce backend application with authentication, products, cart, and order management.
Demo URL: https://ecommerce-frontend-one-lime.vercel.app/
Swagger UI: https://ecommerce-production-fa2b.up.railway.app/swagger-ui/index.html#/Products/getProductById
- User authentication with JWT
- Product management
- Shopping cart
- Order processing
- Role-based access control
- REST API endpoints
- Unit testing with JUnit and Mockito
- Java
- Spring Boot
- Spring Security
- JWT
- Maven
- PostgreSQL
- JUnit 5
- Mockito
git clone https://github.com/SamTeng22/ecommercecd ecommerceUpdate the application.properties file:
spring.datasource.url=YOUR_DATABASE_URL
spring.datasource.username=YOUR_USERNAME
spring.datasource.password=YOUR_PASSWORDmvn spring-boot:runmvn testMake sure Docker Desktop is running, then:
docker-compose up --buildThe app will be available at http://localhost:8080
API docs at http://localhost:8080/swagger-ui/index.html
To stop:
docker-compose downOnce running, visit the interactive API docs at: http://localhost:8080/swagger-ui/index.html
| Method | Endpoint | Description | Access |
|---|---|---|---|
| GET | /api/products | Get all products | Public |
| GET | /api/products/{id} | Get product by ID | Public |
| POST | /api/products | Create a product | Admin |
| PUT | /api/products/{id} | Update a product by ID | Admin |
| DELETE | /api/products/{id} | Delete a product by ID | Admin |
| GET | /api/orders | Get all of user's orders | Authenticated |
| GET | /api/orders/{orderId} | Get an order by ID | Authenticated |
| POST | /api/orders/checkout | Checkout of an order | Authenticated |
| PUT | /api/orders/{orderId}/status | Update an order's status | Admin |
| POST | /api/auth/login | Login | Public |
| POST | /api/auth/register | Register | Public |
| GET | /api/cart | Get cart contents | Authenticated |
| POST | /api/cart/items | Add item to cart | Authenticated |
| DELETE | /api/cart/items/{cartItemId} | Delete an item from the cart | Authenticated |
| GET | /api/categories | Get all categories | Public |
| GET | /api/categories/{id} | Get category by ID | Public |
| POST | /api/categories | Create a category | Admin |
| PUT | /api/categories/{id} | Update a category by ID | Admin |
| DELETE | /api/categories/{id} | Delete a category by ID | Admin |
Samantha Teng