No description
  • Python 53.6%
  • HTML 40.7%
  • JavaScript 5.4%
  • Mako 0.2%
  • Dockerfile 0.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jeff Miller baad4266ae Merge feature/team-computed-avg: fix team page showing wrong player averages
Team page roster now shows computed rolling averages (math.ceil) instead of
raw starting_avg, matching what player detail pages display.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-12-02 13:10:42 -05:00
.claude Update documentation and remove fly.toml 2026-12-01 22:21:09 -05:00
anti-slop Fix accessibility and contrast issues from antislop audit 2026-10-19 12:51:52 -04:00
docs Update docs to reflect team page computed averages fix 2026-12-02 13:09:31 -05:00
migrations Add player nickname support for OCR score sheet matching 2026-10-23 02:30:10 -04:00
static Add favicon and PWA support for home screen pinning 2026-10-09 00:46:16 -04:00
templates Fix team page showing starting avg instead of computed avg 2026-12-02 13:08:17 -05:00
.dockerignore Add README, Dockerfile, and docker-compose for local and production deployment 2026-09-03 11:31:23 -04:00
.env.example Document OCR score scanning feature and API key configuration 2026-10-22 10:34:27 -04:00
.gitignore Add graphify-out/ to .gitignore 2026-10-19 13:44:14 -04:00
admin_roster.py Add rate limiting with stricter limits on OCR, login, and search endpoints 2026-11-28 12:25:06 -05:00
admin_scores.py Add round-robin schedule generator with multi-week support 2026-12-01 19:09:30 -05:00
admin_season.py Add bounds validation to season import 2026-11-28 12:49:35 -05:00
admin_users.py Split admin_routes.py into four focused modules 2026-11-03 20:26:16 -05:00
app.py Add pool_pre_ping to handle Postgres connection drops gracefully 2026-11-30 23:16:36 -05:00
auth.py Split app.py into focused modules 2026-11-03 15:06:13 -05:00
backup.py Add request logging, auth/admin audit trail, and FLASK_ENV support 2026-09-03 09:35:30 -04:00
CLAUDE.md Add project documentation: architecture, decisions, status, security audit 2026-11-28 11:37:07 -05:00
docker-compose.yml Set FLASK_ENV=production on default Docker service 2026-11-28 12:49:10 -05:00
docker-entrypoint.sh Add set -e to docker entrypoint to fail on migration errors 2026-10-16 20:24:02 -04:00
Dockerfile Add match completion flag to control when scores count 2026-10-16 17:13:34 -04:00
export_to_json.gs Refactor export script to support library deployment 2026-09-16 17:16:28 -04:00
helpers.py Show week-number-only averages on team trend chart 2026-12-01 21:50:54 -05:00
import_2025.py
import_from_sheets.py Import older seasons (2020-2023) and fix chart for Week 1 absences 2026-09-02 19:58:52 -04:00
models.py Add player nickname support for OCR score sheet matching 2026-10-23 02:30:10 -04:00
README.md Update documentation and remove fly.toml 2026-12-01 22:21:09 -05:00
requirements.txt Add rate limiting with stricter limits on OCR, login, and search endpoints 2026-11-28 12:25:06 -05:00
seed_data.py
views.py Fix team page showing starting avg instead of computed avg 2026-12-02 13:08:17 -05:00

Dart League

A web app for managing a recreational dart league: seasons, teams, rosters, weekly match scores, standings, and player statistics.

Features

Scheduling and scoring

  • Round-robin schedule generator with multi-week tiling and bye-week display
  • Per-game score entry with absent handling and handicaps
  • OCR score scanning: photograph a paper score sheet, fill the form via Anthropic Claude Sonnet or Google Gemini Flash
  • Match completion flag: incomplete matches are excluded from standings and stats
  • Absence adjustment: percentage of average or fixed deduction, per season
  • Per-game score overrides
  • Board number tracking

Standings and stats

  • Standings with half-season tabs (1st half / 2nd half / overall)
  • Player averages, high games, and handicaps
  • Team average trend chart on the team detail page
  • Print view with QR code

Roster and data

  • Mid-season player moves with score reassignment
  • Player merge with undo
  • Season player pool and bulk CSV upload (players, scores, matches)
  • Season import/export (dart-league-v1 JSON format)

Platform

  • Google OAuth login with role-based access
  • PWA support (Add to Home Screen)
  • Mobile-first responsive UI with dark mode

Tech Stack

  • Backend: Flask, SQLAlchemy, Flask-Migrate (Alembic), Flask-Login
  • Auth: Google OAuth via Authlib
  • Frontend: Jinja2, Tailwind CSS (CDN), HTMX
  • Database: SQLite (default), PostgreSQL, or MariaDB/MySQL via DATABASE_URL

Quick Start

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
# Edit .env: set SECRET_KEY and Google OAuth credentials
python app.py

App runs at http://localhost:5555. Run flask db upgrade first if the database is new.

Docker

cp .env.example .env   # edit SECRET_KEY and Google OAuth credentials
docker compose up -d
Profile Command Stack
Default docker compose up -d App + SQLite. Database persists in the db-data volume.
Production docker compose --profile production up -d App on gunicorn (4 workers) + Postgres 16.
  • Migrations run automatically on container start. If a migration fails, the container does not start.
  • Image: sithadmin/dart-league on DockerHub.
  • Additional volumes: backups and logs.

Environment Variables

Variable Default Description
SECRET_KEY dev-secret-change-me Flask session secret. Required in production.
GOOGLE_CLIENT_ID — Google OAuth client ID
GOOGLE_CLIENT_SECRET — Google OAuth client secret
DATABASE_URL sqlite:///dartleague.db Database connection string
PORT 5555 Host port
FLASK_ENV development development or production
ANTHROPIC_API_KEY — Enables OCR via Claude Sonnet (preferred if both keys are set)
GEMINI_API_KEY — Enables OCR via Gemini Flash
LOG_FILE — Log file path (omit for console only)
BACKUP_DIR backups Backup output directory
MAX_BACKUPS 10 Backups to keep

Database

# PostgreSQL
DATABASE_URL=postgresql://user:pass@localhost:5432/dartleague

# MariaDB / MySQL (via pymysql)
DATABASE_URL=mysql+pymysql://user:pass@localhost:3306/dartleague
flask db migrate -m "description"   # generate a migration
flask db upgrade                    # apply migrations
python backup.py                    # back up (SQLite copy, pg_dump, or mysqldump)

Scoring Rules

  • Team average: sum of each player's average, each rounded up (math.ceil) separately.
  • Handicap: when team averages differ by more than 2, the lower team gets round(0.75 × difference) added to each game.
  • Standings: sorted by wins, then total points.
  • Maximum: 81 points per player per game.

Auth and Roles

  • Google OAuth only. No local passwords.
  • Roles: pending, member, admin. New users start as pending.
  • The first user to sign in becomes admin.
  • /dev-login signs in as the first admin when FLASK_ENV=development.

Project Structure

app.py                — Flask app wiring, config, OAuth, error handlers
admin_season.py       — Dashboard, season CRUD, import/export
admin_roster.py       — Teams, players, bulk uploads, merge
admin_scores.py       — Weeks, matches, schedule generator, OCR, score entry
admin_users.py        — Weeks list, user management
helpers.py            — Averages, handicaps, standings, match scores
auth.py               — Access control decorators
views.py              — Public routes
models.py             — SQLAlchemy models
backup.py             — Database backup utility
seed_data.py          — Development seed data generator
import_from_sheets.py — Google Sheets markdown export importer
export_to_json.gs     — Google Apps Script sheet exporter
templates/            — Jinja2 templates (admin/ for admin pages)
static/               — SVG favicon and PWA manifest
migrations/           — Alembic migration scripts
docs/                 — Design docs
Dockerfile, docker-compose.yml, docker-entrypoint.sh

Docs

Testing

There is no test suite. Verify changes on the dev server.