Skip to content

skatesham/fastapi-bigger-application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Bigger Application for Car Shop ERP

coverage

This REST API serves as an ERP system for a car shop.

Requirements

Ensure you have the following installed:


Setup Project

  1. Create a virtual environment:

    python3 -m venv env
  2. Activate the virtual environment:

    source env/bin/activate
  3. Install app dependencies:

    pip install -r requirements.txt

Running the Application

  1. Start the database (PostgreSQL:alpine3.14):

    docker-compose up
  2. Start the application:

    uvicorn app.main:app --reload

Note:

You can configure the database using an environment variable:

export DB_URL="postgresql://user-name:password@host-name/database-name"

Accessing the Application Locally

If required, add the following headers for authentication on routes:

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

Testing

  • Run tests:

    pytest
  • Run tests with coverage report:

    pytest --cov=app app/test/

Development

To update dependencies in requirements.txt:

  1. Remove the version constraint for dataclasses.
  2. Run:
    pip freeze > requirements.txt

Deploy on Heroku

Requirements

Install Heroku CLI

sudo snap install --classic heroku

Deployment

If automatic deploy is enabled for the master branch, simply commit to the master branch. Otherwise, deploy manually using the Heroku CLI as follows:

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