# jameslilliott/bank-app architecture

> Architecture diagram of the GitHub repository jameslilliott/bank-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jameslilliott/bank-app
- Repository: https://github.com/jameslilliott/bank-app

## Overview

##### Project Type Analysis
This is a .NET solution following a Domain-Driven Design (DDD) and Clean Architecture approach, specifically focused on banking transactions. The project is structured in multiple layers with clear separation of concerns.

##### Main Components

A. Domain Layer (Core)
- Domain entities:
- Transaction
- TransactionType
- TransactionSource
- Domain services:
- TransactionService
- Interfaces:
- ITransactionRepository

B. Infrastructure Layer
- SqlRepository below the domain layer
- Include:
- AppContext (Entity Framework Context)
- SqlTransactionRepository (Implementation of ITransactionRepository)

C. Test Layer
- This as a separate component showing test coverage for:
- Balance operations
- Deposit functionality
- Withdraw operations
- SendMoney transactions

**┌─────────────────────────────────────────┐**
- Test Layer                 │
- ┘
- ↓
**┌─────────────────────────────────────────┐**
- Domain Layer                 │
- ┌─────────────┐      ┌──────────────┐  │
- Entities   │      │   Services   │  │

- ┘      └──────────────┘  │
- ┌─────────────┐                        │
- Interfaces  │                        │
- ┘                        │
- ┘
- ↓
**┌─────────────────────────────────────────┐**
- Infrastructure Layer            │
- ┌─────────────────────────────────────┐ │
- SQL Repository               │ │
- ┘ │
- ┘

##### Component Relationships
- That SqlTransactionRepository implements ITransactionRepository
- That TransactionService depends on ITransactionRepository
- How the Test layer interacts with both Domain and Infrastructure layers

##### Additional Details
- Entity Framework Core usage in SqlRepository
- Migration capabilities
- CRUD operations flow through the layers
- Transaction types supported (derived from test cases):
- Deposits
- Withdrawals
- Money Transfers
- Balance Checks

##### Technical Stack Indicators
- .NET Core
- Entity Framework Core
- SQL Server (implied by SqlRepository)
- xUnit (implied by test project structure)

##### Key Design Patterns to Highlight
- Repository Pattern (ITransactionRepository)
- Factory Pattern (AppContextFactory)
- Domain-Driven Design
- Clean Architecture

Remember to:
- Use consistent styling
- Notes for any specific implementation details
- Direction of dependency flow (following dependency inversion principle)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef domain fill:#e1f5fe,stroke:#01579b
    classDef infra fill:#e8f5e9,stroke:#1b5e20
    classDef test fill:#fff3e0,stroke:#e65100
    classDef interface fill:#f3e5f5,stroke:#4a148c
    
    %% Test Layer
    subgraph TestLayer["Test Layer"]
        Balance["Balance Tests"]
        Deposit["Deposit Tests"]
        Withdraw["Withdraw Tests"]
        SendMoney["SendMoney Tests"]
    end

    %% Domain Layer
    subgraph DomainLayer["Domain Layer"]
        subgraph Entities["Domain Entities"]
            Transaction["Transaction"]
            TransactionType["TransactionType"]
            TransactionSource["TransactionSource"]
            Result["Result Handler"]
            DataResult["Data Result Handler"]
        end

        subgraph Services["Domain Services"]
            TransactionService["Transaction Service"]
        end

        subgraph Interfaces["Domain Interfaces"]
            ITransactionRepo["ITransactionRepository"]
        end
    end

    %% Infrastructure Layer
    subgraph InfraLayer["Infrastructure Layer"]
        subgraph SqlRepo["SQL Repository"]
            AppContext["App Context"]
            AppContextFactory["Context Factory"]
            SqlTransactionRepo["SQL Transaction Repository"]
            Migrations["Database Migrations"]
        end
    end

    %% Relationships
    TestLayer --> DomainLayer
    TestLayer --> InfraLayer
    TransactionService --> ITransactionRepo
    SqlTransactionRepo --> ITransactionRepo
    AppContextFactory --> AppContext
    SqlTransactionRepo --> AppContext

    %% Click Events
    click Transaction "https://github.com/JamesLilliott/bank-app/blob/main/Domain/Transaction.cs"
    click TransactionType "https://github.com/JamesLilliott/bank-app/blob/main/Domain/TransactionType.cs"
    click TransactionSource "https://github.com/JamesLilliott/bank-app/blob/main/Domain/TransactionSource.cs"
    click TransactionService "https://github.com/JamesLilliott/bank-app/blob/main/Domain/TransactionService.cs"
    click ITransactionRepo "https://github.com/JamesLilliott/bank-app/blob/main/Domain/ITransactionRepository.cs"
    click Result "https://github.com/JamesLilliott/bank-app/blob/main/Domain/Result.cs"
    click DataResult "https://github.com/JamesLilliott/bank-app/blob/main/Domain/DataResult.cs"
    click AppContext "https://github.com/JamesLilliott/bank-app/blob/main/SqlRepository/AppContext.cs"
    click AppContextFactory "https://github.com/JamesLilliott/bank-app/blob/main/SqlRepository/AppContextFactory.cs"
    click SqlTransactionRepo "https://github.com/JamesLilliott/bank-app/blob/main/SqlRepository/SqlTransactionRepository.cs"
    click Migrations "https://github.com/JamesLilliott/bank-app/blob/main/SqlRepository/Migrations/20241016195910_Initial.cs"
    click Balance "https://github.com/JamesLilliott/bank-app/blob/main/Tests/Balance.cs"
    click Deposit "https://github.com/JamesLilliott/bank-app/blob/main/Tests/Deposit.cs"
    click Withdraw "https://github.com/JamesLilliott/bank-app/blob/main/Tests/Withdraw.cs"
    click SendMoney "https://github.com/JamesLilliott/bank-app/blob/main/Tests/SendMoney.cs"

    %% Apply Classes
    class Balance,Deposit,Withdraw,SendMoney test
    class Transaction,TransactionType,TransactionSource,Result,DataResult,TransactionService domain
    class AppContext,AppContextFactory,SqlTransactionRepo,Migrations infra
    class ITransactionRepo interface
```
