# devmentors/inflow architecture

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

- Interactive diagram: https://gitdiagram.com/devmentors/inflow
- Repository: https://github.com/devmentors/inflow

## Overview

##### High-Level Architecture Components

a) Bootstrapper Layer (Top)
- Entry point for the application
- Module initialization
- Configuration management
- API exposure

b) Module Layer (Middle)
- Customers Module
- Payments Module
- Wallets Module
- Users Module
- Saga Module

c) Shared Infrastructure Layer (Bottom)
- Abstractions
- Infrastructure components
- Cross-cutting concerns

##### Module Internal Structure
Each module should be represented with these components:

- API Layer (Controllers)
- Application Layer (Commands/Queries)
- Domain Layer (Entities/Value Objects)
- Infrastructure Layer (Repositories/DB)

##### Integration Patterns

Following connections:
- Database connections
- Message broker interactions

##### Specific Implementation Details

Key architectural elements:
- PostgreSQL databases (one per module)
- Event dispatchers
- Command/Query handlers
- Domain events flow
- Saga orchestration patterns

##### Component Relationships

- Customer verification flow
- Payment processing flow
- Wallet transactions
- User authentication flow

##### Technical Details

Implementation specifics:
- CQRS pattern implementation
- Domain-Driven Design boundaries
- Event sourcing flows
- Outbox pattern implementation
- Authentication/Authorization flow

##### Clear boundary contexts

Remember to maintain a balance between detail and clarity, focusing on the modular monolith architecture while showing how the modules interact through events and shared infrastructure.

This system design should reflect the application's modular nature while showing how it maintains cohesion through well-defined integration patterns and shared components.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Bootstrapper
        B1[Program]:::bootstrapper
        B2[Startup]:::bootstrapper
    end

    subgraph Modules
        subgraph CustomersModule
            C1["API"]:::api
            C2["Commands/Queries"]:::logic
            C3["Domain"]:::domain
            C4[(Database)]:::database
        end

        subgraph PaymentsModule
            P1["API"]:::api
            P2["Commands/Queries"]:::logic
            P3["Domain"]:::domain
            P4[(Database)]:::database
        end

        subgraph WalletsModule
            W1["API"]:::api
            W2["Commands/Queries"]:::logic
            W3["Domain"]:::domain
            W4[(Database)]:::database
        end

        subgraph UsersModule
            U1["API"]:::api
            U2["Commands/Queries"]:::logic
            U3["Domain"]:::domain
            U4[(Database)]:::database
        end

        subgraph SagaModule
            S1["API"]:::api
            S2["Saga Orchestration"]:::saga
        end
    end

    subgraph SharedInfrastructure
        SI1["Abstractions"]:::shared
        SI2["Infrastructure"]:::shared
        SI3["Authentication"]:::security
        SI4["Messaging/Event Bus"]:::messaging
        SI5["Database Common"]:::database
        SI6["Caching"]:::cache
        SI7["Security"]:::security
    end

    %% Connections
    B1 --> B2
    B2 --> |Initialize| C1
    B2 --> |Initialize| P1
    B2 --> |Initialize| W1
    B2 --> |Initialize| U1
    B2 --> |Initialize| S1

    %% Module Internal Connections
    C1 --> C2
    C2 --> C3
    C3 --> C4

    P1 --> P2
    P2 --> P3
    P3 --> P4

    W1 --> W2
    W2 --> W3
    W3 --> W4

    U1 --> U2
    U2 --> U3
    U3 --> U4

    %% Saga Connections
    S1 --> S2
    S2 -.-> |Orchestrate| C1
    S2 -.-> |Orchestrate| P1
    S2 -.-> |Orchestrate| W1

    %% Shared Infrastructure Usage
    C1 --> SI1
    P1 --> SI1
    W1 --> SI1
    U1 --> SI1

    SI2 --> SI3
    SI2 --> SI4
    SI2 --> SI5
    SI2 --> SI6
    SI2 --> SI7

    %% Click Events
    click B1 "https://github.com/devmentors/Inflow/blob/master/src/Bootstrapper/Inflow.Bootstrapper/Program.cs"
    click B2 "https://github.com/devmentors/Inflow/blob/master/src/Bootstrapper/Inflow.Bootstrapper/Startup.cs"
    
    click C1 "https://github.com/devmentors/Inflow/blob/master/src/Modules/Customers/Inflow.Modules.Customers.Api"
    click C2 "https://github.com/devmentors/Inflow/tree/master/src/Modules/Customers/Inflow.Modules.Customers.Core/Commands"
    click C3 "https://github.com/devmentors/Inflow/tree/master/src/Modules/Customers/Inflow.Modules.Customers.Core/Domain"
    
    click P1 "https://github.com/devmentors/Inflow/blob/master/src/Modules/Payments/Inflow.Modules.Payments.Api"
    click P3 "https://github.com/devmentors/Inflow/tree/master/src/Modules/Payments/Inflow.Modules.Payments.Core/Deposits/Domain"
    click P4 "https://github.com/devmentors/Inflow/tree/master/src/Modules/Payments/Inflow.Modules.Payments.Core/DAL"
    
    click W1 "https://github.com/devmentors/Inflow/blob/master/src/Modules/Wallets/Inflow.Modules.Wallets.Api"
    click W3 "https://github.com/devmentors/Inflow/tree/master/src/Modules/Wallets/Inflow.Modules.Wallets.Core/Wallets/Domain"
    
    click U1 "https://github.com/devmentors/Inflow/blob/master/src/Modules/Users/Inflow.Modules.Users.Api"
    click U3 "https://github.com/devmentors/Inflow/tree/master/src/Modules/Users/Inflow.Modules.Users.Core/Entities"
    click U4 "https://github.com/devmentors/Inflow/tree/master/src/Modules/Users/Inflow.Modules.Users.Core/DAL"
    
    click S1 "https://github.com/devmentors/Inflow/blob/master/src/Modules/Saga/Inflow.Modules.Saga.Api"
    click S2 "https://github.com/devmentors/Inflow/tree/master/src/Modules/Saga/Inflow.Modules.Saga.Api/Sagas"
    
    click SI1 "https://github.com/devmentors/Inflow/blob/master/src/Shared/Inflow.Shared.Abstractions"
    click SI2 "https://github.com/devmentors/Inflow/blob/master/src/Shared/Inflow.Shared.Infrastructure"
    click SI3 "https://github.com/devmentors/Inflow/tree/master/src/Shared/Inflow.Shared.Infrastructure/Auth"
    click SI4 "https://github.com/devmentors/Inflow/tree/master/src/Shared/Inflow.Shared.Infrastructure/Messaging"
    click SI5 "https://github.com/devmentors/Inflow/tree/master/src/Shared/Inflow.Shared.Infrastructure/Postgres"
    click SI6 "https://github.com/devmentors/Inflow/tree/master/src/Shared/Inflow.Shared.Infrastructure/Cache"
    click SI7 "https://github.com/devmentors/Inflow/tree/master/src/Shared/Inflow.Shared.Infrastructure/Security"

    %% Styles
    classDef api fill:#2374AB
    classDef logic fill:#57A773
    classDef domain fill:#484D6D
    classDef database fill:#F7B32B
    classDef saga fill:#9067C6
    classDef shared fill:#8C271E
    classDef security fill:#D65108
    classDef messaging fill:#6B0F1A
    classDef cache fill:#B497D6
    classDef bootstrapper fill:#05668D
```
