Skip to main content

Football bet rest/graphql server

Project description

Yak-toto

PyPI Python Versions codecov 🔐 CodeQL Testing

Requisites

  • Ubuntu 22.04
  • MySQL 8.0.30

How to build the project

Database

Install and start mysql server on port 3306. Add a database named yak_toto. In root folder, create a dotenv file named .env and fill your MySQL user name, password and database. When backend start, this configuration is automatically loaded.

MYSQL_USER_NAME=my_user_name
MYSQL_PASSWORD=my_password
MYSQL_DB=my_database_name

You can also set MySQL port by adding MYSQL_PORT=my_port to .env file. If not set, it will be 3306 by default.

Backend

Run your project in a Python env is highly recommend. You can use venv python module using the following command:

uv venv
. .venv/bin/activate

Fetch all packages using pip with the following command:

uv pip install -r requirements.txt

Before starting the backend, add JWT_SECRET_KEY and JWT_EXPIRATION_TIME in .env same as the MySQL user name and password. As login system is using JSON Web Token, a secret key is required and an expiration time (in seconds). To generate one, you can use the python built-in secrets module.

>>> import secrets
>>> secrets.token_hex(16)
'9292f79e10ed7ed03ffad66d196217c4'
JWT_SECRET_KEY=9292f79e10ed7ed03ffad66d196217c4
JWT_EXPIRATION_TIME=1800

Also, automatic backup can be done through yak_server/cli/backup_database script. It can be run using yak db backup.

Finally, fastapi needs some configuration to start. Last thing, for development environment, debug needs to be activated with a additional environment variable:

DEBUG=1

And then start backend with:

uvicorn --reload yak_server:create_app --factory

Data initialization

To run local testing, you can use the script create_database.py, initialize_database.py and create_admin.py located in yak_server/cli folder. To select, set COMPETITION environment variable in .env. It will read data from yak_server/data/{COMPETITION}/.

Testing

To set up test, please add a MySQL database named yak_toto_test. It will contain all the records created during unit tests. This database is cleaned everytime you run test. That's why a different database is created to avoid deleting records you use for your local testing.

Yak-server is using pytest to run tests.

Profiling

You can profile by adding this line in the .env

PROFILING=1

Be careful, you need to be in debug mode to activate the profiling. In production mode, adding the environment variable will have no impacts.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yak_server-0.45.0.tar.gz (77.3 kB view details)

Uploaded Source

Built Distribution

yak_server-0.45.0-py3-none-any.whl (80.6 kB view details)

Uploaded Python 3

File details

Details for the file yak_server-0.45.0.tar.gz.

File metadata

  • Download URL: yak_server-0.45.0.tar.gz
  • Upload date:
  • Size: 77.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for yak_server-0.45.0.tar.gz
Algorithm Hash digest
SHA256 c0897de1da7eb6c463e71e686fb2408c047e5f031065e581f83137ae4db4c69f
MD5 f163e31fb0a84e88256dad8472830189
BLAKE2b-256 f3d1cfcfb95e551918a2c7dab2cb47ba47eb48969430f58816db9302478d3c0b

See more details on using hashes here.

File details

Details for the file yak_server-0.45.0-py3-none-any.whl.

File metadata

  • Download URL: yak_server-0.45.0-py3-none-any.whl
  • Upload date:
  • Size: 80.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for yak_server-0.45.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9d7f5ce3512b6ac9ef2c0f4e4d934d17e308ff1d329513d4a0daf5662515ff6
MD5 77bbc8756952ec6b2a621ae7634f81a8
BLAKE2b-256 e2b47e61cc85f9dbf6b90fd94fe65e7101a8c46b5210ea0f103ad0609b0a4a9b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page