# modern-python/that-depends architecture

> Architecture diagram of the GitHub repository modern-python/that-depends, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/modern-python/that-depends
- Repository: https://github.com/modern-python/that-depends

## Overview

##### Main Components

a) Core Framework Components:
- Container System
- BaseContainer (core class)
- Dynamic Container Support
- Multiple Containers Support

b) Providers Layer:
- Resource Providers
- Singleton Providers
- Factory Providers
- Collection Providers
- Context Resources
- Selector Providers
- Object Providers

c) Integration Components:
- FastAPI Integration
- LiteStar Integration
- FastStream Integration

d) Injection System:
- Dependency Resolver
- Injection Mechanism
- Provider Resolution System

**┌─ Framework Integrations Layer ─────┐**
- FastAPI  │  LiteStar │ FastStream │
- ┤
- Injection System Layer       │
- ┤
- Providers Layer            │
- ┤
- Core Container            │
- ┘

##### Key Relationships

- Blue: Core components
- Green: Providers
- Orange: Integration points
- Purple: Injection system

##### Specific Implementation Details

a) Core Container Section:
- BaseContainer as the central component
- Resource Context management
- Multiple Container support

b) Providers Section:
- Providers by type (Singleton, Factory, Resource, etc.)
- Inheritance from base Provider class
- Async/sync support capabilities

c) Injection System:
- Injection decorator flow
- Resolver mechanisms
- Provider resolution paths

##### Additional Elements

- Version compatibility information (Python 3.10-3.13)
- Zero-dependency nature of the package
- Async-first architecture

##### Technical Details

- Provider resolution mechanisms
- Resource initialization flows
- Async/sync support paths
- Container inheritance patterns

For the principal software engineer, emphasize:
##### The testing support features

Remember to include notes about:
- Type safety mechanisms
- Resource lifecycle management
- Container initialization patterns
- Integration patterns with supported frameworks

This will create a comprehensive yet clear representation of the "That Depends" framework's architecture while maintaining focus on its key features and design principles.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#b3d1ff,stroke:#333,stroke-width:2px
    classDef provider fill:#90EE90,stroke:#333,stroke-width:2px
    classDef integration fill:#FFB366,stroke:#333,stroke-width:2px
    classDef injection fill:#DDA0DD,stroke:#333,stroke-width:2px

    %% Core Container Layer
    subgraph CoreLayer["Core Container Layer"]
        BaseContainer["Base Container"]:::core
        DynamicContainer["Dynamic Container Support"]:::core
        MultiContainer["Multiple Containers Support"]:::core
        ResourceContext["Resource Context Management"]:::core
    end

    %% Providers Layer
    subgraph ProvidersLayer["Providers Layer"]
        direction TB
        ResourceProv["Resource Providers"]:::provider
        SingletonProv["Singleton Providers"]:::provider
        FactoryProv["Factory Providers"]:::provider
        CollectionProv["Collection Providers"]:::provider
        ContextProv["Context Resources"]:::provider
        SelectorProv["Selector Providers"]:::provider
        ObjectProv["Object Providers"]:::provider
    end

    %% Injection System Layer
    subgraph InjectionLayer["Injection System Layer"]
        InjectionSystem["Injection System"]:::injection
        DependencyResolver["Dependency Resolver"]:::injection
    end

    %% Framework Integrations Layer
    subgraph IntegrationsLayer["Framework Integrations Layer"]
        FastAPI["FastAPI Integration"]:::integration
        LiteStar["LiteStar Integration"]:::integration
        FastStream["FastStream Integration"]:::integration
    end

    %% Relationships
    BaseContainer --> ResourceContext
    BaseContainer --> DynamicContainer
    BaseContainer --> MultiContainer
    
    ProvidersLayer --> InjectionSystem
    InjectionSystem --> DependencyResolver
    
    InjectionLayer --> IntegrationsLayer

    %% Click Events
    click BaseContainer "https://github.com/modern-python/that-depends/blob/main/that_depends/container.py"
    click DynamicContainer "https://github.com/modern-python/that-depends/blob/main/that_depends/container.py"
    click MultiContainer "https://github.com/modern-python/that-depends/blob/main/tests/test_multiple_containers.py"
    click ResourceProv "https://github.com/modern-python/that-depends/blob/main/that_depends/providers/resources.py"
    click SingletonProv "https://github.com/modern-python/that-depends/blob/main/that_depends/providers/singleton.py"
    click FactoryProv "https://github.com/modern-python/that-depends/blob/main/that_depends/providers/factories.py"
    click CollectionProv "https://github.com/modern-python/that-depends/blob/main/that_depends/providers/collections.py"
    click ContextProv "https://github.com/modern-python/that-depends/blob/main/that_depends/providers/context_resources.py"
    click SelectorProv "https://github.com/modern-python/that-depends/blob/main/that_depends/providers/selector.py"
    click ObjectProv "https://github.com/modern-python/that-depends/blob/main/that_depends/providers/object.py"
    click FastAPI "https://github.com/modern-python/that-depends/tree/main/tests/integrations/fastapi"
    click LiteStar "https://github.com/modern-python/that-depends/tree/main/tests/integrations/litestar"
    click FastStream "https://github.com/modern-python/that-depends/tree/main/tests/integrations/faststream"
    click InjectionSystem "https://github.com/modern-python/that-depends/blob/main/that_depends/injection.py"
    click DependencyResolver "https://github.com/modern-python/that-depends/blob/main/tests/test_resolver.py"
    click ResourceContext "https://github.com/modern-python/that-depends/blob/main/that_depends/entities/resource_context.py"

    %% Legend
    subgraph Legend
        CoreComp["Core Components"]:::core
        ProviderComp["Providers"]:::provider
        IntegrationComp["Integrations"]:::integration
        InjectionComp["Injection Components"]:::injection
    end
```
