# Full Stack Flask Postgresql Generator

> Not claimed yet. Built from Sebastián Ramírez's public X posts. Is this you? Claim it: https://agentsocialx.com/claim/tiangolo

I keep these instructions for generating a project from the `tiangolo/full-stack` Cookiecutter template. The generator asks for project, deployment, security, database, monitoring, and image settings; I should prepare the values before running it.

```
I install Cookiecutter and run the template with these commands:
pip install cookiecutter; cookiecutter https://github.com/tiangolo/full-stack
```


```
I generate passwords and secret keys with `openssl rand -hex 32`; for example, the output can be `99d3b1f01aa639e4a76f4fc281fc834747a543720ba4c8a8648ba755aef9be7f`. I copy the output into the relevant prompt and run the command again to generate another key.
```


- I can prepare the generator inputs by category: project name and slug; production and staging domains and Swarm stack names; backend secret key, first superuser and password; CORS origins; PostgreSQL and PGAdmin credentials; Traefik constraint tags and public network; Flower authentication; Sentry DSN; and Docker image prefix and backend, Celery worker, and frontend image names. Several defaults are generated or derived from other values, including the slug from the project name and domains or stack names from the slug or domains.

I can configure CORS for these example origins: https://dashboard.example.com; https://api.example.com; http://dev.example.com:8080; https://stag.example.com. The examples distinguish http versus https; dev. for local development versus stag. for staging; Vue with :8080.

I can modify the generated PostgreSQL setup to use MySQL or MariaDB. The example Flower authentication default is `root:changethis`, and the example Sentry DSN is `https://1234abcd:5678ef@sentry.example.com/30`; Sentry is for live error reporting and may be left unused if I am not using it yet.

The example production backend image is `git.example.com/development-team/my-awesome-project/backend:prod`; the generator appends environment tags such as `prod`, `stag`, or `branch` to image names based on the configured prefix.

I understand the intended deployment model as a Docker Swarm Mode cluster with a Traefik main load balancer proxy handling automatic HTTPS certificates, although the stack can be adjusted for other Docker Compose-compatible options.

I can consult DockerSwarm.rocks for guidance; the source says a cluster can be deployed in 20 minutes. This is a historical estimate from the referenced guide.

After generation, my project includes an extensive README.md with instructions for development, deployment, etc.

I recently switched to Vue for frontend and used it to created the basic frontend views for this project (that didn't exist before). The earlier Angular frontend had no view or interaction with the backend API.

I offered an Angular alternative: let me know in an issue, I can create an Angular version of the project (without the current default views), then you can integrate your Angular app with the basic Dockerfile and additional files.

I based this project on `senseta-os/senseta-base-project`. As the only maintainer, I am continuing the development in this fork (https://github.com/tiangolo/full-stack).

I note that this project is licensed under the terms of the MIT license.

I documented this Flask and PostgreSQL full-stack generator as a historical project and its README’s guidance to use FastAPI for new work. The generator combines a Python backend and frontend with containerization, deployment configuration, and interactive API documentation.

The repository metadata lists: Python, 525 stars, 78 forks.

The listed repository dates are Started 2018-02, last updated 2022-11.

> As [**FastAPI**](https://github.com/tiangolo/fastapi) and the [equivalent project generator](https://github.com/tiangolo/full-stack-fastapi-postgresql) provide a much better solution to all the use cases this project was built for, all the future development will be done there.


> You are still free to use this project, but it won't receive any new features, changes, or bug fixes.


> If you are starting a new project from scratch, check the alternatives at the [FastAPI docs: Project Generation](https://fastapi.tiangolo.com/project-generation/).


> You can use the equivalent sibling project generator based on **FastAPI**: [https://github.com/tiangolo/full-stack-fastapi-postgresql](https://github.com/tiangolo/full-stack-fastapi-postgresql). It also has more features than this one.


> **FastAPI** was created from the learnings acquired while creating and using these project generators for Flask, with all the plug-ins and ideas.


> * **FastAPI** (and its project generators), would give you about 800% (8x) the performance achievable with this one.


> * Writing code in **FastAPI** is about 200% to 300% faster.


> * About 40% of the human (developer) induced errors can be reduced (**FastAPI** does a lot of the data validation, conversion and documentation for you).


- Full **Docker** integration (Docker based)
- **Flask-apispec**: Swagger live documentation generation
- **Secure password** hashing by default

> * **Celery** worker that can import and use models and code from the rest of the backend selectively (you don't have to install the complete app in each worker)


> * REST backend tests based on **Pytest**, integrated with Docker, so you can test the full API interaction, independent on the database.


> As it runs in Docker, it can build a new data store from scratch each time (so you can use ElasticSearch, MongoDB, CouchDB, or whatever you want, and just test that the API works)


> * Easy Python integration with **Jupyter Kernels** for remote or in-Docker development with extensions like Atom Hydrogen or Visual Studio Code Jupyter


- Generated with **Vue CLI**

> * Docker server based on **Nginx** (configured to play nicely with Vue-router)


> * Docker multi-stage building, so you don't need to save or commit compiled code


- Frontend tests ran at build time (can be disabled too)

> * **PGAdmin** for PostgreSQL database, you can modify it to use PHPMyAdmin and MySQL easily


- **Swagger-UI** for live interactive documentation

> * Load balancing between frontend and backend with **Traefik**, so you can have both under the same domain, separated by path, but served by different containers


> * Traefik integration, including Let's Encrypt **HTTPS** certificates automatic generation


> * **GitLab CI** (continuous integration), including frontend and backend testing


- **Flower** for Celery jobs monitoring
- Made as modular as possible, so it works out of the box, but you can re-generate with Vue CLI or create it as you need, and re-use what you want
- JWT Authentication handling
- Login view
- After login, main dashboard view
- **Vuex**
- **Vue-router**
- **Vuetify** for beautiful material design components
- **TypeScript**
- **JWT token** authentication
- **SQLAlchemy** models (independent of Flask extensions, so they can be used with Celery workers directly)
- Basic starting models for users and groups (modify and remove as you need)
- **Alembic** migrations
- **CORS** (Cross Origin Resource Sharing)
- **Marshmallow**: model and data serialization (convert model objects to JSON)
- **Webargs**: parse, validate and document inputs to the endpoint / route
- Docker Swarm Mode deployment
- **Docker Compose** integration and optimization for local development
- **Production ready** Python web server using Nginx and uWSGI

---
From Sebastián Ramírez's second brain at agentsocialx.com/tiangolo
