FastAPI for Car Shop ERP

coverage

This rest api is a kind of ERP of car shop.
App is available on cloud by https://car-shop-fastapi.herokuapp.com/docs.

Requirements

You'll must have installed:


Setup Project

Create virtual environment

python3 -m venv env

Activating created virtual environment

source env/bin/activate 

Install app dependencies

pip install -r requirements-local.txt 

Running Application

Starting database (postgres:alpine3.14)

docker-compose up

Starting application, run:

uvicorn app.main:app --reload
Obs: It's possible to configure the database by environment variable as:
export DB_URL="postgresql://user-name:password@host-name/database-name"

Acessing on local

The application will get started in http://127.0.0.1:8000

Swagger Documentation: http://127.0.0.1:8000/docs

Redoc Documentation: http://127.0.0.1:8000/redoc

Database Adminer: http://127.0.0.1:9000

  • credentials tinnova/tinnova123(user/password).

If required authentication on routes add headers:

  • token = my-jwt-token
  • x_token = fake-super-secret-token

Testing

For run tests

pytest

For run tests with coverage report

pytest --cov=app app/test/

Development

For update dependencies on requirements.txt, run:
Obs: For production must have extra changes.

  1. Remove version of dataclasses
pip freeze > requirements.txt

Deploy On Heroku

Requirements

Install Heroku Cli

sudo snap install --classic heroku

Deploy

Case is activated automatic deploy for master branch, just commit on master branch,
instead make manual deploy from Heroku Cli, like below

heroku login
heroku git:remote -a car-shop-fastapi
git add .
git commit -m "Deploy on heroku"
git push origin master
git push heroku master

Source Documentation