A fun web application to track coffee consumption among friends. Users can submit their names and coffee photos, and the leaderboard shows who's drinking the most coffee.
- Leaderboard with coffee counts and rankings
- Photo submissions stored on disk
- Admin-protected moderation dashboard
- Modern, responsive UI using Tailwind CSS
- Python 3.10+ with
venv - SQLite (bundled with Python)
systemd(for the supplied service file) and a reverse proxy such as Nginx for TLS/ports 80-443
Create a .env in the project root (keep it out of version control):
FLASK_APP=app.py
FLASK_ENV=production
SECRET_KEY=change-me
DATABASE_URL=sqlite:///coffee_leaderboard.db
UPLOAD_FOLDER=static/uploads
PORT=8000
ADMIN_USERNAME=admin
ADMIN_PASSWORD=strong-password
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Initialize the database (runs migrations):
flask --app app db upgradeThe helper
init_db.pywill drop all tables; avoid it when you have real data.
- Run the app:
python app.py- Open
http://localhost:5000
- Clone the repo onto the server (e.g.,
/home/ubuntu/mockercount) and add the.envabove with production values. - Create a virtual environment and install deps:
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt- Prepare storage and database:
mkdir -p static/uploads
flask --app app db upgrade- Smoke test:
venv/bin/gunicorn --bind 127.0.0.1:8000 app:app- Set up systemd:
- Copy
mockercount.serviceto/etc/systemd/system/mockercount.service. - Update
User,Group,WorkingDirectory,Environment, andExecStartpaths to match the new VPS paths/username. - Enable and start:
- Copy
sudo systemctl daemon-reload
sudo systemctl enable mockercount
sudo systemctl start mockercount
sudo systemctl status mockercount- Put a reverse proxy in front of
127.0.0.1:8000(Nginx/Apache) to terminate TLS and serve on ports 80/443.
- Back up:
- The SQLite DB (
coffee_leaderboard.dbif using the default path). - Uploaded images in
static/uploads/. - The
.envfile (secrets/admin credentials). - If you customized
DATABASE_URL, back up the file it points to (e.g.,instance/coffee_leaderboard.db).
- The SQLite DB (
- Safe backup example (from the project root, ideally while the service is stopped):
mkdir -p backups
sqlite3 coffee_leaderboard.db ".backup 'backups/coffee_leaderboard_$(date +%Y%m%d).db'"
tar -czf backups/uploads_$(date +%Y%m%d).tar.gz static/uploads- Restore/move to a new VPS:
- Follow the deploy steps above on the new host.
- Copy data over:
rsync -avz old:/home/ubuntu/mockercount/static/uploads/ static/uploads/
rsync -avz old:/home/ubuntu/mockercount/coffee_leaderboard.db .- Ensure file ownership matches the systemd
User/Group, then restart:
sudo systemctl restart mockercount.
├── app.py
├── requirements.txt
├── static/
│ └── uploads/
├── templates/
├── mockercount.service
└── migrations/