A REST API for an e-commerce platform built with Spring Boot. It handles user authentication, product catalog management, and order processing.
- User registration, login, logout, and token refresh using JWT
- Product CRUD operations and search
- Order creation and retrieval for authenticated users
- PostgreSQL persistence via Spring Data JPA
- Request validation and centralized exception handling
- Java with Spring Boot
- Spring Data JPA
- Spring Security with OAuth2 client support
- PostgreSQL
- Maven
- Lombok
The application code lives under api/:
controller- REST endpointsservice- business logicrepository- data accessmodel- JPA entitiesdto- request and response objectsexceptions- custom exceptions and global exception handling
POST /api/auth/register- register a new userPOST /api/auth/login- log in and receive tokensPOST /api/auth/refresh- refresh an access tokenPOST /api/auth/logout- log out and invalidate a refresh token
GET /api/products- list all productsGET /api/products/{productId}- get a product by idPOST /api/products- add a productPUT /api/products/{productId}- update a productDELETE /api/products/{productId}- delete a productGET /api/products/search?search=- search products
POST /api/orders- create an orderGET /api/orders- get the authenticated user's orders
- Java 17 or later
- Maven
- PostgreSQL
-
Clone the repository
-
Create a
.envfile inapi/with your database credentials -
Run the application:
cd api ./mvnw spring-boot:run
The API will start on http://localhost:8080.
cd api
./mvnw test