Skip to content

Dref360/fastapi-dependency-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Real-life example of Dependency Injection using FastAPI

Author: Frederic Branchaud-Charron (@Dref360)

Goal: Provide an real-world example of a dependency injection setup.

In this tutorial, we will visit a usecase often seen in production. Your customers probably store their data in different systems which makes it hard for your system to know where to look.

Our App will use Dependency Injection to fetch our customers' deals from multiple CRM (Salesforce or Hubspot).

Resources

Dependency Injection (DI) is a Design Pattern well used in Industry and in particular in "Enterprise Languages" such as Java or C#.

The objective of using DI is to make a class independent of its dependencies.SOLID principles are easily followed when using this pattern.

DI has many advantages:

  • Dependencies are reusable.
  • Dependencies can be mocked, allowing easier testing of a class.

Why this tutorial?

The most common example of DI is the "Logger" example which I find uninspiring and doesn't teach you why you should use DI. I wanted to propose a practical example that anyone can easily understand.

About

Real-life example of Dependency Injection using FastAPI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages