Skip to content

Commit bd25047

Browse files
authored
Update README.md
1 parent af6cee2 commit bd25047

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

README.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@
66
<img src="https://img.shields.io/github/license/rafsaf/minimal-fastapi-postgres-template" alt="License">
77
</a>
88

9-
:information_source: This repository contains two different templates to choose from.
9+
## Minimal FastAPI Postgres Template
10+
11+
There are two templates to choose from, first **minimal template** is a minimal template for FastAPI backend + postgresql db as of 2021.11, async style for database sessions, endpoints and tests. It provides basic codebase that almost every application has, but nothing more.
12+
13+
Seconds one, **fastapi-users template** is similar to minimal in structure, but based on popular library [FastAPI Users](https://fastapi-users.github.io/fastapi-users/) and very powerful (yet it require using it for user accounts management).
14+
15+
:bangbang: | This repository contains two different templates to choose from.
16+
:---: | :---
1017

1118
## Minimal async FastAPI + postgresql template
1219

13-
![template-fastapi-minimal-openapi-example](./docs/template-minimal-openapi-example.png)
20+
1421

1522
- SQLAlchemy using new 2.0 API + async queries
1623
- Postgresql database under `asyncpg`
@@ -22,27 +29,24 @@
2229
- `pre-push.sh` script with poetry export, autoflake, black, isort and flake8
2330
- Setup for async tests, one func test for token flow and very extensible `conftest.py`
2431

32+
![template-fastapi-minimal-openapi-example](./docs/template-minimal-openapi-example.png)
33+
2534
## Async FastAPI + postgresql template based on [fastapi-users](https://fastapi-users.github.io/fastapi-users/)
2635

36+
- Extensible base user model
37+
- Ready-to-use register, login, reset password and verify e-mail routes
38+
- Ready-to-use social OAuth2 login flow
2739
- SQLAlchemy using new 2.0 API + async queries
2840
- Postgresql database under `asyncpg`
2941
- Alembic migrations
3042
- Very minimal project structure yet ready for quick start building new api
31-
- Refresh token endpoint (not only access like in official template)
3243
- Two databases in docker-compose.yml (second one for tests)
3344
- poetry
3445
- `pre-push.sh` script with poetry export, autoflake, black, isort and flake8
3546
- Setup for async tests, one func test for token flow and very extensible `conftest.py`
3647

3748
![template-fastapi-users-openapi-example](./docs/template-fastapi-users-openapi-example.png)
3849

39-
## What this repo is
40-
41-
This is a minimal template for FastAPI backend + postgresql db as of 2021.11, `async` style for database sessions, endpoints and tests. It provides basic codebase that almost every application has, but nothing more.
42-
43-
## What this repo is not
44-
45-
It is not complex, full featured solutions for all human kind problems. It doesn't include any third party that isn't necessary for most of apps (dashboards, queues) or implementation differs so much in every project that it's pointless (complex User model, emails, RBAC, permissions).
4650

4751
## Quickstart
4852

@@ -53,6 +57,9 @@ pip install cookiecutter
5357
# And cookiecutter this project :)
5458
cookiecutter https://github.com/rafsaf/minimal-fastapi-postgres-template
5559

60+
# decide if u want fastapi-users based template by
61+
# changing "use_fastapi_users" in cookiecutter option to True, by default it is minimal template.
62+
5663
cd project_name
5764
# Poetry install (and activate environment!)
5865
poetry install
@@ -78,9 +85,11 @@ This project is heavily base on official template https://github.com/tiangolo/fu
7885

7986
`2.0` style SQLAlchemy API is good enough so there is no need to write everything in `crud` and waste our time... The `core` folder was also rewritten. There is great base for writting tests in `tests`, but I didn't want to write hundreds of them, I noticed that usually after changes in the structure of the project, auto tests are useless and you have to write them from scratch anyway (delete old ones...), hence less than more. Similarly with the `User` model, it is very modest, because it will be adapted to the project anyway (and there are no tests for these endpoints, you would remove them probably).
8087

81-
## Step by step example
88+
On January 30 I added another template to this repository, that is based on [FastAPI Users](https://fastapi-users.github.io/fastapi-users/) project. The main assumptions have not changed and project structure is very similar. What it gives is not buggy, extensible, tested Users accounts managing system. This is a lot, if your project needs to manage accounts, this is definitely better than minimal template.
89+
90+
## Step by step example for minimal template
8291

83-
I always enjoy to to have some kind of example in templates (even if I don't like it much, _some_ parts may be useful and save my time...), so let's create `POST` endpoint for creating dogs.
92+
I always enjoy to to have some kind of example in templates (even if I don't like it much, _some_ parts may be useful and save my time...), so let's create `POST` endpoint for creating dogs. For second template, there may be some differences (imports etc.)
8493

8594
### 1. Add `HappyDog` model
8695

0 commit comments

Comments
 (0)