Skip to content

template for simple web applications made with flask, using SQLAlchemy ORM and Flask-migrate

License

Notifications You must be signed in to change notification settings

Joao-Pedro-P-Holanda/schema-migration-flask

Repository files navigation

Schema migration with Flask

This template workspace gives the project structure to setup a flask web application, using SQLAlchemy, Flask-Migrate, Flask-Marshmallow and Pytest.

Alembic migrations are stored in the migrations folder by default.

This project was inspired and follows the same structure as another Flask example made by the youtuber Eduardo Mendes. My goal is to expand with more advanced configurations, including Docker and CI/CD.

Original video

His Youtube Channel

Source Code

Project Structure

This project features an flask app, defined as a package in the __init__.py file, the function create_app act as application factory and is automatically detected when flask run is executed (see the Flask tutorial for more details).

All database tables are expressed as classes in the models.py file, the function to setup the database is also defined in this file.

serializer.py contains the schemas to serialize every model.

hello_world.py defines a blueprint, which contains its own set of routes that can be registered to the app.

Lastly. the html that is rendered on the starting route is included in the templates folder

Configure Development Workspace

1. Set the DATABASE_URI environment variable

  • Linux

export DATABASE_URI="your_database_uri_here"
  • Windows

setx DATABASE_URI="your_database_uri_here"

Install dev_requirements

pip install -r dev_requirements.txt

Run the app

flask run --debug

TODO

  • Containerize the application
  • Set up dependabot
  • Create actions workflow for migrations
  • Configure logging
  • Style the hello page

About

template for simple web applications made with flask, using SQLAlchemy ORM and Flask-migrate

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published