You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here are some short guidelines to guide you if you want to contribute to the development of the Full Stack FastAPI PostgreSQL project generator itself.
4
+
5
+
After you clone the project, there are several scripts that can help during development.
6
+
7
+
*`./scripts/dev-fsfp.sh`:
8
+
9
+
Generate a new default project `dev-fsfp`.
10
+
11
+
Call it from one level above the project directory. So, if the project is at `~/code/full-stack-fastapi-postgresql/`, call it from `~/code/`, like:
That will also contain all the generated files with the generated variables, but it will let you compare the changes in `dev-fsfp` and the source in the project generator with git, and see what to commit.
46
+
47
+
*`./scripts/discard-dev-files.sh`:
48
+
49
+
After using `./scripts/dev-fsfp-back.sh`, there will be a bunch of generated files with the variables for the generated project that you don't want to commit, like `README.md` and `.gitlab-ci.yml`.
50
+
51
+
To discard all those changes at once, run `discard-dev-files.sh` from the root of the project, e.g.:
52
+
53
+
```console
54
+
$ cd~/code/full-stack-fastapi-postgresql/
55
+
56
+
$ bash ./scripts/dev-fsfp-back.sh
57
+
```
58
+
59
+
*`./scripts/test.sh`:
60
+
61
+
Run the tests. It creates a project `testing-project`*inside* of the project generator and runs its tests.
62
+
63
+
Call it from the root of the project, e.g.:
64
+
65
+
```console
66
+
$ cd~/code/full-stack-fastapi-postgresql/
67
+
68
+
$ bash ./scripts/test.sh
69
+
```
70
+
71
+
*`./scripts/dev-link.sh`:
72
+
73
+
Set up a local directory with links to the files for live development with the source files.
74
+
75
+
This script generates a project `dev-link`*inside* the project generator, just to generate the `.env` and `./frontend/.env` files.
76
+
77
+
Then it removes everything except those 2 files.
78
+
79
+
Then it creates links for each of the source files, and adds those 2 files back.
80
+
81
+
The end result is that you can go into the `dev-link` directory and develop locally with it as if it was a generated project, with all the variables set. But all the changes are actually done directly in the source files.
82
+
83
+
This is probably a lot faster to iterate than using `./scripts/dev-fsfp.sh`. But it's tested only in Linux, it might not work in other systems.
***Fast**: Very high performance, on par with **NodeJS** and **Go** (thanks to Starlette and Pydantic).
34
31
***Intuitive**: Great editor support. <abbrtitle="also known as auto-complete, autocompletion, IntelliSense">Completion</abbr> everywhere. Less time debugging.
35
32
***Easy**: Designed to be easy to use and learn. Less time reading docs.
36
33
***Short**: Minimize code duplication. Multiple features from each parameter declaration.
37
34
***Robust**: Get production-ready code. With automatic interactive documentation.
38
-
***Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"target="_blank">OpenAPI</a> and <ahref="http://json-schema.org/"target="_blank">JSON Schema</a>.
39
-
*[**Many other features**](https://github.com/tiangolo/fastapi) including automatic validation, serialization, interactive documentation, authentication with OAuth2 JWT tokens, etc.
35
+
***Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> and <ahref="http://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
36
+
*<ahref="https://fastapi.tiangolo.com/features/"class="external-link"target="_blank">**Many other features**</a> including automatic validation, serialization, interactive documentation, authentication with OAuth2 JWT tokens, etc.
40
37
***Secure password** hashing by default.
41
38
***JWT token** authentication.
42
39
***SQLAlchemy** models (independent of Flask extensions, so they can be used with Celery workers directly).
43
40
* Basic starting models for users (modify and remove as you need).
44
41
***Alembic** migrations.
45
42
***CORS** (Cross Origin Resource Sharing).
46
-
***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).
43
+
***Celery** worker that can import and use models and code from the rest of the backend selectively.
47
44
* 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).
48
45
* Easy Python integration with **Jupyter Kernels** for remote or in-Docker development with extensions like Atom Hydrogen or Visual Studio Code Jupyter.
49
46
***Vue** frontend:
@@ -61,6 +58,7 @@ Generate a backend and frontend stack using Python, including interactive API do
61
58
* Docker multi-stage building, so you don't need to save or commit compiled code.
62
59
* Frontend tests ran at build time (can be disabled too).
63
60
* 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.
61
+
* It's also easy to remove it if you have an API-only app, check the instructions in the generated `README.md`.
64
62
***PGAdmin** for PostgreSQL database, you can modify it to use PHPMyAdmin and MySQL easily.
65
63
***Flower** for Celery jobs monitoring.
66
64
* 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.
@@ -69,7 +67,7 @@ Generate a backend and frontend stack using Python, including interactive API do
69
67
70
68
## How to use it
71
69
72
-
Go to the directoy where you want to create your project and run:
70
+
Go to the directory where you want to create your project and run:
73
71
74
72
```bash
75
73
pip install cookiecutter
@@ -105,7 +103,7 @@ The input variables, with their default values (some auto generated) are:
105
103
*`secret_key`: Backend server secret key. Use the method above to generate it.
106
104
*`first_superuser`: The first superuser generated, with it you will be able to create more users, etc. By default, based on the domain.
107
105
*`first_superuser_password`: First superuser password. Use the method above to generate it.
108
-
*`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).
106
+
*`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 communicate 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).
109
107
*`smtp_port`: Port to use to send emails via SMTP. By default `587`.
110
108
*`smtp_host`: Host to use to send emails, it would be given by your email provider, like Mailgun, Sparkpost, etc.
111
109
*`smtp_user`: The user to use in the SMTP connection. The value will be given by your email provider.
@@ -117,13 +115,12 @@ The input variables, with their default values (some auto generated) are:
117
115
*`pgadmin_default_user_password`: PGAdmin default user password. Generate it with the method above.
118
116
119
117
*`traefik_constraint_tag`: The tag to be used by the internal Traefik load balancer (for example, to divide requests between backend and frontend) for production. Used to separate this stack from any other stack you might have. This should identify each stack in each environment (production, staging, etc).
120
-
*`traefik_constraint_tag_staging`: The Traefik tag to be used while on staging.
121
-
*`traefik_public_network`: This assumes you have another separate publicly facing Traefik at the server / cluster level. This is the network that main Traefik lives in.
118
+
*`traefik_constraint_tag_staging`: The Traefik tag to be used while on staging.
122
119
*`traefik_public_constraint_tag`: The tag that should be used by stack services that should communicate with the public.
123
120
124
-
*`flower_auth`: Basic HTTP authentication for flower, in the form`user:password`. By default: "`root:changethis`".
121
+
*`flower_auth`: Basic HTTP authentication for flower, in the form`user:password`. By default: "`admin:changethis`".
125
122
126
-
*`sentry_dsn`: Key URL (DSN) of Sentry, for live error reporting. If you are not using it yet, you should, is open source. E.g.: `https://1234abcd:[email protected]/30`.
123
+
*`sentry_dsn`: Key URL (DSN) of Sentry, for live error reporting. You can use the open source version or a free account. E.g.: `https://1234abcd:[email protected]/30`.
127
124
128
125
*`docker_image_prefix`: Prefix to use for Docker image names. If you are using GitLab Docker registry it would be based on your code repository. E.g.: `git.example.com/development-team/my-awesome-project/`.
129
126
*`docker_image_backend`: Docker image name for the backend. By default, it will be based on your Docker image prefix, e.g.: `git.example.com/development-team/my-awesome-project/backend`. And depending on your environment, a different tag will be appended ( `prod`, `stag`, `branch` ). So, the final image names used will be like: `git.example.com/development-team/my-awesome-project/backend:prod`.
@@ -142,12 +139,55 @@ After using this generator, your new project (the directory created) will contai
142
139
143
140
## Sibling project generators
144
141
145
-
*Based on Couchbase: [https://github.com/tiangolo/full-stack-fastapi-couchbase](https://github.com/tiangolo/full-stack-fastapi-couchbase).
* Add consistent errors for env vars not set. PR [#200](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/200).
150
+
* Upgrade Traefik to version 2, keeping in sync with DockerSwarm.rocks. PR [#199](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/199).
151
+
* Add docs about reporting test coverage in HTML. PR [#161](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/161).
152
+
* Run tests with `TestClient`. PR [#160](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/160).
153
+
* Refactor backend:
154
+
* Simplify configs for tools and format to better support editor integration.
155
+
* Add mypy configurations and plugins.
156
+
* Add types to all the codebase.
157
+
* Update types for SQLAlchemy models with plugin.
158
+
* Update and refactor CRUD utils.
159
+
* Refactor DB sessions to use dependencies with `yield`.
160
+
* Refactor dependencies, security, CRUD, models, schemas, etc. To simplify code and improve autocompletion.
161
+
* Change from PyJWT to Python-JOSE as it supports additional use cases.
162
+
* Fix JWT tokens using user email/ID as the subject in `sub`.
* Add docs about removing the frontend, for an API-only app. PR [#156](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/156).
165
+
* Simplify scripts and development, update docs and configs. PR [#155](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/155).
* Simplify env var files, merge to a single `.env` file. PR [#151](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/151).
168
+
169
+
### 0.5.0
170
+
171
+
* Make the Traefik public network a fixed default of `traefik-public` as done in DockerSwarm.rocks, to simplify development and iteration of the project generator. PR [#150](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/150).
172
+
* Update to PostgreSQL 12. PR [#148](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/148). by [@RCheese](https://github.com/RCheese).
173
+
* Use Poetry for package management. Initial PR [#144](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/144) by [@RCheese](https://github.com/RCheese).
174
+
* Fix Windows line endings for shell scripts after project generation with Cookiecutter hooks. PR [#149](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/149).
175
+
* Upgrade Vue CLI to version 4. PR [#120](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/120) by [@br3ndonland](https://github.com/br3ndonland).
176
+
* Remove duplicate `login` tag. PR [#135](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/135) by [@Nonameentered](https://github.com/Nonameentered).
177
+
* Fix showing email in dashboard when there's no user's full name. PR [#129](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/129) by [@rlonka](https://github.com/rlonka).
178
+
* Format code with Black and Flake8. PR [#121](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/121) by [@br3ndonland](https://github.com/br3ndonland).
179
+
* Simplify SQLAlchemy Base class. PR [#117](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/117) by [@airibarne](https://github.com/airibarne).
180
+
* Update CRUD utils for users, handling password hashing. PR [#106](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/106) by [@mocsar](https://github.com/mocsar).
181
+
* Use `.` instead of `source` for interoperability. PR [#98](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/98) by [@gucharbon](https://github.com/gucharbon).
182
+
* Use Pydantic's `BaseSettings` for settings/configs and env vars. PR [#87](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/87) by [@StephenBrown2](https://github.com/StephenBrown2).
183
+
* Remove `package-lock.json` to let everyone lock their own versions (depending on OS, etc).
184
+
* Simplify Traefik service labels PR [#139](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/139).
185
+
* Add email validation. PR [#40](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/40) by [@kedod](https://github.com/kedod).
186
+
* Fix typo in README. PR [#83](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/83) by [@ashears](https://github.com/ashears).
187
+
* Fix typo in README. PR [#80](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/80) by [@abjoker](https://github.com/abjoker).
188
+
* Fix function name `read_item` and response code. PR [#74](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/74) by [@jcaguirre89](https://github.com/jcaguirre89).
189
+
* Fix typo in comment. PR [#70](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/70) by [@daniel-butler](https://github.com/daniel-butler).
190
+
* Fix Flower Docker configuration. PR [#37](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/37) by [@dmontagu](https://github.com/dmontagu).
151
191
* Add new CRUD utils based on DB and Pydantic models. Initial PR [#23](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/23) by [@ebreton](https://github.com/ebreton).
152
192
* Add normal user testing Pytest fixture. PR [#20](https://github.com/tiangolo/full-stack-fastapi-postgresql/pull/20) by [@ebreton](https://github.com/ebreton).
0 commit comments