Skip to content

maxaitel/mockercount

Repository files navigation

Coffee Leaderboard

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.

Features

  • Leaderboard with coffee counts and rankings
  • Photo submissions stored on disk
  • Admin-protected moderation dashboard
  • Modern, responsive UI using Tailwind CSS

Prerequisites

  • 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

Environment

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

Local setup

  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Initialize the database (runs migrations):
flask --app app db upgrade

The helper init_db.py will drop all tables; avoid it when you have real data.

  1. Run the app:
python app.py
  1. Open http://localhost:5000

Deploying to a VPS (Gunicorn + systemd)

  1. Clone the repo onto the server (e.g., /home/ubuntu/mockercount) and add the .env above with production values.
  2. Create a virtual environment and install deps:
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
  1. Prepare storage and database:
mkdir -p static/uploads
flask --app app db upgrade
  1. Smoke test:
venv/bin/gunicorn --bind 127.0.0.1:8000 app:app
  1. Set up systemd:
    • Copy mockercount.service to /etc/systemd/system/mockercount.service.
    • Update User, Group, WorkingDirectory, Environment, and ExecStart paths to match the new VPS paths/username.
    • Enable and start:
sudo systemctl daemon-reload
sudo systemctl enable mockercount
sudo systemctl start mockercount
sudo systemctl status mockercount
  1. Put a reverse proxy in front of 127.0.0.1:8000 (Nginx/Apache) to terminate TLS and serve on ports 80/443.

Backups and moving servers

  • Back up:
    • The SQLite DB (coffee_leaderboard.db if using the default path).
    • Uploaded images in static/uploads/.
    • The .env file (secrets/admin credentials).
    • If you customized DATABASE_URL, back up the file it points to (e.g., instance/coffee_leaderboard.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:
    1. Follow the deploy steps above on the new host.
    2. Copy data over:
rsync -avz old:/home/ubuntu/mockercount/static/uploads/ static/uploads/
rsync -avz old:/home/ubuntu/mockercount/coffee_leaderboard.db .
  1. Ensure file ownership matches the systemd User/Group, then restart:
sudo systemctl restart mockercount

File structure

.
├── app.py
├── requirements.txt
├── static/
│   └── uploads/
├── templates/
├── mockercount.service
└── migrations/

About

a website we are making to track coffees

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors