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
+65-20
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,16 @@ This project is for developers looking to build and maintain full-feature progre
6
6
7
7
This is an **experimental** 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) and [Whythawk's](https://github.com/whythawk)[Full Stack FastAPI and PostgreSQL Base Project Generator](https://github.com/whythawk/full-stack-fastapi-postgresql). FastAPI is updated to version 0.103.2, MongoDB Motor 3.4, ODMantic ODM 1.0.0, and the frontend to React.
8
8
9
+

10
+
11
+
## Index
9
12
13
+
-[Requirements](#requirements)
14
+
-[QuickStart](#quickstart)
10
15
-[Screenshots](#screenshots)
11
16
-[Key features](#key-features)
12
17
-[How to use it](#how-to-use-it)
13
-
-[Getting started](./docs/getting-started.md)
18
+
-[Building a generated app](./docs/getting-started.md)
14
19
-[Development and installation](./docs/development-guide.md)
15
20
-[Deployment for production](./docs/deployment-guide.md)
16
21
-[Authentication and magic tokens](./docs/authentication-guide.md)
@@ -19,28 +24,55 @@ This is an **experimental** fork of [Sebastián Ramírez's](https://github.com/t
19
24
-[Help needed](#help-needed)
20
25
-[Release notes](#release-notes)
21
26
-[License](#license)
22
-
23
-
## Screenshots
24
27
25
-
### App landing page
26
28
27
-

29
+
## Requirements
30
+
31
+
Please make sure you have these installed before proceeding!
*[Cookiecutter](https://cookiecutter.readthedocs.io/en/stable/) -- The Python Cookiecutter library.
35
+
*[Hatch](https://hatch.pypa.io/latest/)
36
+
*[Node.js](https://nodejs.org/en)
37
+
*[MongoDB Compass](https://www.mongodb.com/products/tools/compass) -- To help visualize local/remote database easily.
38
+
39
+
## QuickStart
40
+
41
+
**NOTE: this will generate a local application that is not yet production-ready. Please go through all of the README information linked before creating a version to deploy to a production host**
28
42
29
-
### Dashboard Login
43
+
For those that want to dive in and play around with the generated code, here's a quick start guide on how to do it. It is advised, though, once you have run through generating this app the first time, that you circle back and check out the more fleshed out [Building a generated app](./docs/getting-started.md) section.
30
44
31
-

45
+
```
46
+
// Make sure cookiecutter and python are installed on the device
47
+
// This will generate a full-stack app in the directory ./example
// Make sure that you've opened the Docker Desktop app before this step.
54
+
// build
55
+
docker compose build --no-cache
36
56
37
-
### Interactive API documentation
57
+
// start the container in the background
58
+
docker compose up -d
59
+
```
38
60
39
-

61
+
Now you can view the site by going to `localhost:3000`. You can also see all the logs of the running containers in your Docker Desktop app.
40
62
41
-
### Enabling two-factor security (TOTP)
63
+
There will only be one user on the site: `[email protected]`. If you choose a different project name, then the email domain changes. For example, if you create your project using`project_name=fullstackexample` the user email will be `[email protected]`. The default password will be set to `changethis` but that can be changed.
64
+
65
+
Here are all the local development URLS:
66
+
67
+
- Frontend -- http://localhost:3000
68
+
- Backend -- http://localhost/api/v1/
69
+
- Automatic Documentation via Swagger UI -- http://localhost/docs
70
+
- Alternative Documentation via ReDoc -- http://localhost/redoc
71
+
- Flower: Admin tool of Celery Tasks -- http://localhost:5555
72
+
- Traefik UI to see how routes are being handled by the proxy: http://localhost:8090
73
+
74
+
See [Building a generated app](./docs/getting-started.md) for examples of what these pages look like.
42
75
43
-

44
76
45
77
## Key features
46
78
@@ -55,8 +87,8 @@ This FastAPI, React, MongoDB repo will generate a complete web application stack
55
87
-**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/).
56
88
-[**Many other features**]("https://fastapi.tiangolo.com/features/"): including automatic validation, serialization, interactive documentation, etc.
-**Authorisation**via middleware for page access, including logged in or superuser.
59
-
-**Form validation** with [Vee-Validate 4](https://vee-validate.logaretm.com/v4/).
90
+
-**Authorization**route-based authentication, including support for detecting if a user is logged in or is a superuser.
91
+
-**Form validation** with [React useForm](https://react-hook-form.com/docs/useform)
60
92
-**State management** with [Redux](https://redux.js.org/)
61
93
-**CSS and templates** with [TailwindCSS](https://tailwindcss.com/), [HeroIcons](https://heroicons.com/), and [HeadlessUI](https://headlessui.com/).
62
94
-**Celery** worker that can import and use models and code from the rest of the backend selectively.
@@ -65,9 +97,9 @@ This FastAPI, React, MongoDB repo will generate a complete web application stack
65
97
- Traefik integration, including Let's Encrypt **HTTPS** certificates automatic generation.
66
98
- GitLab **CI** (continuous integration), including frontend and backend testing.
67
99
68
-
## How to use it
100
+
## How to use the template
69
101
70
-
-[Getting started](./docs/getting-started.md)
102
+
-[Building a generated app](./docs/getting-started.md)
71
103
-[Development and installation](./docs/development-guide.md)
72
104
-[Deployment for production](./docs/deployment-guide.md)
73
105
-[Authentication and magic tokens](./docs/authentication-guide.md)
@@ -77,21 +109,34 @@ This FastAPI, React, MongoDB repo will generate a complete web application stack
77
109
78
110
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).
79
111
80
-
This current release (October 2023) is for FastAPI version 0.103 and introduces 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.
112
+
This current release is for FastAPI version 0.103 and introduces 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.
81
113
82
114
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.
83
115
84
116
## Help needed
85
117
86
-
This stack is in an experimental state, so there is no guarantee for bugs or issues. Please open an issue ticket against this repository to make us aware of issues and we will do our best to respond to them in a timely manner. Please leave feedback on features that would be very beneficial for developers who often leverage mongodb in their FastAPI stack.
118
+
This project is currently experimental, so bugs or issues may occur. Please open an issue ticket against this repository to make us aware of issues and we will do our best to respond to them in a timely manner. Please leave feedback on features that would be very beneficial for developers who often leverage MongoDB in their FastAPI stack.
87
119
88
120
89
121
## Release Notes
90
122
123
+
**NOTE: There is no intention to have backwards compatibility between releases.**
124
+
91
125
See notes:
92
126
93
-
## CalVer 2023.12.XX
127
+
## CalVer 2024.01.XX
94
128
- Replaced Beanie usage with ODMantic
129
+
- Fixed TOTP login
130
+
- Added Page-Level route authentication
131
+
- Fixed issued with logged in user being unable to access `/settings` page
Copy file name to clipboardExpand all lines: docs/getting-started.md
+10-18
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,12 @@
1
-
# Getting started with the Base Project Generator
1
+
# Building an App with the Base Project Generator
2
2
3
-
1.[Getting started](getting-started.md)
4
-
2.[Development and installation](development-guide.md)
5
-
3.[Deployment for production](deployment-guide.md)
6
-
4.[Authentication and magic tokens](authentication-guide.md)
7
-
5.[Websockets for interactive communication](websocket-guide.md)
3
+
This page will walk you through the fundamentals of how this app generator works as well as where to look for further details. To learn more about making a production-ready generated application, please read the below sections.
4
+
5
+
1.[Development and installation](development-guide.md)
6
+
2.[Deployment for production](deployment-guide.md)
7
+
3.[Authentication and magic tokens](authentication-guide.md)
8
+
4.[Websockets for interactive communication](websocket-guide.md)
@@ -30,9 +32,9 @@ This FastAPI, React, MongoDB repo will generate a complete web application stack
30
32
-**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/).
31
33
-[**Many other features**]("https://fastapi.tiangolo.com/features/"): including automatic validation, serialization, interactive documentation, etc.
-**Authorisation**via middleware for page access, including logged in or superuser.
35
+
-**Authorization**route-based authentication, including support for detecting if a user is logged in or is a superuser.
34
36
-**Model blog** project, with [Nuxt Content](https://content.nuxtjs.org/) for writing Markdown pages.
35
-
-**Form validation** with [Vee-Validate 4](https://vee-validate.logaretm.com/v4/).
37
+
-**Form validation** with [React useForm](https://react-hook-form.com/docs/useform)
36
38
-**State management** with [Redux](https://redux.js.org/)
37
39
-**CSS and templates** with [TailwindCSS](https://tailwindcss.com/), [HeroIcons](https://heroicons.com/), and [HeadlessUI](https://headlessui.com/).
38
40
-**Celery** worker that can import and use models and code from the rest of the backend selectively.
@@ -42,7 +44,6 @@ This FastAPI, React, MongoDB repo will generate a complete web application stack
42
44
-**Github Actions** (continuous integration), including backend testing.
43
45
44
46
45
-
46
47
## Who is it for?
47
48
48
49
This project is a rock-solid foundation on which to build complex web applications which need parallel processing, scheduled event management, leveraging a NoSQL Datastore (MongoDB). The base deployment requires about 2Gb of memory to run.
@@ -102,12 +103,3 @@ Time-based One-Time Password (TOTP) authentication extends the login process to
102
103
### More details
103
104
104
105
After using this generator, your new project 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).
105
-
106
-
## Release Notes
107
-
108
-
### 2023.11.10
109
-
- Experimental release of FARM-stack generator app
110
-
111
-
## License
112
-
113
-
This project is licensed under the terms of the MIT license.
Copy file name to clipboardExpand all lines: {{cookiecutter.project_slug}}/README.md
+2-44
Original file line number
Diff line number
Diff line change
@@ -80,7 +80,7 @@ Next, open your editor at `./backend/app/` (instead of the project root: `./`),
80
80
$ code .
81
81
```
82
82
83
-
Modify or add beanie models in `./backend/app/app/models/` (make sure to include them in `MODELS` within `.backend/app/app/models/__init__.py`), Pydantic schemas in `./backend/app/app/schemas/`, API endpoints in `./backend/app/app/api/`, CRUD (Create, Read, Update, Delete) utils in `./backend/app/app/crud/`. The easiest might be to copy the ones for Items (models, endpoints, and CRUD utils) and update them to your needs.
83
+
Modify or add ODMantic models in `./backend/app/app/models/`, Pydantic schemas in `./backend/app/app/schemas/`, API endpoints in `./backend/app/app/api/`, CRUD (Create, Read, Update, Delete) utils in `./backend/app/app/crud/`. The easiest might be to copy the ones for Items (models, endpoints, and CRUD utils) and update them to your needs.
84
84
85
85
Add and modify tasks to the Celery worker in `./backend/app/app/worker.py`.
You will have a full Jupyter Notebook running inside your container that has direct access to your database by the container name (`db`), etc. So, you can just run sections of your backend code directly, for example with [VS Code Python Jupyter Interactive Window](https://code.visualstudio.com/docs/python/jupyter-support-py) or [Hydrogen](https://github.com/nteract/hydrogen).
225
225
226
-
### Migrations
227
-
228
-
As during local development your app directory is mounted as a volume inside the container, you can also run the migrations with `alembic` commands inside the container and the migration code will be in your app directory (instead of being only inside the container). So you can add it to your git repository.
229
-
230
-
Make sure you create a "revision" of your models and that you "upgrade" your database with that revision every time you change them. As this is what will update the tables in your database. Otherwise, your application will have errors.
231
-
232
-
* Start an interactive session in the backend container:
233
-
234
-
```console
235
-
$ docker-compose exec backend bash
236
-
```
237
-
238
-
* 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.
239
-
240
-
* After changing a model (for example, adding a column), inside the container, create a revision, e.g.:
241
-
242
-
```console
243
-
$ alembic revision --autogenerate -m "Add column last_name to User model"
244
-
```
245
-
246
-
* Commit to the git repository the files generated in the alembic directory.
247
-
248
-
* After creating the revision, run the migration in the database (this is what will actually change the database):
249
-
250
-
```console
251
-
$ alembic upgrade head
252
-
```
253
-
254
-
If you don't want to use migrations at all, uncomment the line in the file at `./backend/app/app/db/init_db.py` with:
255
-
256
-
```python
257
-
Base.metadata.create_all(bind=engine)
258
-
```
259
-
260
-
and comment the line in the file `prestart.sh` that contains:
261
-
262
-
```console
263
-
$ alembic upgrade head
264
-
```
265
-
266
-
If you don't want to start with the default models and want to remove them / modify them, from the beginning, without having any previous revision, you can remove the revision files (`.py` Python files) under `./backend/app/alembic/versions/`. And then create a first migration as described above.
267
-
268
226
### Development with Docker Toolbox
269
227
270
228
If you are using **Docker Toolbox** in Windows or macOS instead of **Docker for Windows** or **Docker for Mac**, Docker will be running in a VirtualBox Virtual Machine, and it will have a local IP different than `127.0.0.1`, which is the IP address for `localhost` in your machine.
0 commit comments