This is a multi-tenant backend for FastAPI.
- Clone the repository
- Run
docker-compose up --build
- The backend will be running on
http://0.0.0.0:8000
- Detailed docs at
/redoc
- Clone the repository
- Run
rye sync
- Enter rye shell
- Run
uvicorn main:app --reload
- The backend will be running on
http://0.0.0.0:8000
- Detailed docs at
/redoc
Please note: Naming conventions are very strict and should to followed throughout the project. Moving away from them may cause unexpected results or errors
- The project is setup to accommodate future tenants who can share a high amount of code.
- Tenants in the project are referred to as
Domain
. - They are defined here
- Base models are defined in base_models.py
- To extend on the base models, you can extend them under a new domain folder as in here
- Routers a divided based on the resource in the DB.
- Router actions are encapsulated in controllers
- Each of the resource controller necessarily has a
base_<resource>.py
having a classBase<Resource>
. This is the fallback option which will be initialized in case of no domain specific controller. - Domain specific controllers should be defined in a file named
<domain>_<resource>.py
having a class<Domain><Resource>
. For example,tenanta_user.py
having a classTenantaUser
- Base schemas are defined in schemas. Based on resource
- Every Schema follows the naming convention
Base<SchemaName>
- Domain specific schemas should be defined in respective domain folder schemas for example tenent_a
- Domain specific schemas should be named
<Domain><SchemaName>
domain
: Needs to be provided by the client to gain access to the server and that is enforced using middleware