Giter Club home page Giter Club logo

fastapi_psql_boilerplate's Introduction

FASTAPI + PSQL API Boilerplate

codecov

FastAPI Docs

Docs for this boilerplate

Set up for local

>>> python3 -m venv venv
>>> pip install -r requirements.txt

Running manually on local

Create a .env file (use .example-env as a reference) and then run following command.

>>> source .env
>>> python main.py

Using alembic for DB management

  1. Add models to models.py

example for a model class:

class User(Base):
    __tablename__ = "users"

    id = Column(Integer, primary_key=True, index=True)
    user_name = Column(String, unique=True)
    first_name = Column(String)
    last_name = Column(String) 
    phone = Column(String)
    user_type = Column(String)
    email = Column(String, unique=True, index=True)
    password = Column(String)
  1. Create a revision
>>> PYTHONPATH=. alembic revision --autogenerate -m "..."
  1. Running migrations
>>> PYTHONPATH=. alembic upgrade head

Running linter

>>> pylint `pwd`

NOTE: The above cmd is tested on ubuntu.

Running test

>>> pytest tests/

Pytest docs
Fastapi testing docs

Running coverage

>>> coverage run -m pytest tests/
>>> coverage report
>>> coverage html

Running through docker

>>> sudo docker image build .
>>> sudo docker run -d --name myapp 8080:80 <image>

CI using Circleci

We are using Circleci for CI.

Steps to setup

  • Go to CircleCI.
  • Connect you github account.
  • you can simply follow the steps there to set up your project there.
  • Update .circleci/config.yml as per your need.

Important links for CI

fastapi_psql_boilerplate's People

Contributors

abhayaman669 avatar 96radhikajadhav avatar

Stargazers

 avatar

Watchers

 avatar

fastapi_psql_boilerplate's Issues

Add linting.

Need to add pylint and update the docs for that.

Creating login and signup API

  • Need to create this on a new branch example-auth
  • Add an API for login and signup.
  • login should return a token (JWT)
  • For this just need to take email and password.

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.