Skip to content
/ osb Public

Backend repo for opensports.ai | Cricket Insights through Natural Language

Notifications You must be signed in to change notification settings

anipeas/osb

Repository files navigation

opensports_backend (osb)

Local Setup

Repo

  • Make sure you have access to the repo and you have the required ssh keys setup for cloning.

  • Clone the repo

git clone https://github.com/Anirudh58/osb.git

Homebrew.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • add brew to your $PATH
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/anip/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

Environment

  • Create a conda environment
conda create -n os_backend python=3.9
  • Install all requirements
pip install -r requirements.txt

Database

  • Install postgresql
brew install postgresql@15
  • Start postgresql
brew services start postgresql@15
  • Create the opensports database
createdb osdb
  • Create a local user for yourself.
createuser --interactive
  • Edit alembic.ini file to point to the correct database url.
sqlalchemy.url = postgresql://<username>:<password>@localhost:5432/osdb
  • Apply migrations. Make sure you have the latest code pulled from the repo. All migration versions reside in the alembic/versions folder.
alembic upgrade head

Scripts

  • [Recommended] Run the following script to refresh all data.
cd osb
sh scripts/cricket/refresh.sh
  • Run the following script to refresh the player data. If you want to completely wipe and repopulate, set wipe_and_repopulate to True in the script.
cd osb
PYTHONPATH=. python scripts/cricket/refresh_players.py
  • Run the following script to refresh the match data. If you want to completely wipe and repopulate, set wipe_and_repopulate to True in the script. Make sure the player data is refreshed before running this script.
cd osb
PYTHONPATH=. python scripts/cricket/refresh_matches.py
  • Run the following script to refresh the match data. If you want to completely wipe and repopulate, set wipe_and_repopulate to True in the script. Make sure the player data is refreshed before running this script.
cd osb
PYTHONPATH=. python scripts/cricket/refresh_innings.py

Server

  • This will start the backend server on port localhost:8000.
uvicorn main:app --reload
  • Use postman/insomnia to test the endpoints locally.

About

Backend repo for opensports.ai | Cricket Insights through Natural Language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages