It's not clear from your post what is
framework layer
, but in general it is a good practice to separate database layer from business logic, and to separate those two from API. It seems this is what you are trying to achieve. I'm not sure if your question fits well for stackoverflow, and maybe it could be addressed better on
softwareengineering.stackexchange.com ? As a bonus, I would think about
separation of concerns design principle here, and I would ask the question: does the
service layer
need to know details of SQLAlchemy? —
Konrad Talik 16 secs ago