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.qmd
+96-14Lines changed: 96 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -9,50 +9,128 @@ format: gfm
9
9
10
10
This project is still under development.
11
11
12
-
### Install development dependencies
12
+
### Architecture
13
+
14
+
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.
15
+
16
+
```{python}
17
+
#| echo: false
18
+
#| include: false
19
+
from graphviz import Digraph
20
+
21
+
dot = Digraph()
22
+
23
+
dot.node('A', 'User submits form')
24
+
dot.node('B', 'HTML/JS form validation')
25
+
dot.node('C', 'Convert to Pydantic model')
26
+
dot.node('D', 'Optional custom validation')
27
+
dot.node('E', 'Update database')
28
+
dot.node('F', 'Middleware error handler')
29
+
dot.node('G', 'Render error template')
30
+
dot.node('H', 'Redirect to GET endpoint')
31
+
dot.node('I', 'Fetch updated data')
32
+
dot.node('J', 'Re-render Jinja2 page template')
33
+
34
+
dot.edge('A', 'B')
35
+
dot.edge('B', 'A')
36
+
dot.edge('B', 'C', label='POST Request to FastAPI endpoint')
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.
52
+
53
+
### Install development dependencies in a VSCode Dev Container
54
+
55
+
If you use VSCode with Docker to develop in a container, the following VSCode Dev Container configuration will install all dependencies:
Simply create a `.devcontainer` folder in the root of the project and add a `devcontainer.json` file in the folder with the above content. VSCode may prompt you to install the Dev Container extension if you haven't already, and/or to open the project in a container. If not, you can manually select "Dev Containers: Reopen in Container" from View > Command Palette.
70
+
71
+
### Install development dependencies manually
72
+
73
+
#### Python and Docker
15
74
16
75
-[Python 3.12 or higher](https://www.python.org/downloads/)
17
76
-[Docker and Docker Compose](https://docs.docker.com/get-docker/)
- Download and install from [Graphviz.org](https://graphviz.org/download/#windows)
38
116
39
117
#### Python dependencies
40
118
41
-
1. Install Poetry
119
+
1.Install Poetry
42
120
43
-
```bash
121
+
```bash
44
122
pipx install poetry
45
123
```
46
124
47
-
2. Install project dependencies
125
+
2.Install project dependencies
48
126
49
-
```bash
127
+
```bash
50
128
poetry install
51
129
```
52
130
53
-
3. Activate shell
131
+
3.Activate shell
54
132
55
-
```bash
133
+
```bash
56
134
poetry shell
57
135
```
58
136
@@ -86,7 +164,11 @@ Navigate to http://localhost:8000/
86
164
87
165
### Render the README
88
166
89
-
`quarto render README.qmd`
167
+
When updating the documentation, remember to make changes in the README.qmd file, not the README.md file. Then run the following command to render the README.md file:
0 commit comments