flask-ligand

Release v0.8.1 (Changelog)

Docs Build PyPI Codecov pre-commit

A simple Flask library for building microservices with RBAC JWT security, OpenAPI client and SQLAlchemy database support.

Install

$ pip install flask-ligand

Why Use this Library?

Using Flask to create a REST based microservice is a daunting process which will definitely require the use of many different Flask extensions which will really slow down the process of actually writing a functional REST microservice that can be used safely in a production environment. This library seeks to use the best Flask extensions loosely combined together to deliver a delightful developer experience by providing the following functionality out-of-the-box:

  • Create database models using the industry standard SQLAlchemy ORM

  • Leverage those same database models to create schemas for marshalling data in and out of your Flask endpoints defined via Blueprints

  • Provide automatic SwaggerUI docs for quickly developing and testing your Flask application without the need of external tools like curl, Postman or Hoppscotch

  • Generate OpenAPI clients for a variety of languages
    • Endpoints for generating Python and Typescript clients already included!

  • Protect endpoints with JWT security with a OpenID Connect IAM like Auth0 or Keycloak
    • Optionally control access to endpoints using RBAC

  • Quickly enable pagination and ETag support for your endpoints

  • Easily manage database migrations using Alembic through the fantastic Flask-Migrate library and command-line tools

Why not Use FastAPI Instead?

This library mimics many of the features of FastAPI, well, because FastAPI is really good! However, the Flask ecosystem is much larger than FastAPI giving many more options when it comes to high quality extensions. The one large advantage FastAPI has over Flask currently is support for asynchronous I/O via Starlette which can improve performance dramatically.

Flask’s asyncio journey has just started and Quart most likely being the future for asyncio in the Flask ecosystem. This library was inspired by FastAPI and I think anyone considering starting a greenfield microservice should give serious consideration to using FastAPI.

However, if you have an existing Flask microservice needing an upgrade in feature set then this library brings together the best extensions that the Flask ecosystem has to offer! If you’re creating a greenfield microservice then this library lets you tap into a wide range of other Flask extensions that will help you solve your problem(s) faster.

Guides

Powered By

This library is powered by the following awesome projects: