Foodbox is a Spring Boot application designed to make it easy for employees to check the daily lunch menu. The lunch vendor posts the menu on their website as HTML, and this project automates the process of crawling and sharing that information with everyone. The key features include:
- Web Crawling: Fetching the daily menu from the food vendor's website using JSoup HTML parsing
- Data Structuring: Analyzing and organizing the menu for each date into a structured format
- REST API: Providing HTTP endpoints to access menu information
- Slack Integration: Sending the lunch menu via a Slack bot at the beginning of each workday
- Automatic Scheduling: Daily notifications to ensure everyone knows what's for lunch
The goal is to ensure everyone has quick and easy access to the lunch menu, without needing to search for it manually.
- Backend: Spring Boot 3.3.5 (Java 21)
- Web Crawling: JSoup 1.15.3
- Database: File-based storage with Spring Data
- Messaging: Slack API integration
- Testing: JUnit 5, Mockito, AssertJ
- Build Tool: Gradle
src/
βββ main/java/shanepark/foodbox/
β βββ FoodboxApplication.java # Main application entry point
β βββ api/
β β βββ controller/ # REST API controllers
β β βββ domain/ # Domain entities (Menu, MenuResponse, etc.)
β β βββ service/ # Business logic services
β β βββ repository/ # Data access layer
β β βββ config/ # Configuration classes
β β βββ exception/ # Custom exceptions
β βββ crawl/
β β βββ MenuCrawler.java # Web crawling logic
β β βββ CrawlConfig.java # Crawling configuration
β βββ slack/
β βββ controller/ # Slack webhook controllers
β βββ service/ # Slack notification services
β βββ domain/ # Slack-related data structures
βββ test/
βββ resources/
β βββ sample-menu-page.html # Test HTML samples
βββ java/shanepark/foodbox/
βββ crawl/
βββ MenuCrawlerTest.java # Comprehensive crawler tests
- Purpose: Crawls menu data from the vendor's website
- Technology: JSoup for HTML parsing
- Features:
- Robust error handling with Optional-based parsing
- Configurable CSS selectors
- Date extraction and validation
- Menu item parsing and structuring
- Purpose: Business logic for menu management
- Features:
- Automatic crawling on startup if data is outdated
- Weekend handling (no lunch service)
- REST API integration
- Purpose: Automated notifications to team members
- Features:
- Configurable scheduling
- Custom message formatting
- Error handling and retry logic
GET /api/menu/today- Get today's menuGET /api/menu- Get all available menusPOST /api/menu/crawl- Manually trigger menu crawling
POST /slack/notify- Trigger Slack notifications
The application uses application.yml for configuration:
spring:
application:
name: foodbox
crawl:
crawl-url: ${CRAWL_URL:http://www.msmfood.co.kr/page/sub2_7}
slack:
slack-token: ${SLACK_TOKEN:"YOUR_SLACK_TOKEN_HERE"}
slack-channel: ${SLACK_CHANNEL:"YOUR_SLACK_CHANNEL_HERE"}
user-name: "μ μ¬λ΄"
slack-url: "https://hooks.slack.com/services"
foodbox:
db-file-dir: ${DB_FILE_DIR:"/foodbox/db"}
server:
port: 80Create a .env file with the following variables:
SLACK_TOKEN=your_slack_token_here
SLACK_CHANNEL=#your_slack_channel_here
CRAWL_URL=http://www.msmfood.co.kr/page/sub2_7
DB_FILE_DIR=/path/to/database/directory- Java 21+
- Docker (optional)
- Docker Compose (optional)
git clone https://github.com/ArgonetDevStudio/foodbox.git
cd foodbox
./gradlew clean build
./gradlew bootRungit clone https://github.com/ArgonetDevStudio/foodbox.git
cd foodbox
./gradlew clean build
docker compose up -dRun all tests:
./gradlew testRun specific test class:
./gradlew test --tests MenuCrawlerTest- Create a new crawler implementation following the
MenuCrawlerpattern - Add appropriate CSS selectors for the new website structure
- Configure the new URL in
application.yml - Add comprehensive tests with sample HTML files
- Modify
SlackNotifyServicefor new notification patterns - Add new message templates in the Slack domain objects
- Configure additional webhook endpoints if needed
The project uses comprehensive testing with:
- Unit Tests: Mock-based testing for individual components
- Integration Tests: File-based HTML samples for realistic crawling tests
- Test Data: Sample HTML files in
src/test/resources/
- Crawling Fails: Check if the target website structure has changed
- Slack Notifications Not Working: Verify token and channel configuration
- Date Parsing Issues: Check if the website's date format has changed
The application provides detailed logging for:
- Crawling operations and results
- Menu parsing and validation
- Slack notification attempts
- Configuration validation on startup
- Fork the repository
- Create a feature branch
- Add comprehensive tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License.
