An online type racer, but with code. Powered by Vite + React, Flask, and socketio.
$ docker compose up --buildThen go to http://localhost:8080.
(the GIF may take a few seconds to load)
The project uses integration tests in tests/tests.py with pytest.
- API coverage (
requests): game creation, game fetch, and game list endpoints. - Worker/socket coverage (
python-socketio): player join flow, progress updates, finish events, and end-game event. - Database checks (
psycopg): verifies game records are created and deleted correctly. - Isolation: an
autousepytest fixture clears thegamestable after each test.
The tests run against real containers (api, worker, and postgres) through Docker Compose.
Run only the test stack (and required dependencies):
$ docker compose up --build --abort-on-container-exit --exit-code-from tests testsWhat this does:
- Builds the
testsimage fromtests/Dockerfile. - Starts dependency services (
api,worker,postgres) fromcompose.yaml. - Waits briefly (
DELAY_SECONDS) and executespytestinside thetestscontainer. - Returns the test container exit code as the overall command exit code.
Optional cleanup after a run:
$ docker compose down -v --remove-orphansGitHub Actions workflow: .github/workflows/tests.yml
- Trigger: every push to
main. - Purpose: execute tests
If tests fail, the workflow fails and the commit to main is marked as failed.
The API service reads these variables:
USE_AI: enables/disables AI-generated race code.- Set to
trueto generate code with OpenAI. - Any other value (or unset) falls back to built-in sample snippets.
- Set to
OPENAI_API_KEY: required only whenUSE_AI=true.- This is your OpenAI API key used by the API container to call the OpenAI API.
Example (.env):
USE_AI=true
OPENAI_API_KEY=your_openai_api_key_here
