abstracting-fastapi-services
abstracting-fastapi-services copied to clipboard
Why a single app_exceptions.py?
I assume it's nicer to have the ./exceptions/ directory and put each service exception module containing relevant error data.
And if you were to add a new service called Bar:
./routers/ bar.py # Router instance and routes
./services/ bar.py # Business logic (including CRUD helpers)
./schemas/ bar.py # Data "schemas" (e.g., Pydantic models)
./models/ bar.py # Database models (e.g., SQLAlchemy models)
./exceptions/ bar.py # Exceptoins classes completely decoupled