
Flask + SqlAlchemy + Docker + PyTest + PyLint + Tox Boilerplate
This product is a boilerplate repository that aims to facilitate API developers by integrating reputable libraries and following good engineering practices. It is built using Flask, SqlAlchemy, Docker, PyTest, PyLint, and Tox. The repository includes features such as CRUD implementation on a model, environment-specific configuration, logging of web requests and exceptions, and a layered architecture.
git clone https://github.com/uinvent/flask_boilerplate.git
Create a copy of .env.sample and name it as .env. Fill it with your machine configurations. Make sure to configure the APP_DB_* configurations as they lead to your database.
Install the libraries used in the project.
python manage.py init
This will create the database on the server configured in the .env file. Then run:
python manage.py db upgrade
This will run two migrations:
To start the app server for debugging:
python manage.py runserver -d
This will start the app server and the APIs are ready to be consumed. To start a production-ready server using Gunicorn:
python manage.py runserver
Now the APIs are ready to be consumed on the default URL, http://0.0.0.0:8088
To run the tests:
pytest
This command will find all test cases and run them. The tests are available in the /tests/ folder. To see the test coverage report:
pytest --cov=./src/ tests/
To run pylint on the src folder and check for errors only:
pylint src --errors-only
Note that this command uses the .pylintrc file for linting.
This product is a boilerplate repository that aims to make API development easier by integrating various reputable libraries such as Flask, SqlAlchemy, Docker, PyTest, PyLint, and Tox. It includes features such as CRUD implementation on a model, environment-specific configurations, and a layered architecture. The installation guide provides step-by-step instructions for setting up and running the boilerplate, including cloning the repository, configuring the environment, installing dependencies, running database migrations, starting the server, and running code tests.

Flask is a lightweight and popular web framework for Python, known for its simplicity and flexibility. It is widely used to build web applications, providing a minimalistic approach to web development with features like routing, templates, and support for extensions.