A simple Vaadin Flow (v24) web app that helps calculate a restaurant bill: tip amount, bill + tip total, and amount per person when splitting the check. Built with Java 17 and Maven, packaged as a WAR, and runnable locally via Jetty or deployable to Heroku.
Last updated: 2025-10-31
- Enter bill subtotal, tip percentage, and number of people to split between
- Calculates:
- Tip amount
- Bill + tip total
- Amount per person
- Clean Vaadin UI, no JavaScript required
- Unit tests for the calculation service
- Java 17
- Vaadin 24 (Flow)
- Maven (WAR packaging)
- Jetty Maven Plugin for local dev server
- JUnit 5 for tests
- Optional: Heroku deployment using
webapp-runnerand aProcfile
- JDK 17 installed and on PATH
- Maven 3.9+ installed and on PATH
git clone https://github.com/your-org-or-user/RestaurantBill.git
cd RestaurantBillThis project uses the Jetty Maven Plugin. The first run may take longer as Vaadin prepares the frontend.
mvn -DskipTests jetty:runThen open:
To stop the server, press Ctrl+C in the terminal.
- Development build (no production optimizations):
mvn -DskipTests clean packageProduces target/restaurantbill-0.1.war.
- Production build (minified frontend, no dev tools):
mvn -Pproduction -DskipTests clean packagemvn testCore logic lives in BillCalculationService, which computes three values from inputs on the Bill model:
- Tip amount =
billTotal * tipPercent / 100 - Total with tip =
billTotal + tipAmount - Amount per person =
totalWithTip / numberOfPeople
Key files:
src/main/java/com/reedmanit/restaurantbill/service/BillCalculationService.java– calculation logic (rounds to 2 decimals)src/main/java/com/reedmanit/restaurantbill/model/Bill.java– holds bill fields (VaadinNumberFields)src/main/java/com/reedmanit/restaurantbill/view/BillForm.java– the UI formsrc/main/java/com/reedmanit/restaurantbill/MainView.javaandAppShell.java– Vaadin view and shellsrc/test/java/com/reedmanit/restaurantbill/service/BillCalculationServiceTest.java– unit tests
RestaurantBill/
├─ pom.xml
├─ Procfile
├─ system.properties
├─ src/
│ ├─ main/
│ │ ├─ java/com/reedmanit/restaurantbill/
│ │ │ ├─ model/
│ │ │ ├─ service/
│ │ │ └─ view/
│ │ ├─ resources/
│ │ └─ webapp/
│ └─ test/
└─ README.md
This repo includes a Procfile, system.properties, and Maven setup to fetch webapp-runner. Two common options:
- Deploy with Git (Heroku Java buildpack)
- Install Heroku CLI and log in
heroku create
heroku stack:set heroku-22
git push heroku mainHeroku will build and run the app using the Procfile.
- Deploy with Maven plugin
The POM includes
com.heroku.sdk:heroku-maven-plugin.
mvn heroku:deploy- If the first
jetty:runis slow, it’s likely Vaadin preparing the frontend. Subsequent runs are faster. - If the browser shows a 404, verify Jetty is running and you’re opening
http://localhost:8080/. - On Windows PowerShell, you can run the same Maven commands shown above.
This project is licensed. See the LICENSE file for details.
- Fork the repo, create a feature branch, and open a PR.
- Please add or update tests for logic changes.
- Vaadin team and community for the excellent web components and Flow framework.