Football League Simulation & Predictions Dashboard

Go JavaScript CSS HTML

Bu içerik yalnızca İngilizce olarak mevcuttur.

🏆 Football League Simulation & Predictions Dashboard

A high-performance, interactive Football League Simulation and Forecasting application. The project features a Go-powered backend with SQLite storage, a strength-based Poisson match simulation engine, a 10,000-run Monte Carlo championship predictor, and a sleek, premium glassmorphic dark-theme Single-Page App (SPA).


🚀 Key Features

  • Double Round-Robin Schedule: Mathematically balanced 6-week schedule (12 matches total) seeded automatically on startup.
  • Dynamic Standings Calculations: Recalculates Points, Wins, Draws, Losses, and Goal Differences instantly via an aggregate SQL query.
  • Poisson-Distribution Match Simulation: Employs realistic scoring mechanics based on relative team strengths and a home-advantage factor.
  • Monte Carlo Prediction Engine: Simulates the remaining season 10,000 times in milliseconds to calculate precise, live championship probabilities after Week 4.
  • Interactive Score Editing: Type a custom score directly into any match card, and watch the entire league table and predictions update instantly!
  • Premium Glassmorphic UI: Gorgeous dark mode featuring micro-animations, team-colored accent progress bars, and full responsiveness.
  • Zero-Dependency SQLite: Uses a pure Go CGO-free driver (github.com/glebarez/go-sqlite) for compilation and portability on Windows without GCC.

🛠️ Tech Stack

  • Backend: Go (Golang) 1.22+ (using standard HTTP router, go:embed, and standard loggers)
  • Database: SQLite (CGO-free driver)
  • Frontend: Single-Page App (SPA) built with Semantic HTML5, Vanilla CSS3 (Custom properties, grid/flex layouts, glassmorphic filters), and Vanilla JS ES6.
  • Testing: Go unit tests with in-memory SQLite mocks.

📂 Project Structure

├── static/                  # Static Web Assets (Frontend)
│   ├── index.html           # Dashboard HTML5 Skeleton
│   ├── style.css            # Glassmorphic Dark-Theme Stylesheet
│   └── app.js               # UI binding & REST API integrations
├── db.go                    # SQLite database config and embedding migrations
├── models.go                # Domain structs (Team, Match, Standing, Prediction)
├── repository.go            # Data Access Layer & aggregate standings calculation
├── simulation.go            # Poisson-distribution match simulator
├── predictor.go             # Monte Carlo prediction engine (10,000 iterations)
├── main.go                  # API endpoints, CORS support, static router & listeners
├── schema.sql               # Database schemas and double-round robin fixtures seed
└── simulation_test.go       # Comprehensive test suite for services and database

💻 Local Setup & Execution

1. Run Automated Tests

Verify services, standings math, and prediction engine boundaries:

go test -v ./...

2. Start the Server

Build and run the Go server locally:

go run .

Open your browser and navigate to: 👉 http://localhost:8080


☁️ Deployment Guide

You can deploy the entire application as a single self-contained unit to Render, Railway, Fly.io, or any VPS.

  • The backend binary automatically compiles, bundles, and serves the static files inside the static/ directory.
  • This preserves the SQLite league.db file locally, making state persistent and configuration-free.

Option B: Cloudflare Pages (Frontend) + Render/Railway (Backend)

You can split the stack by hosting the static UI on Cloudflare Pages and the Go API backend on Render or Railway. We have equipped the Go server with built-in CORS support to allow cross-origin requests.

1. Deploy Frontend on Cloudflare Pages

  1. Push this repository to GitHub.
  2. In the Cloudflare Dashboard, go to Workers & Pages -> Create Application -> Pages -> Connect to Git.
  3. Select this repository.
  4. In Build settings:
    • Framework preset: None
    • Build command: sed -i "s|%%API_BASE%%|${API_BASE}|g" static/app.js
    • Build output directory: static
  5. Go to the Environment variables tab under your Pages project settings and add:
    • Variable name: API_BASE
    • Value: https://your-go-backend-domain.com (your remote backend URL)
  6. Click Save and Deploy. (Cloudflare will automatically inject your environment variable during compilation!)

2. Deploy Go Backend (Render / Railway)

  1. Deploy the backend to Render/Railway. They will automatically detect the go.mod file and build it.
  2. Set the listening port using PORT environment variable or let it default to 8080.

3. Local/Developer Override (Optional)

If you want to override the API base URL locally without redeploying, the app still supports browser overrides:

  1. Open your browser’s Developer Tools (F12).
  2. Run the following command in the JavaScript Console:
    localStorage.setItem('API_BASE', 'http://localhost:8080');
  3. Clear it by running localStorage.removeItem('API_BASE').

Auto-generated from the GitHub repository.