Skip to content

oscarine/oscarine-api

Repository files navigation

OSCARINE-API

CircleCI

Quickstart

This project uses Poetry for managing and installing Python dependencies, make sure you have it installed. After that, you can run the following commands to bootstrap your development environment

  • git clone https://github.com/oscarine/oscarine-api
  • cd oscarine-api
  • python3 -m venv venv
  • source venv/bin/activate
  • poetry install
  • cp .env.example .env
  • uvicorn app.main:app --reload

From now, commands starting with $ are shell commands, # for SQL commands and // for explanatory comments

Setup Postgresql

Run the following commands to setup your database

  • First download and install the postgresql database
$ sudo apt-get update

$ sudo apt-get install postgresql postgresql-contrib libssl-dev
  • Now create the database. For that we first open the psql shell. Go to the directory where your postgres file is stored
// For linux users
$ sudo -u postgres psql

// For macOS users
$ psql -d postgres
  • Create database oscarine_db with owner oscarine
# CREATE USER oscarine WITH PASSWORD 'password';

# CREATE DATABASE oscarine_db WITH OWNER oscarine;
  • Now make user oscarine SUPERUSER
# ALTER USER oscarine WITH SUPERUSER;
  • Now we need extension called postgis (install it from here)
  • We can now create this extension for our database oscarine_db
// Get inside `oscarine_db` shell
$ sudo -u postgres psql -d oscarine_db

# CREATE EXTENSION postgis;

// Now verify postgis extension
# SELECT postgis_full_version();
  • Now, inside our project directory we can run migrations using alembic
$ alembic upgrade head
  • If you have not followed the above commands exactly please edit the .env file accordingly.

During Development

  • Install pre-commit at .git/hooks/pre-commit
$ pre-commit install
  • We can autogenerate revision file whenever we change the database schema
$ alembic revision --autogenerate -m "Your revision message"
  • Then we can apply those changes to the database
$ alembic upgrade head

For contributing to Oscarine-API, please fork the project first and then clone your fork.