🥃 Bourbonacci

A self-hosted infinity bottle tracker. Log every bourbon you add to your blend, track what you've consumed, and watch your bottle's story unfold over time. Community bottles are visible to anyone who visits the site — click a card to browse the full bourbon list inside that bottle.

Built with FastAPI, vanilla JS, and MySQL — fully containerized with Docker Compose. No framework dependencies on the frontend.

The Name

Bourbonacci is a blend of Bourbon and the Fibonacci sequence. The Fibonacci sequence — 1, 1, 2, 3, 5, 8, 13… — builds endlessly on everything that came before it, with no defined end. An infinity bottle works the same way: every addition layers on top of the existing blend, compounding in complexity over time. Just like the sequence, your bottle is never truly finished.

Features

  • Infinity bottle tracking — log add entries (bourbon name, proof, shots) and remove entries (shots consumed)
  • Live stats — bourbons added, total shots poured in, shots remaining, estimated weighted proof
  • Bottle fill bar — visual level indicator based on your configured bottle size
  • Community page — public leaderboard of all bottles; click any card to see a searchable, alphabetical bourbon list
  • Settings modal — update display name, bottle size, timezone, and password from any page via the gear icon
  • Admin panel — separate out-of-band admin login (not a user account) with Users, Notifications, Backups and Reset tabs
  • Backups — scheduled and on-demand full database dumps to an NFS share, with restore (entries only or all data)
  • JWT auth — Bearer token auth; admin tokens are a separate credential (admin: true claim, no user sub)
  • About page — public explainer on what an infinity bottle is, why to track it, and how to get started
  • Push notifications — Ntfy alerts for admin logins, new registrations, account changes, resets and restores — configured in the admin panel

Stack

Layer Technology
Backend FastAPI 0.165.0 (Starlette 1.10.0, Python 3.12), async SQLAlchemy 2.1.9, Uvicorn 0.54.0
Database MySQL 8.4.13
Frontend Vanilla HTML/CSS/JS (no framework)
Reverse Proxy Nginx 1.31.9 (Alpine)
Auth JWT via python-jose 3.5.0, passwords hashed with passlib[bcrypt] 1.7.4 (bcrypt 4.0.1)
Rate limiting slowapi 0.1.10
Notifications ntfy (optional, configured in the admin panel)
Scheduling apscheduler 3.11.3 (backup schedule)
Backups mariadb-dump / mariadb client (works against the MySQL 8 server)
Container Docker Compose

Project Structure

bourbonacci/
├── backend/
│   ├── app/
│   │   ├── main.py           # FastAPI app entry point, lifespan (DB init + backup scheduler)
│   │   ├── config.py         # Pydantic settings (reads from .env)
│   │   ├── database.py       # Async engine, session factory, Base, init_db()
│   │   ├── dependencies.py   # get_db, get_current_user, get_current_admin
│   │   ├── limiter.py        # slowapi rate limiter instance
│   │   ├── scheduler.py      # APScheduler job for scheduled backups
│   │   ├── models/
│   │   │   ├── user.py       # User ORM model
│   │   │   ├── entry.py      # Entry ORM model (add/remove types)
│   │   │   └── admin_settings.py # Single-row admin config (ntfy, backup schedule, admin lockout)
│   │   ├── routers/
│   │   │   ├── auth.py       # POST /api/auth/register, /api/auth/login
│   │   │   ├── users.py      # GET/PUT /api/users/me, PUT /api/users/me/password
│   │   │   ├── entries.py    # CRUD /api/entries, GET /api/entries/stats
│   │   │   ├── public.py     # GET /api/public/stats (unauthenticated)
│   │   │   ├── admin.py      # Admin login, user management, ntfy settings, reset
│   │   │   └── backups.py    # Backup schedule, run now, list, restore, delete
│   │   ├── schemas/
│   │   │   ├── user.py       # Pydantic schemas for user/auth
│   │   │   ├── entry.py      # Pydantic schemas for entries/stats
│   │   │   └── admin.py      # Pydantic schemas for admin panel + backups
│   │   ├── services/
│   │   │   └── backup.py     # mariadb-dump / restore, retention pruning
│   │   └── utils/
│   │       ├── security.py   # JWT creation/decode (user + admin tokens), password hashing
│   │       ├── crypto.py     # Fernet encryption (from SECRET_KEY) for the stored ntfy token
│   │       └── notify.py     # Ntfy push notification helper (reads admin settings)
│   ├── Dockerfile
│   └── requirements.txt
├── frontend/
│   ├── index.html            # Landing page + public community bottles
│   ├── about.html            # What is an infinity bottle? + Bourbonacci explainer
│   ├── login.html            # User login; falls back to admin login
│   ├── register.html
│   ├── dashboard.html        # My Bottle — stats, fill bar, entry log
│   ├── log.html              # Log add or remove entries
│   ├── profile.html          # Profile settings (display name, timezone, password)
│   ├── admin.html            # Admin panel (Users / Notifications / Backups / Reset)
│   ├── css/style.css         # Bourbon-themed dark UI
│   └── js/
│       ├── api.js            # Fetch wrapper, token injection, escHtml
│       ├── auth.js           # Auth state, nav rendering, settings modal
│       └── admin.js          # Admin panel logic (own admin token + API client)
├── nginx/
│   └── default.conf          # Serves frontend (no-cache), proxies /api/ to backend:8000
├── docker-compose.yml
└── .env.example

Pages

Page Auth Description
/index.html No Landing page with community bottle cards; click to browse bourbons
/about.html No What is an infinity bottle? Why Bourbonacci? How to get started
/login.html No Login form — redirects to /index.html on success; admin credentials redirect to /admin.html
/register.html No Registration form
/dashboard.html Yes My Bottle — stats, fill bar, full entry log with delete
/log.html Yes Log an add or remove entry (date defaults to today in your saved timezone)
/profile.html Yes Edit display name, timezone, bottle size, password
/admin.html Admin Admin panel — Users, Notifications, Backups, Reset

Navigation

The top-right nav area shows (when logged in):

  • Display name — non-clickable label
  • ⚙ Settings button — opens a modal to update display name, bottle size, timezone, and password
  • Logout button

Admin Panel

The admin is an out-of-band login defined by ADMIN_USERNAME / ADMIN_PASSWORD in .env — not a row in users. Sign in from the normal login page: if the user login is rejected, the page tries the admin login and, on success, opens /admin.html with a separate admin token (bb_admin_token). After 5 failed admin attempts the admin login locks for 15 minutes (with an ntfy alert).

Tab What it does
Users Search users, reset password (generates a one-time temp password), disable/enable, delete (type the email to confirm)
Notifications Ntfy server URL, topic and access token (token stored encrypted), send a test notification
Backups Schedule (daily/weekly, hour in UTC, retention count, optional subfolder), backup now, list files, restore (restore entries or restore all typed to confirm), delete
Reset Reset all entries for every user (type reset entries); a safety backup runs first and the reset is aborted if it fails

Backups are gzipped SQL dumps named bourbonacci_<UTC timestamp>_<random>.sql.gz, written to /backups in the backend container — the NFS volume defined in docker-compose.yml (BACKUP_NFS_HOST / BACKUP_NFS_PATH). The share must be writable by uid 1000 (the backend's appuser). A full restore replaces every table, including admin settings, with the backup's contents.

API Endpoints

Auth

Method Path Auth Rate limit Description
POST /api/auth/register No 5/min Register new account, returns JWT
POST /api/auth/login No 10/min Login, returns JWT

Users

Method Path Auth Rate limit Description
GET /api/users/me Yes — Get current user profile
PUT /api/users/me Yes — Update display name, timezone, bottle size
PUT /api/users/me/password Yes 5/min Change password

Entries

Method Path Auth Description
GET /api/entries Yes List entries for current user (?limit=200&offset=0, max 1000)
POST /api/entries Yes Create an entry (add or remove)
DELETE /api/entries/{id} Yes Delete an entry
GET /api/entries/stats Yes Aggregated stats for current user

Public

Method Path Auth Rate limit Description
GET /api/public/stats No 30/min Stats + bourbon list for all users (max 500)

Admin

Method Path Auth Description
POST /api/admin/login No (5/min) Admin login with ADMIN_USERNAME / ADMIN_PASSWORD, returns admin JWT
GET /api/admin/users Admin List all users with entry counts
POST /api/admin/users/{id}/reset-password Admin Generate and return a temporary password
POST /api/admin/users/{id}/disable Admin Disable a user account
POST /api/admin/users/{id}/enable Admin Re-enable a user account
DELETE /api/admin/users/{id} Admin Hard-delete a user and all their data
GET /api/admin/ntfy-settings Admin Get ntfy server/topic (token reported only as has_token)
PUT /api/admin/ntfy-settings Admin Update ntfy server/topic/token
POST /api/admin/ntfy-settings/test Admin Send a test notification
POST /api/admin/reset/entries Admin Safety backup, then delete every entry for every user

Backups

Method Path Auth Description
GET /api/admin/backups/settings Admin Get schedule + last backup status
PUT /api/admin/backups/settings Admin Update schedule, retention, subfolder
GET /api/admin/backups Admin List backup files
POST /api/admin/backups/run Admin Run a backup now
POST /api/admin/backups/{filename}/restore Admin Restore ({"scope": "entries"} or {"scope": "all"})
DELETE /api/admin/backups/{filename} Admin Delete a backup file

Authenticated routes expect Authorization: Bearer <token> header. Admin routes require an admin token; user tokens are rejected there and vice versa.

Entry Schema

{
  "entry_type": "add" | "remove",
  "date": "YYYY-MM-DD",
  "bourbon_name": "string (required for add)",
  "proof": 90.0,
  "amount_shots": 1.0,
  "notes": "optional string"
}

Stats Response

{
  "total_add_entries": 12,
  "total_shots_added": 18.5,
  "current_total_shots": 14.25,
  "estimated_proof": 95.3
}

current_total_shots = total added − total removed. estimated_proof = weighted average proof across all add entries by shot count.

Getting Started

Prerequisites

  • Docker + Docker Compose
  • (Optional) Nginx Proxy Manager or equivalent for TLS termination

Setup

cp .env.example .env
# Edit .env — set real passwords, a secure SECRET_KEY, and your domain

Generate a secure secret key:

python3 -c "import secrets; print(secrets.token_hex(64))"

Run

docker compose up -d

The app will be available at http://localhost:8057 by default (configure the port mapping in docker-compose.yml).

The backend waits for MySQL to pass its healthcheck before starting. Tables are created automatically on first boot via SQLAlchemy's create_all. Sign in with ADMIN_USERNAME / ADMIN_PASSWORD to reach the admin panel, then set up notifications and the backup schedule there.

Stop

docker compose down
# To also remove the database volume:
docker compose down -v

Environment Variables

Variable Required Description
MYSQL_ROOT_PASSWORD Yes MySQL root password
MYSQL_DATABASE Yes Database name (default: bourbonacci)
MYSQL_USER Yes App DB user
MYSQL_PASSWORD Yes App DB password
DATABASE_URL Yes SQLAlchemy async DSN (mysql+aiomysql://user:pass@db:3306/dbname)
SECRET_KEY Yes JWT signing secret — keep long and random
ACCESS_TOKEN_EXPIRE_MINUTES No JWT TTL in minutes (default: 480)
ADMIN_USERNAME No Out-of-band admin login username — must not match any user's email. Leave blank (with the password) to disable the admin panel.
ADMIN_PASSWORD No Out-of-band admin login password
ALLOWED_ORIGINS No Comma-separated CORS origins (default: http://localhost)
BACKUP_NFS_HOST No NFS server for the backups volume (default: 172.16.21.51)
BACKUP_NFS_PATH No NFS export for the backups volume (default: /mnt/pool1/bourbonacci-backups)

Ntfy Notifications

Configured in the admin panel (Notifications tab). Once a server URL and topic are saved, the following events trigger push notifications:

Event Priority
New user registration Default
Admin login High
Admin login locked out High
Password reset issued Default
User account disabled Default
User account deleted Default
All entries reset High
Backup restored High

Security

  • Passwords hashed with bcrypt
  • JWTs signed with HS256, configurable TTL
  • Rate limiting on auth, admin login and password change endpoints
  • Admin login lockout after 5 failed attempts (15 minutes)
  • Stored ntfy token encrypted with a key derived from SECRET_KEY
  • Backup files written 0600; backup filenames and subfolders validated against path traversal
  • Disabled accounts blocked at login and on every authenticated request
  • All security headers set in Nginx (HSTS, CSP, X-Frame-Options, etc.)
  • Gzip compression enabled for text responses
  • Backend runs as a non-root user inside the container
  • Container resource limits enforced (memory + CPU)
  • Docker image digests pinned in docker-compose.yml

Data Model

users

Column Type Notes
id int PK
email varchar(255) unique
password_hash varchar(255) bcrypt
display_name varchar(100) nullable
timezone varchar(50) default UTC
bottle_size float nullable user-configured bottle capacity in shots
is_admin bool default false — legacy, unused (admin is out-of-band)
is_disabled bool default false
created_at datetime server default

entries

Column Type Notes
id int PK
user_id int FK → users cascade delete
entry_type enum add or remove
date date user-supplied
bourbon_name varchar nullable required for add entries
proof float nullable
amount_shots float default 1.0
notes text nullable
created_at datetime server default

admin_settings (single row, id = 1)

Column Type Notes
id int PK always 1
ntfy_server_url / ntfy_topic varchar(255) nullable
ntfy_token varchar(500) nullable Fernet-encrypted
backup_enabled bool default false
backup_frequency varchar(10) daily or weekly
backup_hour / backup_weekday int UTC hour 0–23; weekday 0 = Monday
backup_retention int backups kept, default 14
backup_location varchar(255) nullable optional subfolder under /backups
last_backup_at / last_backup_status / last_backup_error last run result (UTC)
admin_failed_attempts / admin_locked_until admin login lockout state (UTC)
S
Description
A self-hosted infinity bottle tracker. Log every bourbon you add to your blend, track what you've consumed, and watch your bottle's story unfold over time. Community bottles are visible to anyone who visits the site — click a card to browse the full bourbon list inside that bottle.
Readme
249 KiB
0 Stars 1 Watchers 0 Forks
Languages
Python 36.5%
HTML 27.7%
JavaScript 27.1%
CSS 8.2%
Dockerfile 0.5%