Skip to content
sabourinjPublic

About

Inventory management front-end for Grocy designed for Android devices with native barcode scanning hardware

Topics

Resources

Stars

10 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

153 Commits

Folders and files

Repository files navigation

Basil basil_logo

A high-performance Grocy client for Android: scan with a dedicated scanner device or your phone's camera.

Basil is an inventory management front-end for Grocy, built for scanning. While the official Grocy web interface is powerful, it can be cumbersome on a small screen with a box of groceries in your other hand. Basil was designed for dedicated Android devices with barcode reader hardware: by leveraging hardware scanner intents, it listens at the OS level, calls the Grocy API in realtime, and provides haptic feedback so you can keep your eyes on the physical stock.

New in 2.0: no scanner device needed. Any Android phone can scan with its camera, and every part of Basil works the same either way.


✨ Key Features

πŸ“· Two Ways to Scan

  • Hardware Scanner: On PDAs and other scanner devices, Basil receives scans straight from the built-in reader.
  • USB & Bluetooth Scanners: Plug a USB barcode scanner (or pair a Bluetooth one) into any Android device, even one without a camera, like a Raspberry Pi with a touchscreen. Scanners that type the barcode like a keyboard and press Enter work with no setup.
  • Phone Camera: On any Android phone, tap the "Tap to Scan" box and it becomes a live camera right where it is. Elsewhere, a camera button opens a small pop-up camera. Reads UPC/EAN, Code 128/39/93, ITF, QR and Data Matrix (including Grocycodes).
  • Volume Buttons: With the camera, either volume button turns the camera on and off, like a trigger. (This can be switched off in Settings.)
  • Tablets & Landscape: On tablets, landscape phones and wall-mounted screens, results split in two: the product picture on one side, buttons and stock on the other. Settings has a Screen Orientation choice (Portrait, Landscape or Auto).
  • Basil asks which one you'll use when you first open it.

πŸ›’ On-Device Selectable Workflow

  • Purchase Mode: Quickly add items to your stock. Basil intelligently checks the product's Grocy product and only prompts for an expiration date if the item requires it or if a default shelf-life isn't set. A one-tap label print option is displayed after adding to stock.
  • Consume Mode: Simply scan to remove from stock. Basil follows your Grocy instance's transaction logic to ensure virtual inventory matches physical reality.
  • Inventory Lookup: Instantly view a details of items in stock including specific expiration dates and quantities for each.
  • Shopping Mode: Open your Grocy shopping list and scan items as they go in the cart. Each scan purchases the item and checks it off, with Undo. The cart button puts the next scan on the list instead, and Clear completed tidies up when you're done.
  • Transfer Mode: Pick a location in Settings, then scan items to move them there. With the camera, it stays on between items.

πŸ” Intelligent Product Resolution

  • Grocy-First: Basil first checks your Grocy database for the barcode.
  • OpenFoodFacts-Fallback: If unknown, it triggers a lookup with OpenFoodFacts via Grocy's API.
  • User Defaults: Newly discovered items are automatically assigned to the Default Location (configured in Grocy User Settings of the user the API key is associated with), preventing the "Missing Location" errors common in other apps.
  • Gemini AI Enrichment: If enabled, Gemini AI can determine estimated item cost, due dates, and storage location based upon the product name identified. Basil uses Google's newest Flash model by default; you can pick a specific model in Settings.

πŸ“± Industrial Design

  • Deep Purple UI: High-contrast, dark-themed interface designed to elimninate need for light/dark selection, reduce visual strain, and look sleek on industrial displays.
  • Haptic Language:
    • Short Pulse: Success / Scan Accepted.
    • Double Pulse: Error / Item Not Found.
    • Triple Pulse: Input Required (e.g., Expiration Date needed).
  • Sounds & Vibration: Both on by default, and each can be switched off in Settings.

πŸ–ΌοΈ Screenshots

Setup & AI Configuration

Grocy Config Gemini Enable Gemini Config Settings
Scanning the Grocy API Key Opt-in for Gemini features Scanning the Gemini API Key Settings & About

Workflow Modes

Purchase Scan Purchase Success Inventory Example 1 Inventory Example 2
Ready to scan barcodes Confirmation of added stock Inventory-MacCheese Inventory-Bread

πŸ›  Setup & Configuration

Basil runs on Android 13 or newer.

1. Choose How You'll Scan

On first launch, Basil asks "How will you scan?": Phone camera or Hardware scanner (built-in or USB). On a scanner device or with a USB scanner plugged in, you can also just scan something; Basil picks Hardware scanner for you. Devices without a camera skip the question. To change your choice later, use Logout / Disconnect in Settings, which resets Basil and asks again.

2. The "Magic" QR Code

Basil uses a zero-config setup. Generate an API key in Grocy and show the QR code to scan in Basil. With the camera, tap Scan QR Code. If it won't scan, the back arrow returns to the scanner choice. You could also generate your own if desired using format: Grocy URL and API Key separated by a pipe (|): https://grocy.yourdomain.com/api|your_secret_api_key_here

πŸ’‘ In environments where you may share the scanner device with multiple people, it may be desireable to create a generic "Basil" user (or the name of your chosing) in Grocy for the device and create the API key attached to that user account. Thus the journals will show "Basil" vs. an indiviuals name who may not have been using the shared device.

3. Scanner Intent Configuration (scanner devices only)

Skip this if you scan with the phone camera or a USB/Bluetooth scanner (see below). For the hardware buttons to work, configure your PDA's "Scanner" or "DataWedge" to output the following:

  • Intent Action: com.basil.grocyscanner.SCAN
  • Intent Delivery: Broadcast Intent
  • String Extra: barcode_data Output the complete UPC including check digit. NO spaces or other formatting prefix/suffix.

πŸ’‘ You may want to disable other types of barcode formats to eliminate 'false scans'. Many products have Datamatrix/QR Code on the packaging for consumer and non-consumer purpoposes. However, if you are using Grocycode or custom printed Datamatrix/QR Code labels, make sure those formats are not disabled. Basil can process them!

4. USB / Bluetooth Scanners (keyboard mode)

No intent setup needed. This also works for scanner devices set to keystroke output instead of an intent. Set the scanner to its keyboard (HID) mode with an Enter (or Tab) suffix, and scan. Basil tells a scanner from someone typing by speed: the whole code must arrive with less than 50 ms between characters. While a text field is open (a quantity, a date, the Grocy URL), keys go to the field as usual. If scans are ignored, check the scanner isn't set to a slow "inter-character delay" and that it sends Enter after each code.

5. Device Location (optional)

By default (Item defaults), Grocy decides where stock goes and comes from, as always. In Settings > Device Location you can tell Basil where this device is, e.g. a scanner by the garage freezer:

  • Purchases (Purchase mode and scan-to-purchase while shopping) go into that location. Only the stock entry is affected: products' default locations in Grocy are left alone, and new products still get your usual default location.
  • Consumes come from that location when it holds enough of the item. If it doesn't, Grocy picks as usual for the whole amount, and the result says where it came from (e.g. "From Kitchen Pantry").
  • A location chip on the scan screen and the result shows it's on.

If the location is a freezer in Grocy, purchases get the product's days after freezing as their due date when it has one, as Grocy's own purchase page does. Products marked should not be frozen are still added, with a warning. If the location is deleted in Grocy, Basil falls back to item defaults and says so in Settings.

6. Kiosk / Auto-Launch (optional)

For a wall-mounted or fridge-side screen that should always show Basil:

  • Home app: In Android's Settings > Apps > Default apps > Home app, pick Basil. It then opens on startup and whenever Home is pressed. Basil's Settings shows a Change Home App button while it's the Home app, and an Android Settings button for getting to the rest of the device.
  • App pinning (optional): Turn on Settings > Security > App pinning to keep Basil on screen until it's unpinned.
  • Stay awake: Turn on Developer options > Stay awake (screen stays on while charging/powered), or set a long screen timeout.

πŸ’» Technical Architecture

Basil is built using modern Android standards to ensure long-term maintainability:

  • Language: Kotlin 2.x
  • UI Framework: Jetpack Compose (Declarative UI)
  • Networking: Retrofit 2 + OkHttp 4
  • JSON Parsing: Gson
  • Async Logic: Kotlin Coroutines & Flow
  • Camera Scanning: CameraX + ML Kit barcode scanning (bundled, so it works without Google Play Services)
  • Architecture: MVVM (Model-View-ViewModel)

API Implementation

Basil communicates with the Grocy REST API. Key endpoints include:

  • /stock/products/by-barcode/{barcode}: Primary resolution.
  • /stock/barcodes/external-lookup/{barcode}?add=true: The "magic" auto-add trigger.
  • /stock/products/{productId}/entries: Powers the Inventory table.

🀝 Contributing & Open Source

Basil is open-source because the self-hosting community thrives on shared tools.

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature/AmazingFeature).
  3. Commit your changes (git commit -m 'Add some AmazingFeature').
  4. Push to the branch (git push origin feature/AmazingFeature).
  5. Open a Pull Request.

πŸ“œ License

Distributed under the MIT License. See LICENSE for more information.


Developed with ❀️ in Massachusetts by Justin Sabourin for the Grocy Community.

About

Inventory management front-end for Grocy designed for Android devices with native barcode scanning hardware

Topics

Resources

Stars

10 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages