Thanks to visit codestin.com
Credit goes to github.com

Skip to content

๐Ÿฑ Java Spring Boot project for a Bento Recommender System โ€” explore backend engineering, database design, and API building with Docker & PostgreSQL.

License

Notifications You must be signed in to change notification settings

leopaul29/bento-recommender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

77 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿฑ Bento Recommender API

๐Ÿ“– Project Description / ใƒ—ใƒญใ‚ธใ‚งใ‚ฏใƒˆๆฆ‚่ฆ

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 ใ‚ขใƒ—ใƒชใ‚ฑใƒผใ‚ทใƒงใƒณใงใ™ใ€‚ใƒฆใƒผใ‚ถใƒผใฏ้ฃŸๆใ‚„ใ‚ฟใ‚ฐไป˜ใใฎๅผๅฝ“ใ‚’็™ป้Œฒใ—ใ€ๅฅฝใฟใƒปๅซŒใ„ใช้ฃŸๆใ‚’่จญๅฎšใ™ใ‚‹ใ“ใจใงใ€ๅ—œๅฅฝใซๅŸบใฅใ„ใŸใŠใ™ใ™ใ‚ใ‚’ๅ—ใ‘ๅ–ใ‚‹ใ“ใจใŒใงใใพใ™ใ€‚


๐ŸŽฏ Objective

  • 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

๐Ÿš€ Features

  • 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

๐Ÿ› ๏ธ Tech Stack

  • 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

๐Ÿ“š Learning Outcomes

By working on this project, you will:

  1. Understand Spring Boot project structure and dependency injection
  2. Learn CRUD implementation with Spring Data JPA
  3. Use DTOs and mappers (MapStruct) to separate persistence and presentation layers
  4. Integrate PostgreSQL with Docker
  5. Implement recommendation logic using filtering and predicates
  6. Write API tests with MockMvc and SpringBootTest
  7. Manage database initialization with SQL scripts and dummy data
  8. Use Postman or similar tools for API testing and debugging
  9. Handle environment variables with .env and properties

โœ… Good Practices in This Project

  • 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
  • .env is used to store secrets (never commit it)
  • application.properties uses variable substitution for flexibility
  • Docker ensures consistent DB state across environments

๐Ÿ“Œ Next Steps

  • 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

๐Ÿ“ก API Endpoints

Bento API

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

User Preferences API

Method Endpoint Description
POST /api/users/{id}/preferences Set user preferences

Recommendation API

Method Endpoint Description
GET /api/recommendations?userId=1 Get recommendations for a user

๐Ÿ“‚ Project Structure

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

๐Ÿ“ฆ Installation & Setup

Prerequisites

  • Java 17+
  • Maven 3.8+
  • Docker & Docker Compose installed

1. Clone the repository

git clone https://github.com/yourusername/bento-recommender.git
cd bento-recommender

2. Configure Environment Variables

Create a .env file at the root:

POSTGRES_USER=youruser
POSTGRES_PASSWORD=yourpassword
POSTGRES_DB=bento_db

3. Start PostgreSQL with Docker

docker compose --env-file .env up -d

4. Configure Spring Boot

Create 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

5. Run the Application

mvn clean install
mvn spring-boot:run

๐Ÿงช Running Tests

With Maven

mvn test

Example with MockMvc

mockMvc.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

Frontend screenshot

Small frontend with thymeleaf and tailwindcss cdn

bento-list-screenshot.jpg

Documentation

Documentation


๐Ÿ“„ License

MIT โ€“ free to use and modify for learning or production.

About

๐Ÿฑ Java Spring Boot project for a Bento Recommender System โ€” explore backend engineering, database design, and API building with Docker & PostgreSQL.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published