- Back end API, MVC style
- Heartbeat endpoint for testing & monitoring
- Player modeling
- SQL database with migrations
- Create (and Show, for debugging) endpoint
- Battle initiation
- queued for async processing using redis queue
- Leaderboard implementation
- uses a redis sorted set so this is fast
- Battle processor & battle engine logic, this looked fun, but I didn't get there
- Auth (I like basic auth headers and JWTs for authz policies, can use redis cache to make this fast, bring it into middleware)
- Hosting
- Deployment (and CI/CD)
I might have done more, but I wanted to do things to a reasonable standard and Python isn't my native language. Overall I'm happy with what I achieved; I aimed for extensibility and believe it would be pretty easy to keep working on this application and smooth the rough edges to make it production-ready.
pipenv
– environment & dependency managementgit
- source controlasdf
- language version managementpostman
- API development & QAvscode
– code editormacOS
- Mojave 10.14.6
python
- 3.6.7flask
– web frameworksqllite
– db (not acceptable for production, it's gitignored to make the demo convenient)SQLAlchemy
– ORMflask migrate
- db schema migrationspytest
- test runnerpylint
- (editor integrated) lintingredis queue
- async battle processingredis
- 4.0.2 powers the queue, provides fast access & convenient data structures for leaderboarddotenv
- secrets are injected into the application environment and excluded from the git repo
Install deps (and any required tools not installed):
pipenv install
Establish .env from .env sample:
cp .env.sample .env
Create database & run migrations for dev and test dbs:
pipenv run flask db upgrade
TESTING=1 pipenv run flask db upgrade
You will need to start Redis in whatever way appropriate for your system. I am using RedisApp.
Run tests:
pipenv run pytest
Run the web server:
pipenv run python app.py
Import the postman collection into postman, then try out the requests!