Popularity
0.5
Stable
Activity
6.1
Declining
2
2
1

Description

The base code structure for restful Flask-RESTX framework

Programming language: Python
Tags: RESTful API     Flask     Boilerplate     Python3     Flask-restx    
Latest version: v0.1.0

Flask-RESTX-boilerplate alternatives and similar packages

Based on the "Flask" category.
Alternatively, view Flask-RESTX-boilerplate alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Flask-RESTX-boilerplate or a related project?

Add another 'Flask' Package

README

Flask-RESTX-boilerplate


The base code structure for Flask-RESTX

If you like this project, feel fee to leave a few words of appreciation here Say Thanks! or buy me a pizza


Table of contents

  1. Directory Convention
  2. Development instruction
  3. Test and Code quality
  4. Versioning

Directory Convention

/app

/app/manage.py

  • The entry point of the code

/app/config.py

  • Store configuration from env variables

/app/modules

Flask-RESTX provides a way to use Flask’s blueprint. The main idea is to split your app into reusable namespaces. Here namespaces are organized in different modules

  • /app/modules/sample_mod: each module is split into MVC, i.e. controller, dto, view

    • /app/modules/sample_controller.py
    • /app/modules/sample_dto.py
    • /app/modules/sample_view.py
  • /app/modules/sample_mod/datadef: validation layer

app/extensions

we put everything else here, i.e. interfaces, cache, databases, ORM, i18n, monitor, logging, etc.

/docker

  • All related docker files

/sql

  • sql migration files

/test

  • unit test directory

/docs

  • Store documents files

Development instruction

Running service with docker

$ docker build -f ./docker/app/Dockerfile .
$ docker run <name of image> -p 5000:5000
  • Swagger is at /api/v1/openapi

Recommended code contribution and submission

  • The live branch should be named master or main

  • The main feature branch is named dev where development is branched out from dev

$ git checkout -b dev origin/dev
$ git checkout -b <your branch name> dev

# do your development

$ git add --all 
$ git commit -s -am "your message"

# You might also need to rebase from upstream remote branch before pushing
$ git rebase upstream/dev

# Save new packages to app/requirements
$ pip3 freeze > <path to project>/app/requirements.txt

# To push your branch
$ git push -u origin <your branch name>
  • Then you can create MR with the source branch is your branch and the target branch is dev.
  • When we release, we merge dev into master, tag them and deploy.

Test and Code quality

Unit test

$ pytest tests

Code quality

$ pylint ./app
$ mypy ./app
$ black ./tests
  • API design: guide
  • Code style: Pep8 coding style
  • import statement: better to import only necessary function not entire package, i.e. if you only need sqrt(): bash Recommended: from math import sqrt Not recommended: import math
  • Exception - EAFP principle: use except/try instead of if/else, and try to use specific exceptions instead of generic exception.

Versioning

We use SemVer for versioning. Please see CHANGELOG.md for more details.