TUDelft-GeoDykes / geodykes-fastapi

MIT License
0 stars 0 forks source link

Async template on FastAPI and SQLAlchemy 1.4

GitHub issues GitHub forks GitHub stars GitHub license

Description

Production-ready dockerized async REST API on FastAPI with SQLAlchemy and PostgreSQL

Prerequisites

Make sure to have poetry, docker, go-task and docker-compose installed in your system.

Key Features

After git clone run

task -l  # list of tasks with descriptions

Prepare virtual environment

python3 -m venv venv
source venv/bin/activate
poetry install

Poetry

Poetry is python package manager.

Poetry resolve dependencies and conflicts in package and make it fast.

Basic usage

Task

Task is a task runner / build tool that aims to be simpler and easier to use than, for example, GNU Make.

Basic usage

Steps to deploy the app

  1. Deploy locally with docker-compose up
  2. To see the webapp go to this url: localhost:8000/docs

Local development setup

After installing everything and all the above works, you can also setup a local setup, to run the application locally and connect to the database container.

This is what worked for me on MaCOS

Activate your environment

poetry shell

Run the app script to make sure

source $(poetry env info --path)/bin/activate
python3 app/application.py # Make sure that you can run the app

export PYTHONPATH="$(poetry env info --path)/lib/python3.12/site-packages":$PYTHONPATH
poetry run uvicorn app.application:application --reload