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
Copy file name to clipboardExpand all lines: README.md
+59-21Lines changed: 59 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,48 +1,76 @@
1
1
# FastAPI, Jinja2, PostgreSQL Webapp Template
2
2
3
+
3
4

4
5
5
-
## Documentation
6
+
## Quickstart
6
7
7
-
This README provides a high-level overview. See the **[full documentation website](https://promptlytechnologies.com/fastapi-jinja2-postgres-webapp/docs/)** for more detailed information on installation, features, architecture, conventions and code style, customization, and deployment to cloud platforms.
8
+
This quickstart guide provides a high-level overview. See the full
*FastAPI, Jinja2, PostgreSQL Webapp Template* combines three of the most lightweight and performant open-source web development frameworks in existence into a customizable webapp template with:
22
+
This template combines three of the most lightweight and performant
23
+
open-source web development frameworks into a customizable webapp
24
+
template with:
12
25
13
26
- Pure Python backend
14
-
-Low-Javascript frontend
15
-
- Powerful, easy-to-manage database layer
27
+
-Minimal-Javascript frontend
28
+
- Powerful, easy-to-manage database
16
29
17
30
The template also includes full-featured secure auth with:
18
31
19
32
- Token-based authentication
20
33
- Password recovery flow
21
34
- Role-based access control system
22
35
23
-
The design philosophy of the template is to prefer low-level, best-in-class open-source frameworks that offer flexibility, scalability, and performance without vendor-lock-in. You'll find the template amazingly easy not only to understand and customize, but also to deploy to any major cloud hosting platform.
36
+
## Design Philosophy
37
+
38
+
The design philosophy of the template is to prefer low-level,
39
+
best-in-class open-source frameworks that offer flexibility,
40
+
scalability, and performance without vendor-lock-in. You’ll find the
41
+
template amazingly easy not only to understand and customize, but also
42
+
to deploy to any major cloud hosting platform.
24
43
25
-
## Tech stack
44
+
## Tech Stack
26
45
27
46
**Core frameworks:**
28
-
-[FastAPI](https://fastapi.tiangolo.com/): scalable, high-performance, type-annotated Python web backend framework
29
-
-[PostgreSQL](https://www.postgresql.org/): the world's most advanced open-source database engine
30
-
-[Jinja2](https://jinja.palletsprojects.com/en/3.1.x/): frontend HTML templating engine
(Note: You will need to activate the shell every time you open a new terminal session. Alternatively, you can use the `poetry run` prefix before other commands to run them without activating the shell.)
118
+
(Note: You will need to activate the shell every time you open a new
119
+
terminal session. Alternatively, you can use the `poetry run` prefix
120
+
before other commands to run them without activating the shell.)
91
121
92
122
### Set environment variables
93
123
94
124
Copy .env.example to .env with `cp .env.example .env`.
95
125
96
-
Generate a 256 bit secret key with `openssl rand -base64 32` and paste it into the .env file.
126
+
Generate a 256 bit secret key with `openssl rand -base64 32` and paste
127
+
it into the .env file.
97
128
98
129
Set your desired database name, username, and password in the .env file.
99
130
100
-
To use password recovery, register a [Resend](https://resend.com/) account, verify a domain, get an API key, and paste the API key into the .env file.
131
+
To use password recovery, register a [Resend](https://resend.com/)
132
+
account, verify a domain, get an API key, and paste the API key into the
133
+
.env file.
101
134
102
135
### Start development database
103
136
@@ -107,7 +140,8 @@ docker compose up -d
107
140
108
141
### Run the development server
109
142
110
-
Make sure the development database is running and tables and default permissions/roles are created first.
143
+
Make sure the development database is running and tables and default
Your contributions are welcome! See the [issues page](https://github.com/promptly-technologies-llc/fastapi-jinja2-postgres-webapp/issues) for ideas. Fork the repository, create a new branch, make your changes, and submit a pull request.
Copy file name to clipboardExpand all lines: docs/architecture.qmd
+34-16Lines changed: 34 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: "Architecture"
3
3
---
4
4
5
-
## Architecture
5
+
## Data flow
6
6
7
7
This application uses a Post-Redirect-Get (PRG) pattern. The user submits a form, which sends a POST request to a FastAPI endpoint on the server. The database is updated, and the user is redirected to a GET endpoint, which fetches the updated data and re-renders the Jinja2 page template with the new data.
8
8
@@ -12,18 +12,34 @@ This application uses a Post-Redirect-Get (PRG) pattern. The user submits a form
12
12
from graphviz import Digraph
13
13
14
14
dot = Digraph()
15
-
16
-
dot.node('A', 'User submits form')
17
-
dot.node('B', 'HTML/JS form validation')
18
-
dot.node('C', 'Convert to Pydantic model')
19
-
dot.node('D', 'Optional custom validation')
20
-
dot.node('E', 'Update database')
21
-
dot.node('F', 'Middleware error handler')
22
-
dot.node('G', 'Render error template')
23
-
dot.node('H', 'Redirect to GET endpoint')
24
-
dot.node('I', 'Fetch updated data')
25
-
dot.node('J', 'Re-render Jinja2 page template')
26
-
15
+
dot.attr(rankdir='TB')
16
+
dot.attr('node', shape='box', style='rounded')
17
+
18
+
# Create client subgraph at top
19
+
with dot.subgraph(name='cluster_client') as client:
The advantage of the PRG pattern is that it is very straightforward to implement and keeps most of the rendering logic on the server side. The disadvantage is that it requires an extra round trip to the database to fetch the updated data, and re-rendering the entire page template may be less efficient than a partial page update on the client side.
Copy file name to clipboardExpand all lines: docs/contributing.qmd
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -8,12 +8,17 @@ Fork the repository, create a new branch, make your changes, and submit a pull r
8
8
9
9
### Render the documentation
10
10
11
-
The documentation is rendered with [Quarto](https://quarto.org/docs/). Make changes to the `.qmd` files in the `docs` folder. Then run the following command to render:
11
+
The README and documentation website are rendered with [Quarto](https://quarto.org/docs/). Make changes to the `.qmd` files in the root folder and the `docs` folder. Then run the following commands to render:
12
12
13
13
```bash
14
+
# To render the documentation website
14
15
quarto render
16
+
# To render the README
17
+
quarto render index.qmd --output-dir . --output README.md --to gfm
15
18
```
16
19
20
+
Due to a quirk of Quarto, an unnecessary `index.html` file is created in the root folder when the README is rendered. This file can be safely deleted.
0 commit comments