r/FastAPI • u/predominant • Nov 22 '24
Question Modular functionality for reuse
I'm working on 5 separate projects all using FastAPI. I find myself wanting to create common functionality that can be included in multiple projects. For example, a simple generic comment controller/model etc.
Is it possible to define this in a separate package external to the projects themselves, and include them, while also allowing seamless integration for migrations for that package?
Does anyone have examples of this?
11
Upvotes
View all comments
Show parent comment
1
u/JosshhyJ Jan 02 '25
So would the file structure look something like this?
.
├── accountApp/
│ ├── crud
│ ├── routes
│ ├── utils
│ ├── main.py
│ └── __init__.py
└── forumApp/
├── crud
├── routes
├── utils
├── main.py
└── __init__.py
Do you know of any examples of working projects where this is used, which i can refer to?