Standalone REST web service to generate Fantasy MMOG Leaderboard.
Leaderboards are the most accessed screens in any MMOGs. What makes leaderboard calculation little complex than any other rank-based leaderboards is that two or more players can share the same rank. The ranks of the players holding the same score should remain the same and the next succeeding rank to be allocated to the next player and so on.
In this project, we are using the SQL rank function to calculate user ranks.
The OVER()
clause In the SQL RANK function is used to define that the entire table is being considered for calculation of the rank. The ORDER BY
clause is used to sort the results in descending order.
To see the database queries being generated while fetching data, set database.logmode: true
in the config.yml file.
- Go with minimum version 1.13
- make
- PostgreSQL
# Get the code
git clone https://github.com/souvikmaji/leaderboard
cd leaderboard
# initialize database and tables
make init
# Build and run
make
The application follows 12 factor principals for configuration management. Configurations are read in the following manner config.yml > .env > Exported Enviroment variables > Program Flags
.
Visit: <127.0.0.1:8000>
During development use the autoreload server
make devrun
- Golang
- GNU Make
- Gorilla Mux as the HTTP router and URL matcher
- Gorm as ORM
- Viper for externalized configuration
- PostgreSQL as the database
- Datatables as the UI framework to display the leaderboard
- CRUD apis for game
- CRUD apis for users
- Integrate validators
- Use datatable sorting feature
- Datatable filter by game id/ name
- User auth apis
- Gameplay apis
- DB script sample size from flag
- Use redis for db
- Benchmark with a larger dataset
- Read database credentials at app start for the first time.
- Integrate Swagger
- AutomaticEnv not working
- Add logger
- Hosting
- Unit tests