Skip to content

Commit dcc2f9a

Browse files
committed
readme fixes
Signed-off-by: rafsaf <rafal.safin12@gmail.com>
1 parent 9ee075e commit dcc2f9a

1 file changed

Lines changed: 18 additions & 20 deletions

File tree

README.md

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ _Check out online example: [https://minimal-fastapi-postgres-template.rafsaf.pl]
1515
- [1. Create repository from a template](#1-create-repository-from-a-template)
1616
- [2. Install dependecies with uv](#2-install-dependecies-with-uv)
1717
- [3. Run app](#3-run-app)
18-
- [5. Activate pre-commit](#5-activate-pre-commit)
19-
- [6. Running tests](#6-running-tests)
18+
- [4. Activate pre-commit](#4-activate-pre-commit)
19+
- [5. Running tests](#5-running-tests)
2020
- [Step by step example - POST and GET endpoints](#step-by-step-example---post-and-get-endpoints)
2121
- [1. Create new app](#1-create-new-app)
2222
- [2. Create SQLAlchemy model](#2-create-sqlalchemy-model)
2323
- [3. Import new models.py file in alembic env.py](#3-import-new-modelspy-file-in-alembic-envpy)
24-
- [2. Create and apply alembic migration](#2-create-and-apply-alembic-migration)
25-
- [3. Create request and response schemas](#3-create-request-and-response-schemas)
26-
- [4. Create endpoints](#4-create-endpoints)
27-
- [5. Add Pet model to tests factories](#5-add-pet-model-to-tests-factories)
28-
- [5. Create new test file](#5-create-new-test-file)
29-
- [6. Write tests](#6-write-tests)
24+
- [4. Create and apply alembic migration](#4-create-and-apply-alembic-migration)
25+
- [5. Create request and response schemas](#5-create-request-and-response-schemas)
26+
- [6. Create endpoints](#6-create-endpoints)
27+
- [7. Add Pet model to tests factories](#7-add-pet-model-to-tests-factories)
28+
- [8. Create new test file](#8-create-new-test-file)
29+
- [9. Write tests](#9-write-tests)
3030
- [Design choices](#design-choices)
3131
- [Dockerfile](#dockerfile)
3232
- [Registration](#registration)
@@ -40,8 +40,6 @@ _Check out online example: [https://minimal-fastapi-postgres-template.rafsaf.pl]
4040

4141
## About
4242

43-
This project is heavily based on [the official template](https://github.com/tiangolo/full-stack-fastapi-postgresql) (and on my previous work: [link1](https://github.com/rafsaf/fastapi-plan), [link2](https://github.com/rafsaf/docker-fastapi-projects)), started on Sep 2021 and then updated (more or less) on yearly basis.
44-
4543
If you are curious about latest changes and rationale, read 2026 update blog post: [Update of minimal-fastapi-postgres-template to version 7.0.0](https://rafsaf.pl/blog/2026/02/07/update-of-minimal-fastapi-postgres-template-to-version-7.0.0/).
4644

4745
Enjoy!
@@ -54,8 +52,8 @@ Enjoy!
5452
- [x] Full [Alembic](https://github.com/alembic/alembic) migrations setup (also in unit tests).
5553
- [x] Secure and tested setup for [PyJWT](https://github.com/jpadilla/pyjwt) and [bcrypt](https://github.com/pyca/bcrypt).
5654
- [x] Ready to go Dockerfile with [uvicorn](https://www.uvicorn.org/) webserver.
57-
- [x] [uv](https://docs.astral.sh/uv/getting-started/installation/), [mypy](https://github.com/python/mypy), [pre-commit](https://github.com/pre-commit/pre-commit) hooks with [ruff](https://github.com/astral-sh/ruff)
58-
- [x] Perfect pytest asynchronous test setup with +40 tests and full coverage
55+
- [x] [uv](https://docs.astral.sh/uv/getting-started/installation/), [mypy](https://github.com/python/mypy), [pre-commit](https://github.com/pre-commit/pre-commit) hooks with [ruff](https://github.com/astral-sh/ruff).
56+
- [x] Perfect pytest asynchronous test setup and full coverage.
5957

6058
![template-fastapi-minimal-openapi-example](https://rafsaf.pl/blog/2026/02/07/update-of-minimal-fastapi-postgres-template-to-version-7.0.0/minimal-fastapi-postgres-template-2026-02-07-version-7.0.0.png)
6159

@@ -98,7 +96,7 @@ uvicorn app.main:app --reload
9896

9997
You should then use `git init` (if needed) to initialize git repository and access OpenAPI spec at [http://localhost:8000/](http://localhost:8000/) by default. See last section for customizations.
10098

101-
### 5. Activate pre-commit
99+
### 4. Activate pre-commit
102100

103101
[pre-commit](https://pre-commit.com/) is de facto standard now for pre push activities like isort or black or its nowadays replacement ruff.
104102

@@ -121,7 +119,7 @@ pre-commit run --all-files
121119

122120
```
123121

124-
### 6. Running tests
122+
### 5. Running tests
125123

126124
Note, it will create databases for session and run tests in many processes by default (using pytest-xdist) to speed up execution, based on how many CPU are available in environment.
127125

@@ -190,7 +188,7 @@ import app.pets.models # noqa
190188

191189
```
192190

193-
### 2. Create and apply alembic migration
191+
### 4. Create and apply alembic migration
194192

195193
```bash
196194
### Use below commands in root folder in virtualenv ###
@@ -214,7 +212,7 @@ alembic upgrade head
214212

215213
PS. Note, alembic is configured in a way that it work with async setup and also detects specific column changes if using `--autogenerate` flag.
216214

217-
### 3. Create request and response schemas
215+
### 5. Create request and response schemas
218216

219217
```python
220218
# app/pets/schemas.py
@@ -235,7 +233,7 @@ class PetResponse(BaseModel):
235233

236234
```
237235

238-
### 4. Create endpoints
236+
### 6. Create endpoints
239237

240238
```python
241239
# app/pets/views.py
@@ -305,7 +303,7 @@ app.include_router(pets_router, prefix="/pets", tags=["pets"])
305303

306304
```
307305

308-
### 5. Add Pet model to tests factories
306+
### 7. Add Pet model to tests factories
309307

310308
File `app/tests/factories.py` contains `User` model factory already. Every new DB model should also have it, as it really simplify things later (when you have more models and relationships).
311309

@@ -322,11 +320,11 @@ class PetFactory(SQLAlchemyFactory[Pet]):
322320

323321
```
324322

325-
### 5. Create new test file
323+
### 8. Create new test file
326324

327325
Create folder `app/pet/tests` and inside files `__init__.py` and eg. `test_pets_views.py`.
328326

329-
### 6. Write tests
327+
### 9. Write tests
330328

331329
We will write two really simple tests into new file `test_pets_views.py`
332330

0 commit comments

Comments
 (0)