Summary
Well done! You should now be comfortable with one of the most iconic features of FastAPI: dependency injections. By implementing your own dependencies, you'll be able to keep common logic that you wish to reuse across your API separate from the endpoints' logic. This will make your project clean and maintainable while retaining maximum readability: dependencies just need to be declared as arguments of the path operation functions, which will help to understand the intent without having to read the body of the function.
Those dependencies can be both simple wrappers to retrieve and validate request parameters, or complex services performing machine learning tasks. Thanks to the class-based approach, you can indeed set dynamic parameters or keep a local state for your most advanced tasks.
Finally, those dependencies can also be used at a router or global level, allowing you to perform common logic or checks for a set of routes or a whole application.
That&apos...