Skip to content

Commit 9f9b025

Browse files
committed
Version updates & refactoring across the stack
Updates to `backend`: - FastAPI 0.99 -> 0.109 (Inboard 0.51 -> 0.68) - Pydantic 1.10 -> 2.7.1 Updates to `frontend`: - NuxtJS 3.6.5 -> 3.11.2 - Nuxtjs i18n 8.0.0 RC -> 8.3.1 The Pydantic change is dramatic, so please revise their [migration guide](https://docs.pydantic.dev/2.7/migration/). Similarly, [nuxt/i18n](https://i18n.nuxtjs.org/docs/getting-started) has some major quality of life improvements. This update necessitated refactoring across the stack.
1 parent a76587d commit 9f9b025

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+5783
-4274
lines changed

README.md

+62-34
Original file line numberDiff line numberDiff line change
@@ -2,76 +2,75 @@
22

33
[![Build Status](https://app.travis-ci.com/whythawk/full-stack-fastapi-postgresql.svg?branch=master)](https://app.travis-ci.com/whythawk/full-stack-fastapi-postgresql)
44

5-
Accelerate your next web development project with this FastAPI/Nuxt.js base project generator.
5+
Accelerate your next web development project with this FastAPI/NuxtJS base project generator.
66

77
This project is for developers looking to build and maintain full-feature progressive web applications using Python on the backend / Typescript on the frontend, and want the complex-but-routine aspects of auth 'n auth, and component and deployment configuration, taken care of, including interactive API documentation.
88

9-
This is a comprehensively updated fork of [Sebastián Ramírez's](https://github.com/tiangolo) [Full Stack FastAPI and PostgreSQL Base Project Generator](https://github.com/tiangolo/full-stack-fastapi-postgresql). FastAPI is updated to version 0.99 (July 2023), SQLAlchemy to version 2.0 (July 2023), and the frontend to Nuxt 3.6 (July 2023).
9+
This project is a fork of [Sebastián Ramírez's](https://github.com/tiangolo) [Full Stack FastAPI and PostgreSQL Base Project Generator](https://github.com/tiangolo/full-stack-fastapi-postgresql). FastAPI is updated to version 0.109 (April 2024), SQLAlchemy to version 2.0.29 (March 2024), and the frontend to Nuxt 3.11 (April 2024).
1010

11-
- [Screenshots](#screenshots)
1211
- [Key features](#key-features)
12+
- [Screenshots](#screenshots)
1313
- [How to use it](#how-to-use-it)
1414
- [Getting started](./docs/getting-started.md)
1515
- [Development and installation](./docs/development-guide.md)
1616
- [Deployment for production](./docs/deployment-guide.md)
1717
- [Authentication and magic tokens](./docs/authentication-guide.md)
1818
- [Websockets for interactive communication](./docs/websocket-guide.md)
19+
- [Fork differences](#fork-differences)
1920
- [More details](#more-details)
2021
- [Help needed](#help-needed)
2122
- [Release notes](#release-notes)
2223
- [License](#license)
2324

24-
## Screenshots
25-
26-
### App landing page
27-
28-
![Landing page](img/landing.png)
29-
30-
### Dashboard Login
31-
32-
![Magic-link login](img/login.png)
33-
34-
### Dashboard User Management
35-
36-
![Moderator user management](img/dashboard.png)
37-
38-
### Interactive API documentation
39-
40-
![Interactive API docs](img/redoc.png)
41-
42-
### Enabling two-factor security (TOTP)
43-
44-
![Enabling TOTP](img/totp.png)
45-
4625
## Key features
4726

4827
This FastAPI, PostgreSQL, Neo4j & Nuxt 3 repo will generate a complete web application stack as a foundation for your project development.
4928

5029
- **Docker Compose** integration and optimization for local development.
5130
- **Authentication** user management schemas, models, crud and apis already built, with OAuth2 JWT token support & default hashing. Offers _magic link_ authentication, with password fallback, with cookie management, including `access` and `refresh` tokens.
52-
- [**FastAPI**](https://github.com/tiangolo/fastapi) backend with [Inboard](https://inboard.bws.bio/) one-repo Docker images:
31+
- [**FastAPI**](https://github.com/tiangolo/fastapi) backend with [Inboard](https://inboard.bws.bio/) one-repo Docker images, using Python 3.11:
5332
- **SQLAlchemy** version 2.0 support for models.
54-
- **MJML** templates for common email transactions.
33+
- **Pydantic** version 2.7 for schemas.
5534
- **Metadata Schema** based on [Dublin Core](https://www.dublincore.org/specifications/dublin-core/dcmi-terms/#section-3) for inheritance.
5635
- **Common CRUD** support via generic inheritance.
5736
- **Standards-based**: Based on (and fully compatible with) the open standards for APIs: [OpenAPI](https://github.com/OAI/OpenAPI-Specification) and [JSON Schema](http://json-schema.org/).
37+
- **MJML** templates for common email transactions.
5838
- [**Many other features**]("https://fastapi.tiangolo.com/features/"): including automatic validation, serialization, interactive documentation, etc.
59-
- [**Nuxt/Vue 3**](https://nuxt.com/) frontend:
39+
- [**Nuxt/Vue 3**](https://nuxt.com/) frontend using TypeScript:
6040
- **Authorisation** via middleware for page access, including logged in or superuser.
6141
- **Model blog** project, with [Nuxt Content](https://content.nuxtjs.org/) for writing Markdown pages.
6242
- **Form validation** with [Vee-Validate 4](https://vee-validate.logaretm.com/v4/).
6343
- **State management** with [Pinia](https://pinia.vuejs.org/), and persistance with [Pinia PersistedState](https://prazdevs.github.io/pinia-plugin-persistedstate/).
6444
- **CSS and templates** with [TailwindCSS](https://tailwindcss.com/), [HeroIcons](https://heroicons.com/), and [HeadlessUI](https://headlessui.com/).
65-
- **Internationalisation** with [@nuxt/i18n](https://nuxt.com/modules/i18n).
66-
- **PWA support** with [Vite PWA plugin](https://vite-pwa-org.netlify.app/frameworks/nuxt.html).
6745
- **PostgreSQL** database.
6846
- **PGAdmin** for PostgreSQL database management.
6947
- **Celery** worker that can import and use models and code from the rest of the backend selectively.
7048
- **Flower** for Celery jobs monitoring.
7149
- **Neo4j** graph database, including integration into the FastAPI base project.
7250
- 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.
7351
- Traefik integration, including Let's Encrypt **HTTPS** certificates automatic generation.
74-
- GitLab **CI** (continuous integration), including frontend and backend testing.
52+
53+
## Screenshots
54+
55+
### App landing page
56+
57+
![Landing page](img/landing.png)
58+
59+
### Dashboard Login
60+
61+
![Magic-link login](img/login.png)
62+
63+
### Dashboard User Management
64+
65+
![Moderator user management](img/dashboard.png)
66+
67+
### Interactive API documentation
68+
69+
![Interactive API docs](img/redoc.png)
70+
71+
### Enabling two-factor security (TOTP)
72+
73+
![Enabling TOTP](img/totp.png)
7574

7675
## How to use it
7776

@@ -81,15 +80,32 @@ This FastAPI, PostgreSQL, Neo4j & Nuxt 3 repo will generate a complete web appli
8180
- [Authentication and magic tokens](./docs/authentication-guide.md)
8281
- [Websockets for interactive communication](./docs/websocket-guide.md)
8382

83+
## Fork differences
84+
85+
The original objective of this fork was to maintain parity with the [Full Stack FastAPI and PostgreSQL Base Project Generator](https://github.com/tiangolo/full-stack-fastapi-postgresql) but update it to bring it up to current stack versions, fixes, and with a complete auth 'n auth system.
86+
87+
With the most recent updates to the base stack, Sebastián has made some fairly dramatic changes and these two stacks are no longer compatible. This table presents a summary of the major differences:
88+
89+
| This base stack | Tiangolo base stack |
90+
| :------------------------------- | :---------------------- |
91+
| SQLAlchemy & Pydantic | SqlModel |
92+
| Postgresql 15 & PGAdmin | Postgresql 12 & Adminer |
93+
| Celery & RabbitMQ task queue | - |
94+
| NuxtJS frontend | React frontend |
95+
96+
I use this stack to produce some fairly complex web-based applications and I need to get to the full APIs for SQLAlchemy and Pydantic, and SqlModel doesn't offer me that. I also need to run distributed asyncronous tasks, so Celery is important. Finally, I prefer Nuxt.
97+
98+
This stack also has a much more sophisticated and feature-complete auth 'n auth system which is a requirement for any web app.
99+
84100
## More details
85101

86102
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).
87103

88-
This current release (August 2023) is for FastAPI version 0.99 and is the last before introducing support for Pydantic 2. Since this is intended as a base stack on which you will build complex applications, there is no intention of backwards compatability between releases, and the objective is to ensure that each release has the latest long-term-support versions of the core libraries so that you can rely on your application core for as long as possible.
104+
This current release (May 2024) is for FastAPI version 0.109 introduces support for Pydantic 2.7. Since this is intended as a base stack on which you will build complex applications, there is no intention of backwards compatability between releases, and the objective is to ensure that each release has the latest long-term-support versions of the core libraries so that you can rely on your application core for as long as possible.
89105

90-
To align with [Inboard](https://inboard.bws.bio/), Poetry has been deprecated in favour of [Hatch](https://hatch.pypa.io/latest/). This will also, hopefully, sort out some Poetry-related Docker build errors.
106+
To align with [Inboard](https://inboard.bws.bio/), Poetry has been deprecated in favour of [Hatch](https://hatch.pypa.io/latest/).
91107

92-
You will also find an initial implementation of internationalisation using [@nuxt/i18n](https://nuxt.com/modules/i18n). This is - at this time - a release candidate, so please do update and check their documentation for any changes. The [Vite PWA plugin](https://vite-pwa-org.netlify.app/frameworks/nuxt.html) is also included, along with a Node CLI for generating all necessary app icons. You will see links and notes to this in the [nuxt.config.ts](./{{cookiecutter.project_slug}}/frontend/nuxt.config.ts) file.
108+
You will also find an initial implementation of internationalisation using [@nuxt/i18n](https://nuxt.com/modules/i18n). The [Vite PWA plugin](https://vite-pwa-org.netlify.app/frameworks/nuxt.html) is also included, along with a Node CLI for generating all necessary app icons. You will see links and notes to this in the [nuxt.config.ts](./{{cookiecutter.project_slug}}/frontend/nuxt.config.ts) file.
93109

94110
## Help needed
95111

@@ -103,6 +119,18 @@ The tests are broken and it would be great if someone could take that on. Other
103119

104120
See notes and [releases](https://github.com/whythawk/full-stack-fastapi-postgresql/releases).
105121

122+
## 0.9.0
123+
124+
Updates to `backend`:
125+
- FastAPI 0.99 -> 0.109 (Inboard 0.51 -> 0.68)
126+
- Pydantic 1.10 -> 2.7.1
127+
128+
Updates to `frontend`:
129+
- NuxtJS 3.6.5 -> 3.11.2
130+
- Nuxtjs i18n 8.0.0 RC -> 8.3.1
131+
132+
The Pydantic change is dramatic, so please revise their [migration guide](https://docs.pydantic.dev/2.7/migration/). Similarly, [nuxt/i18n](https://i18n.nuxtjs.org/docs/getting-started) has some major quality of life improvements.
133+
106134
## 0.8.2
107135

108136
Fixing [#39](https://github.com/whythawk/full-stack-fastapi-postgresql/issues/39), thanks to @a-vorobyoff:

docs/getting-started.md

+16-4
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ It consists of the following key components:
2525

2626
- **Docker Compose** integration and optimization for local development.
2727
- **Authentication** user management schemas, models, crud and apis already built, with OAuth2 JWT token support & default hashing. Offers _magic link_ authentication, with password fallback, with cookie management, including `access` and `refresh` tokens.
28-
- [**FastAPI**](https://github.com/tiangolo/fastapi) backend with [Inboard](https://inboard.bws.bio/) one-repo Docker images:
28+
- [**FastAPI**](https://github.com/tiangolo/fastapi) backend with [Inboard](https://inboard.bws.bio/) one-repo Docker images, using Python 3.11:
2929
- **SQLAlchemy** version 2.0 support for models.
30-
- **MJML** templates for common email transactions.
30+
- **Pydantic** version 2.7 for schemas.
3131
- **Metadata Schema** based on [Dublin Core](https://www.dublincore.org/specifications/dublin-core/dcmi-terms/#section-3) for inheritance.
3232
- **Common CRUD** support via generic inheritance.
3333
- **Standards-based**: Based on (and fully compatible with) the open standards for APIs: [OpenAPI](https://github.com/OAI/OpenAPI-Specification) and [JSON Schema](http://json-schema.org/).
34+
- **MJML** templates for common email transactions.
3435
- [**Many other features**]("https://fastapi.tiangolo.com/features/"): including automatic validation, serialization, interactive documentation, etc.
35-
- [**Nuxt/Vue 3**](https://nuxt.com/) frontend:
36+
- [**Nuxt/Vue 3**](https://nuxt.com/) frontend using TypeScript:
3637
- **Authorisation** via middleware for page access, including logged in or superuser.
3738
- **Model blog** project, with [Nuxt Content](https://content.nuxtjs.org/) for writing Markdown pages.
3839
- **Form validation** with [Vee-Validate 4](https://vee-validate.logaretm.com/v4/).
@@ -45,7 +46,6 @@ It consists of the following key components:
4546
- **Neo4j** graph database, including integration into the FastAPI base project.
4647
- 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.
4748
- Traefik integration, including Let's Encrypt **HTTPS** certificates automatic generation.
48-
- GitLab **CI** (continuous integration), including frontend and backend testing.
4949

5050
## Who is it for?
5151

@@ -105,6 +105,18 @@ After using this generator, your new project will contain an extensive `README.m
105105

106106
See notes and [releases](https://github.com/whythawk/full-stack-fastapi-postgresql/releases). The last four release notes are listed here:
107107

108+
## 0.9.0
109+
110+
Updates to `backend`:
111+
- FastAPI 0.99 -> 0.109 (Inboard 0.51 -> 0.68)
112+
- Pydantic 1.10 -> 2.7.1
113+
114+
Updates to `frontend`:
115+
- NuxtJS 3.6.5 -> 3.11.2
116+
- Nuxtjs i18n 8.0.0 RC -> 8.3.1
117+
118+
The Pydantic change is dramatic, so please revise their [migration guide](https://docs.pydantic.dev/2.7/migration/). Similarly, [nuxt/i18n](https://i18n.nuxtjs.org/docs/getting-started) has some major quality of life improvements.
119+
108120
## 0.8.2
109121

110122
Fixing [#39](https://github.com/whythawk/full-stack-fastapi-postgresql/issues/39), thanks to @a-vorobyoff:

img/docs.png

96.2 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text eol=lf

{{cookiecutter.project_slug}}/README.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ Traefik UI, to see how the routes are being handled by the proxy: http://localho
3030
To check the logs, run:
3131

3232
```bash
33-
docker-compose logs
33+
docker compose logs
3434
```
3535

3636
To check the logs of a specific service, add the name of the service, e.g.:
3737

3838
```bash
39-
docker-compose logs backend
39+
docker compose logs backend
4040
```
4141

4242
If your Docker is not running in `localhost` (the URLs above wouldn't work) check the sections below on **Development with Docker Toolbox** and **Development with a custom IP**.
@@ -81,21 +81,21 @@ The changes to that file only affect the local development environment, not the
8181
For example, the directory with the backend code is mounted as a Docker "host volume", mapping the code you change live to the directory inside the container. That allows you to test your changes right away, without having to build the Docker image again. It should only be done during development, for production, you should build the Docker image with a recent version of the backend code. But during development, it allows you to iterate very fast. Have in mind that if you have a syntax error and save the Python file, it will break and exit, and the container will stop. After that, you can restart the container by fixing the error and running again:
8282

8383
```console
84-
$ docker-compose up -d
84+
$ docker compose up -d
8585
```
8686

8787
There is also a commented out `command` override, you can uncomment it and comment the default one. It makes the backend container run a process that does "nothing", but keeps the container alive. That allows you to get inside your running container and execute commands inside, for example a Python interpreter to test installed dependencies, or start the development server that reloads when it detects changes, or start a Jupyter Notebook session.
8888

8989
To get inside the container with a `bash` session you can start the stack with:
9090

9191
```console
92-
$ docker-compose up -d
92+
$ docker compose up -d
9393
```
9494

9595
and then `exec` inside the running container:
9696

9797
```console
98-
$ docker-compose exec backend bash
98+
$ docker compose exec backend bash
9999
```
100100

101101
You should see an output like:
@@ -133,23 +133,23 @@ The `./backend/app` directory is mounted as a "host volume" inside the docker co
133133
You can rerun the test on live code:
134134

135135
```Bash
136-
docker-compose exec backend /app/tests-start.sh
136+
docker compose exec backend /app/tests-start.sh
137137
```
138138

139139
#### Test running stack
140140

141141
If your stack is already up and you just want to run the tests, you can use:
142142

143143
```bash
144-
docker-compose exec backend /app/tests-start.sh
144+
docker compose exec backend /app/tests-start.sh
145145
```
146146

147147
That `/app/tests-start.sh` script just calls `pytest` after making sure that the rest of the stack is running. If you need to pass extra arguments to `pytest`, you can pass them to that command and they will be forwarded.
148148

149149
For example, to stop on first error:
150150

151151
```bash
152-
docker-compose exec backend bash /app/tests-start.sh -x
152+
docker compose exec backend bash /app/tests-start.sh -x
153153
```
154154

155155
#### Test Coverage
@@ -165,7 +165,7 @@ DOMAIN=backend sh ./scripts/test-local.sh --cov-report=html
165165
To run the tests in a running stack with coverage HTML reports:
166166

167167
```bash
168-
docker-compose exec backend bash /app/tests-start.sh --cov-report=html
168+
docker compose exec backend bash /app/tests-start.sh --cov-report=html
169169
```
170170

171171
### Live development with Python Jupyter Notebooks
@@ -177,7 +177,7 @@ The `docker-compose.override.yml` file sends a variable `env` with a value `dev`
177177
So, you can enter into the running Docker container:
178178

179179
```bash
180-
docker-compose exec backend bash
180+
docker compose exec backend bash
181181
```
182182

183183
And use the environment variable `$JUPYTER` to run a Jupyter Notebook with everything configured to listen on the public port (so that you can use it from your browser).
@@ -218,7 +218,7 @@ Make sure you create a "revision" of your models and that you "upgrade" your dat
218218
* Start an interactive session in the backend container:
219219

220220
```console
221-
$ docker-compose exec backend bash
221+
$ docker compose exec backend bash
222222
```
223223

224224
* If you created a new model in `./backend/app/app/models/`, make sure to import it in `./backend/app/app/db/base.py`, that Python module (`base.py`) that imports all the models will be used by Alembic.
@@ -349,7 +349,7 @@ That variable will make your frontend communicate with that domain when interact
349349
After changing the two lines, you can re-start your stack with:
350350

351351
```bash
352-
docker-compose up -d
352+
docker compose up -d
353353
```
354354

355355
and check all the corresponding available URLs in the section at the end.
@@ -587,11 +587,11 @@ TAG=${TAG?Variable not set} \
587587
# a default value of "production" if nothing else was passed
588588
FRONTEND_ENV=${FRONTEND_ENV-production?Variable not set} \
589589
# The actual comand that does the work: docker-compose
590-
docker-compose \
590+
docker compose \
591591
# Pass the file that should be used, setting explicitly docker-compose.yml avoids the
592592
# default of also using docker-compose.override.yml
593593
-f docker-compose.yml \
594-
# Use the docker-compose sub command named "config", it just uses the docker-compose.yml
594+
# Use the docker compose sub command named "config", it just uses the docker-compose.yml
595595
# file passed to it and prints their combined contents
596596
# Put those contents in a file "docker-stack.yml", with ">"
597597
config > docker-stack.yml
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Get rid of .venv when copying
2+
# https://docs.docker.com/engine/reference/builder/#dockerignore-file
23
*/.venv
34
*/*/.venv

0 commit comments

Comments
 (0)