All Projects → antkahn → Flask Api Starter Kit

antkahn / Flask Api Starter Kit

Licence: mit
Start a Flask API in less than 5 minutes

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Flask Api Starter Kit

Go Api Boilerplate
Go Server/API boilerplate using best practices DDD CQRS ES gRPC
Stars: ✭ 373 (+26.01%)
Mutual labels:  api, starter-kit, boilerplate
Flasgger
Easy OpenAPI specs and Swagger UI for your Flask API
Stars: ✭ 2,825 (+854.39%)
Mutual labels:  api, swagger, flask
Koa Rest Api Boilerplate
💯 Boilerplate for Node.js Koa RESTful API application with Docker, Swagger, Jest, CodeCov and CircleCI
Stars: ✭ 420 (+41.89%)
Mutual labels:  api, swagger, boilerplate
Graphql Starter
💥 Monorepo template (seed project) pre-configured with GraphQL API, PostgreSQL, React, Relay, and Material UI.
Stars: ✭ 3,377 (+1040.88%)
Mutual labels:  api, starter-kit, boilerplate
Wertik Js
💪 A library that powers your app with GraphQL + Rest API
Stars: ✭ 56 (-81.08%)
Mutual labels:  api, starter-kit, boilerplate
Flask Restplus
Fully featured framework for fast, easy and documented API development with Flask
Stars: ✭ 2,585 (+773.31%)
Mutual labels:  api, swagger, flask
Postgrest Starter Kit
Starter Kit and tooling for authoring REST API backends with PostgREST
Stars: ✭ 657 (+121.96%)
Mutual labels:  api, starter-kit, boilerplate
Nodejsstarterkit
Starter Kit for Node.js v14.x, minimum dependencies 🚀
Stars: ✭ 348 (+17.57%)
Mutual labels:  api, starter-kit, boilerplate
Flask Restx
Fork of Flask-RESTPlus: Fully featured framework for fast, easy and documented API development with Flask
Stars: ✭ 1,050 (+254.73%)
Mutual labels:  api, swagger, flask
Go Restful Api
An idiomatic Go REST API starter kit (boilerplate) following SOLID principles and Clean Architecture
Stars: ✭ 1,043 (+252.36%)
Mutual labels:  api, starter-kit, boilerplate
Hapi Starter Kit
Hapi.js based REST boilerplate which uses latest ES7/ES8 features (async/await) with code coverage and follows best pratices
Stars: ✭ 103 (-65.2%)
Mutual labels:  swagger, starter-kit, boilerplate
Subzero Starter Kit
Starter Kit and tooling for authoring GraphQL/REST API backends with subZero
Stars: ✭ 136 (-54.05%)
Mutual labels:  api, starter-kit, boilerplate
Full Stack
Full stack, modern web application generator. Using Flask, PostgreSQL DB, Docker, Swagger, automatic HTTPS and more.
Stars: ✭ 451 (+52.36%)
Mutual labels:  api, swagger, flask
Apispec
A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)..
Stars: ✭ 831 (+180.74%)
Mutual labels:  api, swagger, flask
Bhagavadgita
A non-profit initiative to help spread the transcendental wisdom from the Bhagavad Gita to people around the world.
Stars: ✭ 84 (-71.62%)
Mutual labels:  api, swagger, flask
Express Graphql Typescript Boilerplate
A starter kit for building amazing GraphQL API's with TypeScript and express by @w3tecch
Stars: ✭ 163 (-44.93%)
Mutual labels:  api, starter-kit, boilerplate
Apiato
PHP Framework for building scalable API's on top of Laravel.
Stars: ✭ 2,564 (+766.22%)
Mutual labels:  api, starter-kit
Express Es6 Rest Api
🔋 Starter project for an ES6 RESTful Express API.
Stars: ✭ 2,401 (+711.15%)
Mutual labels:  api, boilerplate
Hexo Theme Doc
A documentation theme for the Hexo blog framework
Stars: ✭ 222 (-25%)
Mutual labels:  api, swagger
Openapi Diff
Utility for comparing two OpenAPI specifications.
Stars: ✭ 208 (-29.73%)
Mutual labels:  api, swagger

Flask Api Starter Kit CircleCI Scrutinizer Code Quality

This starter kit is designed to allow you to create very fast your Flask API.

The primary goal of this project is to remain as unopinionated as possible. Its purpose is not to dictate your project structure or to demonstrate a complete sample application, but to provide a set of tools intended to make back-end development robust, easy, and, most importantly, fun.

This starter kit comes with a tutorial. Check it out if you want a quick tutorial on how to use Flask with this architecure.

Table of Contents

  1. Dependencies
  2. Getting Started
  3. Commands
  4. Database
  5. Application Structure
  6. Development
  7. Testing
  8. Lint
  9. Format
  10. Swagger

Dependencies

You will need docker and docker-compose.

Getting Started

First, clone the project:

$ git clone https://github.com/antkahn/flask-api-starter-kit.git <my-project-name>
$ cd <my-project-name>

Then install dependencies and check that it works

$ make server.install      # Install the pip dependencies on the docker container
$ make server.start        # Run the container containing your local python server

If everything works, you should see the available routes here.

The API runs locally on docker containers. You can easily change the python version you are willing to use here, by fetching a docker image of the python version you want.

Commands

You can display availables make commands using make.

While developing, you will probably rely mostly on make server.start; however, there are additional scripts at your disposal:

make <script> Description
help Display availables make commands
server.install Install the pip dependencies on the server's container.
server.start Run your local server in its own docker container.
server.daemon Run your local server in its own docker container as a daemon.
server.upgrade Upgrade pip packages interactively.
database.connect Connect to your docker database.
database.migrate Generate a database migration file using alembic, based on your model files.
database.upgrade Run the migrations until your database is up to date.
database.downgrade Downgrade your database by one migration.
test Run unit tests with pytest in its own container.
test.coverage Run test coverage using pytest-cov.
test.lint Run flake8 on the src and test directories.
test.safety Run safety to check if your vendors have security issues.
format.black Format python files using Black.
format.isort Order python imports using isort.

Database

The database is in PostgreSql.

Locally, you can connect to your database using :

$ make database.connect

However, you will need before using this command to change the docker database container's name here.

This kit contains a built in database versioning using alembic. Once you've changed your models, which should reflect your database's state, you can generate the migration, then upgrade or downgrade your database as you want. See Commands for more information.

The migration will be generated by the container, it may possible that you can only edit it via sudo or by running chown on the generated file.

Application Structure

The application structure presented in this boilerplate is grouped primarily by file type. Please note, however, that this structure is only meant to serve as a guide, it is by no means prescriptive.

.
├── devops                   # Project devops configuration settings
│   └── deploy               # Environment-specific configuration files for shipit
├── migrations               # Database's migrations settings
│   └── versions             # Database's migrations versions generated by alembic
├── src                      # Application source code
│   ├── models               # Python classes modeling the database
│   │   ├── abc.py           # Abstract base class model
│   │   └── user.py          # Definition of the user model
│   ├── repositories         # Python classes allowing you to interact with your models
│   │   └── user.py          # Methods to easily handle user models
│   ├── resources            # Python classes containing the HTTP verbs of your routes
│   │   └── user.py          # Rest verbs related to the user routes
│   ├── routes               # Routes definitions and links to their associated resources
│   │   ├── __init__.py      # Contains every blueprint of your API
│   │   └── user.py          # The blueprint related to the user
│   ├── swagger              # Resources documentation
│   │   └── user             # Documentation of the user resource
│   │       └── GET.yml      # Documentation of the GET method on the user resource
│   ├── util                 # Some helpfull, non-business Python functions for your project
│   │   └── parse_params.py  # Wrapper for the resources to easily handle parameters
│   ├── config.py            # Project configuration settings
│   ├── manage.py            # Project commands
│   └── server.py            # Server configuration
└── test                     # Unit tests source code

Development

To develop locally, here are your two options:

$ make server.start           # Create the containers containing your python server in your terminal
$ make server.daemon          # Create the containers containing your python server as a daemon

The containers will reload by themselves as your source code is changed. You can check the logs in the ./server.log file.

Testing

To add a unit test, simply create a test_*.py file anywhere in ./test/, prefix your test classes with Test and your testing methods with test_. Unittest will run them automaticaly. You can add objects in your database that will only be used in your tests, see example. You can run your tests in their own container with the command:

$ make test

Lint

To lint your code using flake8, just run in your terminal:

$ make test.lint

It will run the flake8 commands on your project in your server container, and display any lint error you may have in your code.

Format

The code is formatted using Black and Isort. You have the following commands to your disposal:

$ make format.black # Apply Black on every file
$ make format.isort # Apply Isort on every file

Swagger

Your API needs a description of it's routes and how to interact with them. You can easily do that with the swagger package included in the starter kit. Simply add a docstring to the resources of your API like in the user example. The API description will be available here. The Swagger UI will be available here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].