FoodSense is a modern Java desktop application that scans grocery barcodes to display nutrition data, ingredients, allergen warnings, and official Nutri-Score ratings via the Open Food Facts API.
- In-App Live Webcam Scanner: Built-in modal dialog with illuminated corner reticles, animated scan guide, and automatic barcode detection.
- Modern Adaptive Theme: Sleek desktop interface built with FlatLaf, supporting instant Light and Dark mode toggling via an icon button.
- Nutri-Score Spectrum Bar: Displays the recognized European 5-pill indicator (A–E) with the active grade elevated and highlighted.
- Nutrition Facts & Macro Visualizer: Hero calorie callout, visual macronutrient distribution bar (Carbs, Fats, Protein), and per-100g nutrient table.
- Allergen Alert Banners: Highlighted alert cards parsing allergens with clear warning iconography.
- Hardened Security & Input Validation: Strict barcode sanitization, Swing HTML injection defenses, bounded async image loading, and SSRF prevention.
- Headless CLI Mode: Fast barcode query via
--barcode <code>/-b <code>for headless terminal use without initializing GUI components.
- Java 25 / Swing: Core desktop application and GUI
- FlatLaf: Modern cross-platform Look and Feel with Retina HiDPI scaling
- JavaCV (OpenCV): Webcam capture and computer vision
- ZXing: Barcode decoding
- Gson: JSON deserialization
Prebuilt platform-specific JARs are published on the Releases page for macOS (Apple Silicon ARM64), Windows (x64), and Linux (x64).
Requires Java 25+ installed on your system.
java -jar FoodSense-macOS-ARM64.jar
# or FoodSense-Windows-X64.jar / FoodSense-Linux-X64.jarEvery release publishes cryptographic SHA-256 checksums and GitHub build provenance attestations. To verify your downloaded artifact integrity:
macOS / Linux:
shasum -a 256 -c FoodSense-macOS-ARM64.jar.sha256
gh attestation verify FoodSense-macOS-ARM64.jar --repo SamuelIVX/FoodSenseWindows (PowerShell):
Get-FileHash .\FoodSense-Windows-X64.jar -Algorithm SHA256
gh attestation verify .\FoodSense-Windows-X64.jar --repo SamuelIVX/FoodSenseCompare the printed hash with the contents of FoodSense-Windows-X64.jar.sha256.
Note for macOS users: When launching via terminal, ensure your terminal application (Terminal.app, iTerm) has Camera permissions granted in System Settings > Privacy & Security > Camera for live barcode scanning.
git clone https://github.com/SamuelIVX/FoodSense.git
cd FoodSense
mvn clean packageThe build produces a self-contained fat JAR in target/ using maven-shade-plugin.
Interactive GUI:
mvn compile exec:java -Dexec.mainClass="com.foodsense.FoodSense"Headless CLI search:
mvn compile exec:java -Dexec.mainClass="com.foodsense.FoodSense" -Dexec.args="-b 0049000006346"Override the default API host (world.openfoodfacts.org):
mvn compile exec:java -Dexec.mainClass="com.foodsense.FoodSense" -Dfoodsense.host="staging.openfoodfacts.org" -Dexec.args="-b 0049000006346"src/main/java/com/foodsense/
├── FoodSense.java # Main entry point (CLI springboard + GUI launcher)
├── ProductApiClient.java # API client and host resolver
├── FoodSenseGUI.java # Main desktop window & search orchestrator
├── VideoProcessor.java # Webcam capture & barcode detection pipeline
├── Product.java # Product data model
├── Nutriments.java # Nutrition data model
├── ApiResponse.java # API response wrapper
├── security/
│ ├── SecurityValidator.java # Barcode regex, HTML escaping, and HTTPS URL checks
│ └── SafeImageLoader.java # Bounded async image fetcher (5MB cap, timeouts)
└── ui/
├── FoodSenseTheme.java # Design tokens, palette scales, and Light/Dark toggle
├── CameraScanDialog.java # In-app modal camera scanner with viewfinder reticles
├── NutriScoreSpectrumView.java # 5-pill Nutri-Score spectrum (A-B-C-D-E)
├── NutritionLabelPanel.java # Nutrition card with hero calories & macro proportion bar
└── AllergenBanner.java # Danger alert card for allergen warnings
- Camera Permissions: Ensure your OS camera permissions allow the terminal or Java process to access video device 0.
- Barcode Validation: Barcodes must be 3–48 characters (letters, digits, hyphens, or underscores).
- Product Not Found: Products must be cataloged in Open Food Facts. Check the barcode on
world.openfoodfacts.org.