Wine Cellar Management Application with OCR label scanning
Project description
WineBox
A wine cellar management application with OCR label scanning.
Features
- Label Scanning: Upload wine label images for automatic text extraction via OCR
- Wine Autocomplete: Search 100K+ wines from the X-Wines dataset with community ratings
- Inventory Tracking: Check-in and check-out bottles with full history
- Smart Parsing: Automatically identifies vintage, grape variety, region, and more
- Search: Find wines by any criteria
- Web Interface: Simple, mobile-friendly interface
Quick Start
Prerequisites
- Python 3.11+
- Tesseract OCR
Installation
From PyPI:
pip install winebox
From source:
# Clone the repository
git clone https://github.com/jdrumgoole/winebox.git
cd winebox
# Install dependencies
uv sync --all-extras
# Install Tesseract OCR
# macOS:
brew install tesseract
# Ubuntu/Debian:
sudo apt-get install tesseract-ocr
Running the Server
# Development mode with auto-reload
invoke start --reload
# Background mode
invoke start-background
# Check status
invoke status
# Stop server
invoke stop
Access the Application
- Web Interface: http://localhost:8000/static/index.html
- API Documentation: http://localhost:8000/docs
- Health Check: http://localhost:8000/health
Usage
Check In Wine
- Navigate to the Check In page
- Upload front label image (required)
- Optionally upload back label image
- Review/edit auto-detected wine details
- Set quantity and add notes
- Click "Check In Wine"
Check Out Wine
- Go to the Cellar view
- Click "Check Out" on a wine card
- Enter quantity to remove
- Add optional notes (tasting notes, occasion)
- Confirm checkout
Search
Use the Search page to find wines by:
- Text search (name, winery, region)
- Vintage year
- Grape variety
- Region or country
- Stock status
API
Full REST API available at /api:
| Endpoint | Method | Description |
|---|---|---|
/api/wines/checkin |
POST | Add wine to cellar |
/api/wines/{id}/checkout |
POST | Remove wine from cellar |
/api/wines |
GET | List all wines |
/api/wines/{id} |
GET | Get wine details |
/api/cellar |
GET | Current inventory |
/api/cellar/summary |
GET | Cellar statistics |
/api/transactions |
GET | Transaction history |
/api/search |
GET | Search wines |
/api/xwines/search |
GET | Autocomplete wine search |
/api/xwines/wines/{id} |
GET | X-Wines wine details |
/api/xwines/stats |
GET | Dataset statistics |
See /docs for interactive API documentation.
Data Storage
Database
The SQLite database is stored at data/winebox.db by default. This can be configured via the WINEBOX_DATABASE_URL environment variable.
Images
Wine label images are stored in the data/images/ directory by default. Each image is saved with a UUID filename to avoid conflicts.
| Item | Default Location | Environment Variable |
|---|---|---|
| Database | data/winebox.db |
WINEBOX_DATABASE_URL |
| Images | data/images/ |
WINEBOX_IMAGE_STORAGE_PATH |
Images are served via the API at /api/images/{filename}.
Note: The data/ directory is excluded from git (see .gitignore). Make sure to back up this directory to preserve your wine collection data.
X-Wines Dataset
WineBox integrates the X-Wines dataset for wine autocomplete, providing suggestions from 100,646 wines with 21 million community ratings.
Installing the Dataset
# Run database migration (if not already done)
uv run python -m scripts.migrations.runner up
# Option 1: Test dataset (100 wines, for development)
uv run python -m scripts.import_xwines --version test
# Option 2: Full dataset (100K+ wines, for production)
# First, install gdown and download from Google Drive
uv pip install gdown
mkdir -p data/xwines
uv run gdown --folder "https://drive.google.com/drive/folders/1LqguJNV-aKh1PuWMVx5ELA61LPfGfuu_?usp=sharing" -O data/xwines/
cp data/xwines/X-Wines_Official_Repository/last/XWines_Full_*.csv data/xwines/
# Then import
uv run python -m scripts.import_xwines --version full
The autocomplete appears when typing in the Wine Name field during check-in.
Label Scanning
WineBox uses AI-powered label scanning to extract wine information from photos.
Claude Vision (Recommended)
For best results, configure Claude Vision by setting your Anthropic API key:
export ANTHROPIC_API_KEY=your-api-key
# or
export WINEBOX_ANTHROPIC_API_KEY=your-api-key
Claude Vision provides intelligent label analysis that:
- Handles decorative and artistic fonts
- Understands wine-specific terminology
- Extracts structured data (winery, vintage, grape variety, region, etc.)
- Works with curved or angled text
Tesseract OCR (Fallback)
If no Anthropic API key is configured, WineBox falls back to Tesseract OCR. This requires Tesseract to be installed on your system:
# macOS
brew install tesseract
# Ubuntu/Debian
sudo apt-get install tesseract-ocr
Authentication
WineBox requires authentication for all API endpoints (except /health).
Creating Users
Use the winebox-admin command to manage users:
# Create an admin user
uv run winebox-admin add admin --email admin@example.com --admin --password yourpassword
# Create a regular user
uv run winebox-admin add username --email user@example.com --password yourpassword
# List all users
uv run winebox-admin list
# Disable/enable a user
uv run winebox-admin disable username
uv run winebox-admin enable username
# Change password
uv run winebox-admin passwd username --password newpassword
# Remove a user
uv run winebox-admin remove username
Server Management
Use the winebox-server command to manage the server:
# Start server (foreground)
uv run winebox-server start --foreground
# Start server (background)
uv run winebox-server start
# Stop server
uv run winebox-server stop
# Restart server
uv run winebox-server restart
# Check status
uv run winebox-server status
API Authentication
The API uses JWT bearer tokens. To authenticate:
- POST to
/api/auth/tokenwithusernameandpassword(form-urlencoded) - Include the returned token in subsequent requests:
Authorization: Bearer <token>
Tokens expire after 24 hours.
Development
Running Tests
# Run all tests
invoke test
# With verbose output
invoke test --verbose
# With coverage
invoke test --coverage
Project Structure
winebox/
├── winebox/ # Application package
│ ├── main.py # FastAPI app
│ ├── models/ # Database models
│ ├── schemas/ # API schemas
│ ├── routers/ # API endpoints
│ ├── services/ # Business logic
│ └── static/ # Web interface
├── tests/ # Test suite
├── docs/ # Documentation
└── tasks.py # Build tasks
Building Documentation
invoke docs-build
invoke docs-serve
Tech Stack
- FastAPI: Web framework
- SQLAlchemy: ORM
- SQLite: Database
- Tesseract: OCR engine
- Vanilla JS: Frontend (no frameworks)
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file winebox-0.3.2.tar.gz.
File metadata
- Download URL: winebox-0.3.2.tar.gz
- Upload date:
- Size: 5.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3451fa6c14fecde4ef0ac60851ba598d74003ccaf48949deaedd9cdf8c68f5d0
|
|
| MD5 |
0415e3e962655b011929f9167901e5cb
|
|
| BLAKE2b-256 |
7d4ae0abca04de7adbffb24fa73f94094aa0a6fd9097a893ac7e61fff971b64d
|
Provenance
The following attestation bundles were made for winebox-0.3.2.tar.gz:
Publisher:
publish.yml on jdrumgoole/winebox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
winebox-0.3.2.tar.gz -
Subject digest:
3451fa6c14fecde4ef0ac60851ba598d74003ccaf48949deaedd9cdf8c68f5d0 - Sigstore transparency entry: 952767411
- Sigstore integration time:
-
Permalink:
jdrumgoole/winebox@aacb6f0c6d21c2a35951eed39c6280e14571b403 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/jdrumgoole
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@aacb6f0c6d21c2a35951eed39c6280e14571b403 -
Trigger Event:
release
-
Statement type:
File details
Details for the file winebox-0.3.2-py3-none-any.whl.
File metadata
- Download URL: winebox-0.3.2-py3-none-any.whl
- Upload date:
- Size: 66.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e24488b24b24a7a9474dd5a2eaa4985517f645b148345ed2a761c17500ac870a
|
|
| MD5 |
533a67636eb5d5c0ea23f649226e470a
|
|
| BLAKE2b-256 |
f6ff9423ce763198510848b90a825c97e9971c82dc5f699eca6ac1f743200cdc
|
Provenance
The following attestation bundles were made for winebox-0.3.2-py3-none-any.whl:
Publisher:
publish.yml on jdrumgoole/winebox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
winebox-0.3.2-py3-none-any.whl -
Subject digest:
e24488b24b24a7a9474dd5a2eaa4985517f645b148345ed2a761c17500ac870a - Sigstore transparency entry: 952767502
- Sigstore integration time:
-
Permalink:
jdrumgoole/winebox@aacb6f0c6d21c2a35951eed39c6280e14571b403 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/jdrumgoole
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@aacb6f0c6d21c2a35951eed39c6280e14571b403 -
Trigger Event:
release
-
Statement type: