The NRL Tipping Application is a project designed to create a user-friendly tipping platform for the Australian NRL competitions, including NRL, NRL Women's Championship, State of Origin, and State of Origin Women's. The application allows users to view fixtures, team details, and match outcomes and place tips on various games. The backend is built with Go, and the frontend uses Vue.js, TailwindCSS, and Pinia.
Ensure you have Docker installed as the best way to mimic the live environment is via containerisation. First it would be best to setup the database, which can be down by pulling it up first and using migrate. The following is a single script to set up and run:
# Build the whole project
docker compose build
# Setup the database and migrate to the current version
docker compose up -d db
migrate -source 'file:./backend/internal/db/migration' -database 'postgres://postgres:password@localhost:5432/nrl_tipping?sslmode=disable' up
# Run the whole project
docker compose up
This will be a blocking session unless you add the -d
flag to daemonise it. Some form of testing stage will be added at some point soon to ensure everything works accordingly.
If you want to add a new table or modify existing tables, you will need to create a new database migration. For example, if you want to add a new field to the teams table called city, you can do the following:
# Generate new migration files
migrate create -ext sql -dir backend/internal/db/migration -seq add_team_city
Then, modify the generated migration files:
-- file: backend/db/internal/migration/000003_add_team_city.up.sql
ALTER TABLE teams
ADD COLUMN city VARCHAR(255);
-- file: backend/db/internal/migration/000003_add_team_city.down.sql
ALTER TABLE teams
DROP COLUMN city;
After modifying the migration files, run the following command to apply the migration:
migrate -source 'file:./backend/internal/db/migration' -database 'postgres://postgres:password@localhost:5432/nrl_tipping?sslmode=disable' up
This project uses sqlc to generate type-safe Go code from SQL queries, avoiding the use of traditional ORMs and maintaining better control over database interactions. To add a new query, follow these steps:
.sql
files located in backend/internal/db/query
. For example, to get a fixture by its ID:-- file: backend/internal/db/query/fixtures.sql
-- name: GetFixtureByID :one
SELECT *
FROM fixtures
WHERE id = $1;
sqlc generate
in the backend directory of the project to generate Go code for the new query:cd backend
sqlc generate
This command will generate new Go functions based on your SQL queries in the backend/internal/db
directory. Make sure to run sqlc generate
every time you modify the .sql
files.
The NRL Tipping Application backend provides several API endpoints for interacting with competitions, fixtures, and match details.
Get Competitions
GET /api/v1/competitions
Get All Fixtures
GET /api/v1/fixtures
Get Fixtures by Competition ID
GET /api/v1/fixtures/{competition_id}
competition_id
(required): The ID of the competition.Get Match Details
GET /api/v1/fixtures/{competition_id}/{match_id}
competition_id
(required): The ID of the competition.match_id
(required): The ID of the match.Here are some example commands using curl to interact with the API.
# Get Competitions
curl -X GET http://localhost:8080/api/v1/competitions
# Get All Fixtures
curl -X GET http://localhost:8080/api/v1/fixtures
# Get Fixtures by Competition ID
# - 111 NRL
# - 161 NRLW
# - 116 State of Origin
# - 156 Womens State of Origin
curl -X GET "http://localhost:8080/api/v1/fixtures/111"
# Get Match Details
curl -X GET "http://localhost:8080/api/v1/fixtures/111/20241112610"
To contribute to this project, please fork the repository and create a pull request with your changes. Ensure that all new code follows the project’s coding standards and is well-documented.