serebrov / flask-vue-starter

Flask REST + Vue.js/typescript template app, docker setup, tests (pytest and jest), linters and code formatting (black and prettier)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CircleCI

Starter example app: Flask (SQLAlchemy, PostgreSQL) + Vue.js (Typescript), docker setup for backend and frontend.

Backend is powered by Flask, flask-rest-api, marshmallow and SQLAlchemy to create a solid framework for REST API backend development:

  • Application structure
  • Routing
  • Data validation, serialization and de-serialization
  • DB layer with ORM and migrations
  • API documentation with apispec and Swagger
  • Testing with pytest

Backend setup:

Frontend setup:

Note: on linux, to fix permissions between host / docker shared containers, it is necessary to export $UID and $GID variables, this can be done in ~/.bashrc or ~/.zshrc. This is because UID and GID are shell variables, not env variables. It allows to have dependencies (python venv and node.js node_modules shared from the container to the host, so we can have IDE completion on the host, or just easily access the dependencies from the editor). See also: docker/compose#2380.

Backend dependencies are in backend/venv and frontend dependencies are in the frontend/node_modules.

Local Setup

  • Rebuild images / reinstall dependencies: make build
  • Run docker compose setup: make up
  • Create the initial DB (once the setup is running): make recreate-local-db
  • Run linters: make lint
  • Run tests: make test

Reformat sources: make format-code.

Backend DB Migrations

DB migrations are handled by alembic and Flask-Migrate.

Flask-Migrate runs migrations in the context of flask application, to use it, run make backend-bash and then use one of the following commands:

  • flask db migrate -m "change description" - generate new migrations from models
  • flask db upgrade - apply migrations to the database
  • flask db downgrade - downgrade the database
  • flask db --help - get help and list of available commands

About

Flask REST + Vue.js/typescript template app, docker setup, tests (pytest and jest), linters and code formatting (black and prettier)


Languages

Language:Python 57.4%Language:Vue 18.5%Language:TypeScript 8.6%Language:JavaScript 7.1%Language:Makefile 3.3%Language:Dockerfile 2.1%Language:HTML 1.2%Language:Mako 1.1%Language:Shell 0.7%