Docs (OpenAPI format)
In order to run without containers, running postgresql database service locally and using python executable also works
Create .env
file with contents:
POSTGRES_USERNAME=postgres
POSTGRES_PASSWORD=pw
POSTGRES_HOST=db
In order to run tests:
docker-compose run api pytest --cov=. --cov-report=html
With the postgresql server running on port 5432:
pip install -r requirements.txt
pytest --cov=. --cov-report=html
Linting is done through pyright and for formatting use yapf.
Games are going to be fixed and added based on the business needs, warzone is going to be the first implementation. At first there will only be one platform, probably cross-play stemming from battle.net
If it would end up being crypto-based, there could be a L2 Arbitrum smart contract to keep track of everything safely on chain.
Below are some loose thoughts from previous meetings with the stakeholders.
contract Premiere {
// this would probably require merkle proofs for checking the players
struct Tournament {
uint entryPrice;
uint currentPlayerId;
uint startDate;
uint playerCap;
uint winnerAddress;
}
mapping(uint => Tournament) public tournaments;
function joinTournament(uint tournamentId) {
Tournament tournament = tournaments[tournamentId];
require(tournament.currentPlayerId < tournament.playerCap);
// ...
}
function finalise(Tournament t, address winner) external onlyAuthorized {
// withdraw(winnerAddress);
// withdraw to the winner, write the tournament as done
}
function getBestPlayer() external view {
// storage is quite expensive, but a function that loops through
// and only reads could be very cheap computation-wise
}
}
FastAPI with PostgreSQL database, with user authentication and endpoints for CRUD operations on tournaments and games. Running on Terraform-provisioned Linode Kubernetes Engine cluster with NGINX node balancing with TLS.
After provisioning with terraform (requires the terraform.tfvars
file) and
getting the kubeconfig.yml
, let's expose the cluster with an ingress:
helm upgrade --install ingress-nginx ingress-nginx \
--repo https://kubernetes.github.io/ingress-nginx \
--namespace ingress-nginx --create-namespace
Then get the ipv4 of the ingress and point the domain (in this case
api.premiere.sh
) to it. Note that the hostname has to be included in the
manifest.yml
. Next, get cert:
kubectl apply -f \
https://github.com/cert-manager/cert-manager/releases/download/v1.8.0/cert-manager.yaml
This should leave to api.premiere.sh
being accessible both via HTTP/HTTPS
and returning 503 status from nginx.
Having exposed the cluster, deploy the resorces.
.env
file contents:
POSTGRES_USERNAME=***
POSTGRES_PASSWORD=***
POSTGRES_HOST=***
SECRET_KEY=***
where the SECRET_KEY
is an openssl rand -hex 32
hash.
kubectl create secret generic premiere-secrets --from-env-file=./.env
kubectl apply -f manifest.yml