Add comments

This commit is contained in:
2026-05-03 09:14:27 +05:45
parent ebb12e6ab7
commit 0f41a95a70
2 changed files with 27 additions and 4 deletions
+26 -4
View File
@@ -1,5 +1,9 @@
# Template for fastapi backend for aayutech projects # Template for fastapi backend for aayutech projects
Fastapi doesn't ship with support for orm, authentication etc.
This repo implements all the basic tools and their integrations
so we can start from here
## Libraries used ## Libraries used
1. Fastapi 1. Fastapi
2. Alembic 2. Alembic
@@ -8,10 +12,28 @@
## Features ## Features
1. Base user and /login using Oauth2 1. Base user and /login using Oauth2
2. Api logging in audit table table 2. Api logging in audit table
3. Model base class including soft delete, created_at, updated_at 3. Model for base class including soft delete, created_at, updated_at
4. Model auditing by default 4. Table auditing by default
5. Static files routing 5. Static files routing
6. Exception handling
# Code structure
## Utilities
1. the exceptions.py file implmenets ExceptionHandlerRoute, All routes derive from this
2. All routes are included in routes.py
3. background.py includes a write log function that stores all the request response on a table
4. middlewares.py implements a HTTP middleware, it calls background.py's log_api function
### db folder
1. config.py file contains environment files declarations
2. db.py contains database configuration and contains safe_commit function that handles exception while commiting to database
### alembic
Alembic is configured to take the postgresql from .env file
## TODO: ## TODO:
5. Optional multitenant Optional multitenant
Tests
+1
View File
@@ -16,6 +16,7 @@ from .routes import routers, docs
@asynccontextmanager @asynccontextmanager
async def init_db(app: FastAPI): async def init_db(app: FastAPI):
#Create a admin user and password at the beggining
with Session(engine) as session: with Session(engine) as session:
from sqlalchemy import select, insert from sqlalchemy import select, insert
user = session.execute(select(Users).where(Users.username == settings.FIRST_SUPERUSER)).first() user = session.execute(select(Users).where(Users.username == settings.FIRST_SUPERUSER)).first()