diff --git a/README.md b/README.md index 6fe1f45..7126d47 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # 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 1. Fastapi 2. Alembic @@ -8,10 +12,28 @@ ## Features 1. Base user and /login using Oauth2 -2. Api logging in audit table table -3. Model base class including soft delete, created_at, updated_at -4. Model auditing by default +2. Api logging in audit table +3. Model for base class including soft delete, created_at, updated_at +4. Table auditing by default 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: -5. Optional multitenant +Optional multitenant +Tests diff --git a/app/main.py b/app/main.py index 69e006f..5434bb9 100644 --- a/app/main.py +++ b/app/main.py @@ -16,6 +16,7 @@ from .routes import routers, docs @asynccontextmanager async def init_db(app: FastAPI): + #Create a admin user and password at the beggining with Session(engine) as session: from sqlalchemy import select, insert user = session.execute(select(Users).where(Users.username == settings.FIRST_SUPERUSER)).first()