|
1 |
| -# Full Stack Flask and PostgreSQL - Base Project Generator |
| 1 | +# Full Stack FastAPI and PostgreSQL - Base Project Generator |
2 | 2 |
|
3 |
| -[](https://travis-ci.org/tiangolo/full-stack) |
| 3 | +[](https://travis-ci.org/tiangolo/full-stack-fastapi-postgresql) |
4 | 4 |
|
5 | 5 | Generate a backend and frontend stack using Python, including interactive API documentation.
|
6 | 6 |
|
7 |
| -[](https://github.com/tiangolo/full-stack) |
| 7 | +[](https://github.com/tiangolo/full-stack-fastapi-postgresql) |
8 | 8 |
|
9 | 9 | ## Features
|
10 | 10 |
|
11 |
| -* Full **Docker** integration (Docker based) |
12 |
| -* Docker Swarm Mode deployment |
| 11 | +* Full **Docker** integration (Docker based). |
| 12 | +* Docker Swarm Mode deployment. |
13 | 13 | * **Docker Compose** integration and optimization for local development
|
14 |
| -* **Production ready** Python web server using Nginx and uWSGI |
15 |
| -* Python **Flask** backend with: |
16 |
| - * **Flask-apispec**: Swagger live documentation generation |
17 |
| - * **Marshmallow**: model and data serialization (convert model objects to JSON) |
18 |
| - * **Webargs**: parse, validate and document inputs to the endpoint / route |
19 |
| - * **Secure password** hashing by default |
20 |
| - * **JWT token** authentication |
21 |
| - * **SQLAlchemy** models (independent of Flask extensions, so they can be used with Celery workers directly) |
22 |
| - * Basic starting models for users and groups (modify and remove as you need) |
23 |
| - * **Alembic** migrations |
24 |
| - * **CORS** (Cross Origin Resource Sharing) |
25 |
| -* **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) |
26 |
| -* 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) |
27 |
| -* Easy Python integration with **Jupyter Kernels** for remote or in-Docker development with extensions like Atom Hydrogen or Visual Studio Code Jupyter |
28 |
| -* Vue frontend: |
29 |
| - * Generated with **Vue CLI** |
30 |
| - * JWT Authentication handling |
31 |
| - * Login view |
32 |
| - * After login, main dashboard view |
33 |
| - * **Vuex** |
34 |
| - * **Vue-router** |
35 |
| - * **Vuetify** for beautiful material design components |
36 |
| - * **TypeScript** |
37 |
| - * Docker server based on **Nginx** (configured to play nicely with Vue-router) |
38 |
| - * Docker multi-stage building, so you don't need to save or commit compiled code |
39 |
| - * Frontend tests ran at build time (can be disabled too) |
40 |
| - * 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 |
41 |
| -* **PGAdmin** for PostgreSQL database, you can modify it to use PHPMyAdmin and MySQL easily |
42 |
| -* **Swagger-UI** for live interactive documentation |
43 |
| -* **Flower** for Celery jobs monitoring |
44 |
| -* 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 |
45 |
| -* Traefik integration, including Let's Encrypt **HTTPS** certificates automatic generation |
46 |
| -* **GitLab CI** (continuous integration), including frontend and backend testing |
| 14 | +* **Production ready** Python web server using Uvicorn and Gunicorn. |
| 15 | +* Python **[FastAPI](https://github.com/tiangolo/fastapi)** backend: |
| 16 | + * **Fast**: Very high performance, on par with **NodeJS** and **Go** (thanks to Starlette and Pydantic). |
| 17 | + * **Intuitive**: Great editor support. <abbr title="also known as auto-complete, autocompletion, IntelliSense">Completion</abbr> everywhere. Less time debugging. |
| 18 | + * **Easy**: Designed to be easy to use and learn. Less time reading docs. |
| 19 | + * **Short**: Minimize code duplication. Multiple features from each parameter declaration. |
| 20 | + * **Robust**: Get production-ready code. With automatic interactive documentation. |
| 21 | + * **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <a href="https://github.com/OAI/OpenAPI-Specification" target="_blank">OpenAPI</a> and <a href="http://json-schema.org/" target="_blank">JSON Schema</a>. |
| 22 | + * [**Many other features**](https://github.com/tiangolo/fastapi) including automatic validation, serialization, interactive documentation, authentication with OAuth2 JWT tokens, etc. |
| 23 | +* **Secure password** hashing by default. |
| 24 | +* **JWT token** authentication. |
| 25 | +* **SQLAlchemy** models (independent of Flask extensions, so they can be used with Celery workers directly). |
| 26 | +* Basic starting models for users (modify and remove as you need). |
| 27 | +* **Alembic** migrations. |
| 28 | +* **CORS** (Cross Origin Resource Sharing). |
| 29 | +* **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). |
| 30 | +* 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). |
| 31 | +* Easy Python integration with **Jupyter Kernels** for remote or in-Docker development with extensions like Atom Hydrogen or Visual Studio Code Jupyter. |
| 32 | +* **Vue** frontend: |
| 33 | + * Generated with Vue CLI. |
| 34 | + * **JWT Authentication** handling. |
| 35 | + * Login view. |
| 36 | + * After login, main dashboard view. |
| 37 | + * Main dashboard with user creation and edition. |
| 38 | + * Self user edition. |
| 39 | + * **Vuex**. |
| 40 | + * **Vue-router**. |
| 41 | + * **Vuetify** for beautiful material design components. |
| 42 | + * **TypeScript**. |
| 43 | + * Docker server based on **Nginx** (configured to play nicely with Vue-router). |
| 44 | + * Docker multi-stage building, so you don't need to save or commit compiled code. |
| 45 | + * Frontend tests ran at build time (can be disabled too). |
| 46 | + * 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. |
| 47 | +* **PGAdmin** for PostgreSQL database, you can modify it to use PHPMyAdmin and MySQL easily. |
| 48 | +* **Flower** for Celery jobs monitoring. |
| 49 | +* 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. |
| 50 | +* Traefik integration, including Let's Encrypt **HTTPS** certificates automatic generation. |
| 51 | +* GitLab **CI** (continuous integration), including frontend and backend testing. |
47 | 52 |
|
48 | 53 | ## How to use it
|
49 | 54 |
|
@@ -84,6 +89,11 @@ The input variables, with their default values (some auto generated) are:
|
84 | 89 | * `first_superuser`: The first superuser generated, with it you will be able to create more users, etc. By default, based on the domain.
|
85 | 90 | * `first_superuser_password`: First superuser password. Use the method above to generate it.
|
86 | 91 | * `backend_cors_origins`: Origins (domains, more or less) that are enabled for CORS (Cross Origin Resource Sharing). This allows a frontend in one domain (e.g. `https://dashboard.example.com`) to communicate with this backend, that could be living in another domain (e.g. `https://api.example.com`). It can also be used to allow your local frontend (with a custom `hosts` domain mapping, as described in the project's `README.md`) that could be living in `http://dev.example.com:8080` to cummunicate with the backend at `https://stag.example.com`. Notice the `http` vs `https` and the `dev.` prefix for local development vs the "staging" `stag.` prefix. By default, it includes origins for production, staging and development, with ports commonly used during local development by several popular frontend frameworks (Vue with `:8080`, React, Angular).
|
| 92 | +* `smtp_port`: Port to use to send emails via SMTP. By default `587`. |
| 93 | +* `smtp_host`: Host to use to send emails, it would be given by your email provider, like Mailgun, Sparkpost, etc. |
| 94 | +* `smtp_user`: The user to use in the SMTP connection. The value will be given by your email provider. |
| 95 | +* `smtp_password`: The password to be used in the SMTP connection. The value will be given by the email provider. |
| 96 | +* `smtp_emails_from_email`: The email account to use as the sender in the notification emails, it would be something like `[email protected]`. |
87 | 97 |
|
88 | 98 | * `postgres_password`: Postgres database password. Use the method above to generate it. (You could easily modify it to use MySQL, MariaDB, etc).
|
89 | 99 | * `pgadmin_default_user`: PGAdmin default user, to log-in to the PGAdmin interface.
|
@@ -113,14 +123,6 @@ Please refer to <a href="https://dockerswarm.rocks" target="_blank">DockerSwarm.
|
113 | 123 |
|
114 | 124 | After using this generator, your new project (the directory created) will contain an extensive `README.md` with instructions for development, deployment, etc. You can pre-read [the project `README.md` template here too](./{{cookiecutter.project_slug}}/README.md).
|
115 | 125 |
|
116 |
| -## History |
117 |
| - |
118 |
| -**Note about Angular**: a previous version of this project generated a basic default Angular frontend application, but without any view or interaction with the rest of the stack (the backend API). I recently switched to Vue for frontend and used it to created the basic frontend views for this project (that didn't exist before). If you are interested in keeping the Angular version, 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. |
119 |
| - |
120 |
| -This project was based on [senseta-os/senseta-base-project](https://github.com/senseta-os/senseta-base-project). |
121 |
| - |
122 |
| -As [I was the only maintainer](https://github.com/tiangolo), I'm continuing the development in this fork (https://github.com/tiangolo/full-stack). |
123 |
| - |
124 | 126 | ## License
|
125 | 127 |
|
126 | 128 | This project is licensed under the terms of the MIT license.
|
0 commit comments