Skip to content

Commit a3961fd

Browse files
committed
docs: update docs for file structures
1 parent 7b791db commit a3961fd

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

README.md

+17-13
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Ultimately the output of this lab will be consumed as the `app` and `worker` for
2929

3030
## Using this template
3131

32-
All `docker-compose` files depend on the following environment variables, which can be set by either exporting them before you run the commands or by declaring them in your `.env` file.
32+
All `docker compose` files depend on the following environment variables, which can be set by either exporting them before you run the commands or by declaring them in your `.env` file.
3333

3434
- `PROJ_NAME` is a prefix that is used to label resources, object stores
3535
- `PROJ_FQDN` is the domain name of the application, this can be set
@@ -120,12 +120,12 @@ Directory structure for our application:
120120
| └─ models/ -- SQLAlchemy models
121121
| └─ dto/ -- Data Transfer Objects
122122
| └─ alembic/ -- Alembic migrations
123-
| └─ __init__.py
124-
| └─ api.py
125-
| └─ broker.py
126-
| └─ config
127-
| └─ db.py
128-
| └─ utils.py
123+
| └─ __init__.py -- FastAPI app
124+
| └─ api.py -- ASGI app that uvicorn serves
125+
| └─ broker.py -- TaskIQ broker configuration
126+
| └─ settings -- pyndatic based settings
127+
| └─ db.py -- SQLALchemy session management
128+
| └─ utils/ -- App wide utility functions
129129
├─ pyproject.toml
130130
├─ poetry.lock
131131
@@ -184,19 +184,23 @@ FastAPI provides a really nice, clean way to build out endpoints. We recommend t
184184
- Provide a summary of the operation (no matter how trivial) which will make for better documentation
185185

186186
```python
187-
from fastapi import APIRouter, Depends,\
188-
HTTPException, Query, status
187+
from fastapi import (
188+
APIRouter,
189+
Depends,
190+
HTTPException,
191+
Query,
192+
status
193+
)
189194

190195
@router.get(
191196
"/{id}",
192197
summary="Get a particular user",
193-
response_model=UserResponse,
194198
status_code=status.HTTP_200_OK
195199
)
196200
async def get_user_by_id(
197201
id: UUID,
198202
session: AsyncSession = Depends(get_async_session)
199-
):
203+
) -> UserResponse:
200204
""" Get a user by their id
201205
202206
@@ -488,7 +492,7 @@ you need to import the following in `env.py`, relative imports don't seem to be
488492

489493
```python
490494
# App level imports
491-
from labs.config import config as app_config
495+
from labs.settings import config as settings
492496
from labs.db import Base
493497
from labs.models import *
494498
```
@@ -501,7 +505,7 @@ and then in `env.py` import the application configuration and set the environmen
501505
config = context.config
502506

503507
# Read the app config and set sqlalchemy.url
504-
config.set_main_option("sqlalchemy.url", app_config.postgres_dsn)
508+
config.set_main_option("sqlalchemy.url", settings.postgres_dsn)
505509
```
506510

507511
lastly you have to assign your `declerative_base` to the `target_metadata` varaible in `env.py`, so find the line:

0 commit comments

Comments
 (0)