Skip to content

The boilerplate for the project using restful Flask-RESTX framework

Notifications You must be signed in to change notification settings

tranlv/Flask-RESTX-boilerplate

Repository files navigation

Flask-RESTX-boilerplate


The boilerplate for the project using restful Flask-RESTX framework


Table of contents

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

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

Test and Code quality

Unit test

$ pytest tests

Code quality

$ pylint ./app
$ mypy ./app
$ black ./app
$ flake ./app

Versioning

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

Contribution

Please follow our contribution convention at contribution instructions and code of conduct.

To set up development environment, simply run:

$ pip install -r requirements.txt

You can also put a vote to get the project more visible to others.

If you like this project, you can buy buy me a pizza to motivate me improve on the project.