A Spring Boot REST API for managing a smart grocery list with admin product approval, external food database integration, and user shopping lists.
Frontend Repository: smart-grocery-frontend
| Technology | Version |
|---|---|
| Java | 21 |
| Spring Boot | 3.5 |
| Spring Security | JWT (Access + Refresh Tokens) |
| Spring Data JPA | Hibernate |
| PostgreSQL | Latest (via Docker) |
| MapStruct | 1.5.5 |
| Lombok | Latest |
| SpringDoc OpenAPI | 2.8.6 |
| Maven | Wrapper included |
- JWT-based authentication with access & refresh token rotation
- Role-based access control (
ADMIN/USER) - First registered user is automatically assigned the
ADMINrole - Secure logout with server-side token revocation
- Password encryption with BCrypt
- Search external food products from Open Food Facts API by keyword
- Import products (single or bulk) into the application database as approved items
- Remove products via soft-delete (preserves data integrity)
- Dashboard analytics — total products, categories, users, recently approved items, and product distribution by category
- Browse paginated approved grocery items
- View detailed product information — calories, protein, carbs, fat, brand, estimated price, category, and image
- Search and filter products by name and/or category
- Personal shopping list — add items, update quantities, remove items, or clear the entire list
- Bulk import — admins can import multiple products in a single request
- Pagination on all list endpoints with sorting support
| Method | Endpoint | Access |
|---|---|---|
POST |
/api/auth/signup |
Public |
POST |
/api/auth/login |
Public |
POST |
/api/auth/refresh |
Public |
POST |
/api/auth/logout |
Authenticated |
| Method | Endpoint | Access |
|---|---|---|
GET |
/api/admin/products/dashboard |
ADMIN |
GET |
/api/admin/products/search?query=&page=&size= |
ADMIN |
GET |
/api/admin/products/approved?name=&category=&page=&size= |
ADMIN |
POST |
/api/admin/products/import |
ADMIN |
POST |
/api/admin/products/import/bulk |
ADMIN |
DELETE |
/api/admin/products/{id} |
ADMIN |
| Method | Endpoint | Access |
|---|---|---|
GET |
/api/products?page=&size= |
USER, ADMIN |
GET |
/api/products/{id} |
USER, ADMIN |
GET |
/api/products/categories |
USER, ADMIN |
GET |
/api/products/search?name=&category=&page=&size= |
USER, ADMIN |
| Method | Endpoint | Access |
|---|---|---|
GET |
/api/shopping-list |
USER |
POST |
/api/shopping-list/items |
USER |
PUT |
/api/shopping-list/items/{id} |
USER |
DELETE |
/api/shopping-list/items/{id} |
USER |
DELETE |
/api/shopping-list/items |
USER |
- Java 21 or higher
- Maven (or use the included Maven Wrapper)
- Docker & Docker Compose (for PostgreSQL)
Important: You must create the database before starting the application.
docker-compose up -dThis will start a PostgreSQL container on port 5433 with:
- Database:
smart_grocery - Username:
postgres - Password:
postgres
Very Important: Always run a clean compile before starting the application. This ensures MapStruct mappers and Lombok annotations are properly generated.
# Clean compile (REQUIRED — generates MapStruct mappers)
./mvnw clean compile
# Run tests to verify everything works
./mvnw clean verify./mvnw spring-boot:runThe API will be available at: http://localhost:8080
Once the application is running, you can access the interactive API documentation at:
- Swagger UI: http://localhost:8080/swagger-ui.html
- OpenAPI Spec: http://localhost:8080/v3/api-docs
The project includes unit tests for core services:
./mvnw clean verify| Test Class | Coverage |
|---|---|
AuthServiceTest |
Signup, login, token refresh, logout |
ProductServiceTest |
Product listing, search, filtering |
DashboardServiceTest |
Dashboard analytics aggregation |
ShoppingListServiceTest |
CRUD operations on shopping list |