A Node.js + REST API to simulate football matches, manage teams, players, and match events. Uses MySQL for data storage.
- CRUD operations for teams and players
- Match simulation and history
- REST API to simulate football matches
- Node.js
- MySQL
git clone https://github.com/yourusername/Football-simulation.git
cd Football-simulationMake sure that the version is 18+
npm installcd football-skripts
cp .env.example .envEdit .env with your DB credentials.
Make sure MySQL is running - sudo systemctl status mysql
If not:
sudo systemctl start mysqlThen execute the football_db to create tables:
cd ..
mysql -u root -p < football_db.sqlnode api.jsServer will be available at http://localhost:3000
To test API, can be used POSTMAN.
| Method | URL | Description |
|---|---|---|
| GET | /api/teams |
List all teams |
| POST | /api/teams |
Create a new team |
| PUT | /api/teams/:id |
Update team info |
| DELETE | /api/teams/:id |
Delete team |
| GET | /api/teams/:id/matches |
List team matches |
| GET | /api/players/:id |
Get player's name and team name |
| Method | URL | Description |
|---|---|---|
| GET | /api/matches |
List matches |
| POST | /api/matches |
Add a new match |
| PUT | /api/matches/:id |
Update match info |
| DELETE | /api/matches/:id |
Delete a match |
| Method | URL | Description |
|---|---|---|
| GET | /api/teams/:id/players |
List all players in an excect team |
| POST | /api/teams/:id/players |
Add player to team |
| PUT | /api/players/:id |
Update player info |
| DELETE | /api/players/:id |
Delete a player |
{
"name": "AC Sparta",
"country": "Czech Republic"
}{
"name": "Sparta Praha",
"country": "Czech Republic"
}{
"home_team": 1,
"away_team": 2,
"match_date": "2025-05-01"
}