This REST API serves as an ERP system for a car shop.
Ensure you have the following installed:
- Python 3.6~3.8 (Verify runtime.txt)
- Virtual Environments with Python 3.6+
- Docker
- Docker Compose
-
Create a virtual environment:
python3 -m venv env
-
Activate the virtual environment:
source env/bin/activate -
Install app dependencies:
pip install -r requirements.txt
-
Start the database (PostgreSQL:alpine3.14):
docker-compose up
-
Start the application:
uvicorn app.main:app --reload
You can configure the database using an environment variable:
export DB_URL="postgresql://user-name:password@host-name/database-name"- The application will be available at: 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: skatesham/skatesham-github)
If required, add the following headers for authentication on routes:
token: my-jwt-tokenx_token: fake-super-secret-token
-
Run tests:
pytest
-
Run tests with coverage report:
pytest --cov=app app/test/
To update dependencies in requirements.txt:
- Remove the version constraint for
dataclasses. - Run:
pip freeze > requirements.txt
sudo snap install --classic herokuIf 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- FastAPI
- Bigger Application
- SQL Databases
- Testing
- Pydantic
- SQLAlchemy by FastAPI
- SQLAlchemy 1.4
- FastAPI "Real World Example App"