Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

⚽ Football League Simulator

A Laravel + Vue.js project that simulates a mini football league with:

  • Standings table (team points, goals, goal difference)
  • Match results by week
  • Championship prediction table (after Week 4)
  • Interactive controls: Play Next Week, Play All, Reset
  • Fully OOP structured backend with clean separation of models, controllers, and services
  • Frontend styled with vanilla CSS + Vue (no Tailwind dependency)

🚀 Features

  • Step-by-step simulation: Play one week at a time or run the full season automatically.
  • Sequential Play All: "Play All" runs weeks sequentially with visual delays (500ms between weeks).
  • Dynamic league standings: Updates live as matches are played with P/W/D/L tracking.
  • Realistic championship prediction: Probabilities are recalculated after Week 4.
  • Reset button: Restart the entire league instantly.

🛠️ Tech Stack

  • Backend: Laravel 11
  • Frontend: Vue.js 3 with Vite
  • Database: SQLite (lightweight, auto-configured)
  • Styling: Vanilla CSS

📂 Project Structure

shin-test/
├── app/
│   ├── Http/Controllers/LeagueController.php   # Controller delegates to LeagueService
│   ├── Models/Team.php                         # Team model
│   ├── Models/MatchModel.php                   # Match model
│   └── Services/
│       ├── LeagueService.php                   # Orchestrates simulation & predictions (sequential playAll)
│       ├── MatchSimulator.php                  # Strength-based match simulation
│       ├── StandingsCalculator.php             # Computes standings with P/W/D/L tracking
│       └── PredictionEngine.php                # Probability engine
├── config/
│   └── league.php                              # League config (prediction threshold, score variation)
├── resources/
│   ├── js/components/LeagueApp.vue             # Vue.js component with async Play All
│   ├── views/league/index.blade.php            # Blade entry point
│   └── css/league.css                          # Styling
├── routes/web.php                              # Routes definition
└── tests/                                      # Unit & feature tests

⚙️ Installation

1. Clone the repo

git clone https://github.com/ShinTruong205/insider-test.git
cd insider-test

2. Install PHP dependencies

composer install

3. Install Node.js dependencies

npm install

4. Configure environment

cp .env.example .env
php artisan key:generate

Set database to SQLite in .env:

DB_CONNECTION=sqlite
DB_DATABASE=database/database.sqlite

Create the SQLite file:

mkdir -p database
touch database/database.sqlite

5. Run migrations

php artisan migrate

6. Build assets

npm run build

7. Start the dev server

php artisan serve
npm run dev

Now visit: http://127.0.0.1:8000/league 🎉


🧪 Running Tests

php artisan test

Deterministic tests / runs (optional)

Set a seed to make simulated results reproducible:

LEAGUE_RNG_SEED=42

Then clear config cache and run tests:

php artisan config:clear
php artisan test

🐳 Docker (optional)

Run the stack:

docker-compose up --build -d

Run tests inside container:

docker-compose run --rm test

App will be available at http://localhost:8080/league.

To enable deterministic runs in containers:

docker-compose exec app sh -lc 'echo "LEAGUE_RNG_SEED=42" >> .env && php artisan config:clear'

👨‍💻 Author

Developed by Shin — PHP/Laravel Developer

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages