Skip to content

vutuanphan/aewc26

Repository files navigation

AEWC26

AEWC26 — friends' World Cup 2026 betting pool

Self-hosted, peer-to-peer points betting for your group of friends. Run a private pool, place head-to-head bets with play-money points, and let the results settle everything automatically. One Go binary, SQLite, no database server, no signups for strangers.

CI License: MIT Go

What is this?

AEWC26 is a tiny self-hosted web app for betting against each other (not a bookmaker) on World Cup 2026 matches, using points the admin hands out. One person posts a wager on a match; a friend takes the opposite side for the same stake; when the match ends, the pot is paid out automatically from the full-time score. It ships with all 48 teams and 104 fixtures pre-loaded.

It is intentionally small and private: closed roster (the admin creates accounts), no email required, login by username. Perfect for a group chat of friends, a family, or an office.

Features

  • ⚔️ Head-to-head betting — creator stakes N points on one side, one taker matches N on the opposite side. Winner takes the pot.
  • 🎲 Four bet types — 1x2 (win/draw/lose), Asian handicap (including quarter lines → half-win / push / half-loss), over/under total goals, and correct score.
  • 🔴 Live (in-play) betting — keep posting and taking bets while a match is on, with the running score shown. When a goal is scored, every still-open (un-taken) offer is automatically voided and refunded so nobody can pick off a stale price.
  • 🤖 Automatic settlement — results sync in and matched bets pay out with no manual work. Push/void refunds, un-taken bets refunded at kickoff.
  • 👛 Wallet + full ledger — every grant, stake, refund and payout is recorded; each player has a transaction history page.
  • 🏆 Live leaderboard by current balance.
  • 💬 Group chat for trash talk.
  • 📈 Bookmaker reference odds (optional, via The Odds API) shown right in the create-bet form for 1x2 / handicap / over-under.
  • 🛠️ Admin panel — create players, reset passwords, grant/top-up points, enter or correct results.
  • 🌐 Bilingual — English (default) + Vietnamese, switchable per device.
  • 📱 Mobile-first dark UI.

Screenshots

Add your screenshots to docs/ and reference them here.

Quick start

Requires Docker.

git clone https://github.com/vutuanphan/aewc26.git
cd aewc26
cp .env.example .env
# edit .env: set AEWC_ADMIN_PASSWORD (and ODDS_API_KEY if you have one)
docker compose up --build -d

Open http://localhost:8091, log in as admin with the password you set, then go to Admin → Players to create accounts for your friends.

Want to try it instantly with sample players? Set AEWC_SEED_DEMO=1 in .env before the first run — it creates demo1demo4 (password demo1234).

Run from source (no Docker)

go run .            # listens on :8090, DB at ./data/aewc.db (set AEWC_DB)

Configuration

All configuration is via environment variables (see .env.example):

Variable Default Notes
HOST_PORT 8091 Host port (compose); app listens on 8090 inside.
AEWC_BRAND AEWC26 Name shown across the UI.
AEWC_START_BALANCE 100000 Starting wallet for new players.
AEWC_ADMIN_PASSWORD (random) Admin password; random + logged if unset.
AEWC_SEED_DEMO 0 1 seeds 4 demo players (password demo1234).
AEWC_TZ Asia/Ho_Chi_Minh IANA timezone for kickoff display.
AEWC_DB /data/aewc.db SQLite path.
ODDS_API_KEY (empty) The Odds API key — enables reference odds + result sync.

How settlement works

Bets settle on the full-time (90') score. The creator's net result is a fraction in {-1, -0.5, 0, 0.5, 1}; the pot (2 × stake) is always fully distributed:

Bet type Creator wins when
1x2 the chosen outcome (home / draw / away) happens
Asian handicap (backed goals − other goals) + line > 0 (quarter lines split across the two adjacent half-lines)
Over/Under total goals beat the line on the chosen side

The math lives in internal/app/betsmath.go and is covered by betsmath_test.go.

Data & results

  • Teams and fixtures are seeded from public-domain openfootball data (internal/app/seeddata/).
  • Live + final scores come from ESPN's free public scoreboard by default (AEWC_RESULTS_SOURCE=espn) — no key, no quota. Switch to oddsapi to use The Odds API /scores instead. The admin can also enter/correct results in /admin.
  • Bookmaker reference odds (optional) come from The Odds API /odds when ODDS_API_KEY is set — shown in the create-bet form, refreshed ~every 6h.

Tech

Go 1.26 · net/http (stdlib router) · html/template server-rendered UI · pure-Go SQLite (modernc.org/sqlite, no CGO) · bcrypt sessions · vanilla JS. Everything (templates, static assets, seed data, timezone DB) is embedded into a single static binary.

Development

go vet ./...
go test ./...
go build .

See CONTRIBUTING.md.

Security

This is play-money among friends, but it still handles auth. See SECURITY.md. Highlights: bcrypt password hashing, server-side sessions, CSRF double-submit tokens, parameterized SQL. Keep .env private and put the app behind HTTPS (e.g. nginx/Caddy).

Roadmap

  • Corner & card markets with automatic settlement (needs a stats provider such as API-Football, since The Odds API doesn't return corner/card results).
  • Light theme + PWA install.
  • More languages.

Credits

License

MIT © Phan Vu Tuan

About

Self-hosted World Cup 2026 friends betting pool — single Go binary + SQLite, P2P points betting (1x2 / Asian handicap / over-under) with automatic settlement, leaderboard, chat & bilingual UI.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors