Built with Python + Flask + PostgreSQL + SQLAlchemy; to easily develop a solid framework for REST APIs
- Python 3.7
- Docker
- Flask 2.0.2
- PostgreSQL 13
- SQLAlchemy 1.4 for database ORM
- Marshmallow 3.14 for validation and serialization
- Flask Restful 0.3 for wrapping REST APIs
- Linting with mypy, flake8 and black
- Code formatting with black
Docker Compose was used to avoid manually installing PostgreSQL database and to easily setup, run and develop the server and APIs
# Build and start database and server
$ make start
# Setup database and run migrations
$ make init-db
- Server:
http://localhost:5000
- Database:
http://localhost:5432
- Database Admin (pgadmin4):
http://localhost:5050
make build
: Rebuild images / reinstall dependenciesmake start
: Run docker compose services (database, app)make init-db
: Create the initial DB and run initial migrationsmake recreate-db
: Delete the database and re-create itmake start-psql
: Start PSQL cli. To exitctrl + d
make start-bash
: Start bash in server. To exitctrl + d
make lint
: Run lintersmake format
: Reformat sources
DB migrations are handled by alembic and Flask-Migrate.
Flask-Migrate
runs migrations in the context of flask application, to use it, run make start-bash
and then use one of the following commands:
flask db migrate -m "migration description"
- generate new migrations from modelsflask db upgrade
- apply migrations to the databaseflask db downgrade
- downgrade the databaseflask db --help
- get help and list of available commands