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



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


  • The entry point of the code
  • Store configuration from env variables

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


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


  • All related docker files


  • sql migration files


  • unit test directory


  • 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.


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