Writings

Research

Expository Writing

FastAPI + Injector: A simplified approach to dependency injection in Python

Python, Back-End, Solid, Clean Code, Clean Architecture, Uncle Bob

Python is a dynamically typed language, which means type checking happens at runtime—unlike statically typed languages like C# or Java. This flexibility enables powerful features such as monkey patching, hot swapping, and dynamic class creation. Because of this, dependency injection (DI) is not strictly required in Python applications.

However, DI brings a formal structure to your codebase, especially when using architectural patterns like Domain-Driven Design (DDD) or Hexagonal Architecture. It promotes flexibility by allowing large parts of the code to be replaced or modified without impacting the rest of the system. It also reduces coupling, making the system less dependent on specific implementations. This, in turn, simplifies testing, as modules can be easily mocked.

Projects