Giter VIP home page Giter VIP logo

fastapi-dependency-tutorial's Introduction

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.

fastapi-dependency-tutorial's People

Contributors

dref360 avatar

Stargazers

Eduardo Diniz avatar José A. Pastor Valera avatar George Pearse avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.