CodeBattle Hackathon

API for October CodeBattle Hackathon.

Live Demo

API docs: http://51.250.44.9/api/v1/docs

Stack

Starlite, SQLAlchemy, Alembic, Postgres, Redis, Traefik

Configuration

Docker containers:

  1. server
  2. db
  3. redis
  4. traefik

docker-compose files:

  1. docker-compose.yml - for local development.
  2. tests/functional/docker-compose.yml - for functional tests.

To run docker containers, you need to create a .env file in the root directory.

.env example:

cp .env.example .env

Start project:

Locally:

docker-compose build
docker-compose up

Development

Sync environment with requirements.txt / requirements.dev.txt (will install/update missing packages, remove redundant ones):

make sync-requirements

Compile requirements.*.txt files (have to re-compile after changes in requirements.*.in):

make compile-requirements

Use requirements.local.in for local dependencies; always specify constraints files (-c ...)

Example:

# requirements.local.txt

-c requirements.txt

ipython

Tests

Run unit tests (export environment variables from .env file):

export $(echo $(cat .env | sed 's/#.*//g'| xargs) | envsubst) && make test

To run functional tests, you need to create .env in ./tests/functional directory

.env example:

cd ./tests/functional && cp .env.example .env

Run functional tests:

cd ./tests/functional && docker-compose up test

Makefile recipe:

make dtf

Code style:

Before pushing a commit run all linters:

make lint

pre-commit:

pre-commit installation:

pre-commit install

Documentation

OpenAPI 3 documentation:

  • ${PROJECT_BASE_URL}/api/v1/docs - Swagger
  • ${PROJECT_BASE_URL}/api/v1/docs/redoc - ReDoc
  • ${PROJECT_BASE_URL}/api/v1/docs/openapi.json - OpenAPI json