Coder Social home page Coder Social logo

iashraful / fastapi-boilerplate-with-postgres Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 0.0 68 KB

A production ready boilerplate/template for FastAPI and PostgreSQL

Shell 0.42% Dockerfile 1.04% Python 96.99% Mako 1.56%
fastapi fastapi-sqlalchemy pytest python3 template

fastapi-boilerplate-with-postgres's Introduction

FastAPI Boilerplate [PostgreSQL]

Features

  • Database support with PostgreSQL
  • Async query with SQLAlchemy ORM
  • Migration management with alembic
  • A better directory structure
  • Tests setup with pytest
  • Testing with a real database along with setup and tear down approch
  • Celery worker support (celery beat can be configured easily.)
  • Repository based ORM writing for better abstraction
  • Logging support

How to run [Docker & Docker Compose]

  • Copy the .env.example and create .env file.
  • $ docker-compose up --build -d
  • Create databases by logging into the container of db. Use the following commands
$ docker-compose exec db sh

# su - postgres
$ psql
# CREATE DATABASE "fastapi_boilerplate";
# CREATE DATABASE "fastapi_boilerplate_test_db";
# \password
Enter new password for user postgres: *****
  • Copy the alembic.ini.example file to alembic.ini.
  • SSH to the container and run migration command,
./migrate.sh
  • Again re-run the $ docker-compose up --build -d
  • To run the tests run the following command,
$ docker-compose exec backend sh
# You will be logged in to the container shell. Then,
$ pytest

How to run [Without Docker]

  • Copy the .env.example and create .env file.
  • Create a virtualenv and activate it.
  • Install requirements pip install -r requirements.txt
  • Create database from psql shell.
  • Run the Server $ uvicorn main:app --reload --port 7001
  • Run celery $ python -m celery -A core.celery worker -l INFO
  • Run the tests $ pytest

Contributing Guide

  • Found something? Create an issue on this repository.
  • Fork this repo.
  • Work on it. Push it on your forked.
  • Make a PR with Upstream(this repo)

Contributors are most welcome

fastapi-boilerplate-with-postgres's People

Contributors

iashraful avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.