EN: The Bento Recommender API is a Spring Boot application designed to manage Bento (Japanese lunch box) data, user preferences, and provide personalized meal recommendations. Users can register Bentos with their ingredients and tags, set their food preferences (likes/dislikes), and receive recommendations based on these preferences.
JP: Bento Recommender API ใฏใๅผๅฝใใผใฟใปใฆใผใถใผๅๅฅฝๆ ๅ ฑใ็ฎก็ใใๅๅฅใซๆ้ฉๅใใใใใใใๅผๅฝใๆไพใใ Spring Boot ใขใใชใฑใผใทใงใณใงใใใฆใผใถใผใฏ้ฃๆใใฟใฐไปใใฎๅผๅฝใ็ป้ฒใใๅฅฝใฟใปๅซใใช้ฃๆใ่จญๅฎใใใใจใงใๅๅฅฝใซๅบใฅใใใใใใใๅใๅใใใจใใงใใพใใ
- Build a fully functional REST API for managing bentos and related entities
- Implement recommendation logic based on user preferences
- Provide dummy dataset for testing search and recommendation features
- Ensure API follows clean architecture and best practices in Spring Boot
- Use PostgreSQL with Docker and Docker Compose to manage your dev environment
- CRUD for Bento: Create, read, update, and delete Bento records
- Ingredient & Tag Management: Store and manage reusable ingredients and tags
- User Preferences: Define liked tags and disliked ingredients for each user
- Recommendation Engine: Recommend Bentos based on user preferences
- Dummy Data Initialization: Pre-load the database with sample data for testing
- API Testing: Postman collection and MockMvc-based unit tests
- Java 17
- Spring Boot 3
- Spring Data JPA
- Maven
- Docker / Docker Compose
- MapStruct for DTO โ Entity mapping
- PostgreSQL (via Docker)
- Lombok for boilerplate reduction
- JUnit 5 / MockMvc / SpringBootTest for testing
- Postman for API testing
By working on this project, you will:
- Understand Spring Boot project structure and dependency injection
- Learn CRUD implementation with Spring Data JPA
- Use DTOs and mappers (MapStruct) to separate persistence and presentation layers
- Integrate PostgreSQL with Docker
- Implement recommendation logic using filtering and predicates
- Write API tests with MockMvc and SpringBootTest
- Manage database initialization with SQL scripts and dummy data
- Use Postman or similar tools for API testing and debugging
- Handle environment variables with
.envand properties
- Entity vs DTO separation โ Prevents overexposing internal models
- Service layer encapsulation โ All business logic isolated from controllers
- Mapper layer โ Clean transformation between entities and DTOs
- Validation annotations (
@NotNull,@Size,@Min) โ Ensure API contract consistency - ControllerAdvice for global error handling โ Centralized exception management
- Environment variables for DB credentials โ Security & flexibility
- Idempotent SQL initialization scripts โ Reusable and safe test datasets
- Japanese & English specs โ Supports bilingual development and documentation
- RESTful API design โ Predictable, clean, and standard endpoint naming
.envis used to store secrets (never commit it)application.propertiesuses variable substitution for flexibility- Docker ensures consistent DB state across environments
- Enhance Recommendation Algorithm
- Add scoring system for tags and ingredients
- Implement ranking and result limits
- Security
- Add Spring Security with JWT authentication
- Frontend
- Create a simple UI to visualize recommendations
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/bentos |
Get all bentos |
| GET | /api/bentos/{id} |
Get bento by ID |
| POST | /api/bentos |
Create a new bento |
| PUT | /api/bentos/{id} |
Update existing bento |
| DELETE | /api/bentos/{id} |
Delete a bento |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/users/{id}/preferences |
Set user preferences |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/recommendations?userId=1 |
Get recommendations for a user |
- More details with the page API Documentation
- See also with OpenAPI swagger at the following url http://localhost:8080/v3/api-docs
src/
โโ main/
โ โโ java/com/leopaul29/bento
โ โ โโ config # Config classes (DB init, OpenAPI=Swagger)
โ โ โโ controllers # REST API controllers
โ โ โโ dtos # Data Transfer Objects
โ โ โโ entities # JPA Entities
โ โ โโ exceptions # Global Exception Handler
โ โ โโ Init # Data initializer
โ โ โโ mappers # MapStruct mappers
โ โ โโ repositories # Spring Data repositories
โ โ โโ services # Service interfaces
โ โ โโ service/impl # Service implementations
โ โโ resources
โ โโ application.yml # Application configuration
โ โโ data.sql # Initial test data (optional)
โ โโ ...
โโ test/
โโ java/com/leopaul29/bento
โ โโ controllers # API tests with MockMvc
โ โโ services # Unit tests
โโโ Dockerfile
โโโ docker-compose.yml
โโโ README.md
- Java 17+
- Maven 3.8+
- Docker & Docker Compose installed
git clone https://github.com/yourusername/bento-recommender.git
cd bento-recommenderCreate a .env file at the root:
POSTGRES_USER=youruser
POSTGRES_PASSWORD=yourpassword
POSTGRES_DB=bento_dbdocker compose --env-file .env up -dCreate src/main/resources/application.properties:
spring.datasource.url=jdbc:postgresql://localhost:5432/bento_db
spring.datasource.username=${POSTGRES_USER}
spring.datasource.password=${POSTGRES_PASSWORD}
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
mvn clean install
mvn spring-boot:runmvn testmockMvc.perform(get("/api/bentos/1"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.name").value("Test Bento"));- **More details with the page Bento test
- With postman: check the collection test results with the page postman tests
Small frontend with thymeleaf and tailwindcss cdn
MIT โ free to use and modify for learning or production.