# thisisnabi/digitalwallet architecture

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

- Interactive diagram: https://gitdiagram.com/thisisnabi/digitalwallet
- Repository: https://github.com/thisisnabi/digitalwallet

## Overview

##### Main components
- API/Endpoint Layer: Represent the various HTTP endpoints that serve as the entry point for operations (e.g., CreateCurrency, IncreaseWalletBalance, CreateWallet, etc.).
- MultiCurrency: Handling currency creation, updating conversion ratios, and retrieving currencies.
- UserWallet: Managing wallet creation, balance retrieval, activation/suspension, change title, and retrieving transactions.
- Transactions: Managing operations like increasing/decreasing wallet balance, wallet funds retrieval, and transaction details.
- Business/Domain Logic: Components like FeatureManagers and domain services (CurrencyService, WalletService, TransactionService) that encapsulate the core business rules.
- Persistence Layer: The WalletDbContext and related migration components, responsible for data persistence using EF Core.
- Cross-Cutting Concerns: Utility/Extension methods, Filters (like the EndpointValidatorFilter), and custom exception handling.

##### Relationships and interactions
- The API/Endpoint Layer receives HTTP requests and passes them onto their respective feature handlers and FeatureManagers.
- Each vertical slice’s components (endpoints, request validators, and managers) coordinate to perform feature-specific operations.
- Business/Domain Logic components interact with the Persistence Layer to read from and write to the database.
- Application-wide cross-cutting modules (such as extensions and filters) integrate into the pipeline affecting all endpoints.

##### Important architectural patterns and design principles
- Vertical Slice Architecture: Emphasize that rather than a traditional layered approach, the application is divided by business capability. Each “slice” encapsulates everything it needs (e.g., endpoint, validation, business logic, and persistence interactions).
- Separation of Concerns: Distinct modules handle API routing, business logic, and data persistence.
- Use of Dependency Injection: The IServiceCollectionExtensions and use of filters likely indicate strong DI practices.
- EF Core for Data Persistence: Showcase that a persistence layer with database migrations is used.

## Diagram (Mermaid)

```mermaid
flowchart TD
    HTTPReq["HTTP Request"]:::bootstrap
    Program["Program.cs"]:::bootstrap

    HTTPReq --> Program

    subgraph "HTTP Endpoints"
        subgraph "MultiCurrency Endpoints"
            mcep1["CreateCurrency Endpoint"]:::endpoints
            mcep2["GetAll Endpoint"]:::endpoints
            mcep3["UpdateRatio Endpoint"]:::endpoints
        end
        subgraph "UserWallet Endpoints"
            uwcep1["CreateWallet Endpoint"]:::endpoints
            uwcep2["Active Endpoint"]:::endpoints
            uwcep3["ChangeTitle Endpoint"]:::endpoints
            uwcep4["GetBalance Endpoint"]:::endpoints
            uwcep5["GetTransactions Endpoint"]:::endpoints
            uwcep6["Suspend Endpoint"]:::endpoints
        end
        subgraph "Transactions Endpoints"
            txncep1["IncreaseWalletBalance Endpoint"]:::endpoints
            txncep2["DecreaseWalletBalance Endpoint"]:::endpoints
            txncep3["WalletFunds Endpoint"]:::endpoints
            txncep4["WalletTransactions Endpoint"]:::endpoints
        end
    end

    subgraph "MultiCurrency Feature"
        MC_FM["MultiCurrency FeatureManager"]:::feature
        MC_Service["CurrencyService"]:::service
    end

    subgraph "UserWallet Feature"
        UW_FM["UserWallet FeatureManager"]:::feature
        UW_Service["WalletService"]:::service
    end

    subgraph "Transactions Feature"
        TXN_FM["Transactions FeatureManager"]:::feature
        TXN_Service["TransactionService"]:::service
    end

    subgraph "Persistence Layer (EF Core)"
        Persist["WalletDbContext"]:::persistence
        Migrations["Migrations"]:::persistence
    end

    subgraph "Cross-Cutting Concerns"
        Cross["Extensions & Filters"]:::crosscut
    end

    subgraph "Testing Layers"
        UnitTest["Unit Tests"]:::testing
        IntTest["Integration Tests"]:::testing
        FuncTest["Functional Tests"]:::testing
    end

    %% Connections from Program to Endpoints
    Program --> mcep1
    Program --> mcep2
    Program --> mcep3
    Program --> uwcep1
    Program --> uwcep2
    Program --> uwcep3
    Program --> uwcep4
    Program --> uwcep5
    Program --> uwcep6
    Program --> txncep1
    Program --> txncep2
    Program --> txncep3
    Program --> txncep4

    %% Connections from Endpoints to Feature Managers
    mcep1 --> MC_FM
    mcep2 --> MC_FM
    mcep3 --> MC_FM

    uwcep1 --> UW_FM
    uwcep2 --> UW_FM
    uwcep3 --> UW_FM
    uwcep4 --> UW_FM
    uwcep5 --> UW_FM
    uwcep6 --> UW_FM

    txncep1 --> TXN_FM
    txncep2 --> TXN_FM
    txncep3 --> TXN_FM
    txncep4 --> TXN_FM

    %% Feature Manager to Domain Service
    MC_FM --> MC_Service
    UW_FM --> UW_Service
    TXN_FM --> TXN_Service

    %% Domain Service to Persistence Layer
    MC_Service --> Persist
    UW_Service --> Persist
    TXN_Service --> Persist

    Persist --> Migrations

    %% Program integrates Cross-Cutting Components
    Program --> Cross

    %% Testing Layers (Verification)
    Program -.-> UnitTest
    Program -.-> IntTest
    Program -.-> FuncTest

    click Program "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Program.cs"
    click mcep1 "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/MultiCurrency/CreateCurrency/Endpoint.cs"
    click mcep2 "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/MultiCurrency/GetAll/Endpoint.cs"
    click mcep3 "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/MultiCurrency/UpdateRatio/Endpoint.cs"
    click txncep1 "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/Transactions/IncreaseWalletBalance/Endpoint.cs"
    click txncep2 "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/Transactions/DecreaseWalletBalance/Endpoint.cs"
    click txncep3 "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/Transactions/WalletFunds/Endpoint.cs"
    click txncep4 "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/Transactions/WalletTransactions/Endpoint.cs"
    click uwcep1 "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/UserWallet/CreateWallet/Endpoint.cs"
    click uwcep2 "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/UserWallet/Active/Endpoint.cs"
    click uwcep3 "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/UserWallet/ChangeTitle/Endpoint.cs"
    click uwcep4 "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/UserWallet/GetBalance/Endpoint.cs"
    click uwcep5 "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/UserWallet/GetTransactions/Endpoint.cs"
    click uwcep6 "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/UserWallet/Suspend/Endpoint.cs"
    click MC_FM "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/MultiCurrency/FeatureManager.cs"
    click UW_FM "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/UserWallet/FeatureManager.cs"
    click TXN_FM "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/Transactions/FeatureManager.cs"
    click MC_Service "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/MultiCurrency/Common/CurrencyService.cs"
    click UW_Service "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/UserWallet/Common/WalletService.cs"
    click TXN_Service "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Features/Transactions/Common/TransactionService.cs"
    click Persist "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Common/Persistence/WalletDbContext.cs"
    click Migrations "https://github.com/thisisnabi/digitalwallet/tree/main/src/DigitalWallet/Common/Persistence/Migrations/"
    click Cross "https://github.com/thisisnabi/digitalwallet/tree/main/src/DigitalWallet/Common/Extensions/"
    click Cross "https://github.com/thisisnabi/digitalwallet/blob/main/src/DigitalWallet/Common/Filters/EndpointValidatorFilter.cs"
    click UnitTest "https://github.com/thisisnabi/digitalwallet/blob/main/tests/DigitalWallet.UnitTests"
    click IntTest "https://github.com/thisisnabi/digitalwallet/blob/main/tests/DigitalWallet.IntegrationTests"
    click FuncTest "https://github.com/thisisnabi/digitalwallet/blob/main/tests/DigitalWallet.FunctionalTests"

    classDef endpoints fill:#AED6F1,stroke:#5DADE2,stroke-width:2px;
    classDef feature fill:#A9DFBF,stroke:#28B463,stroke-width:2px;
    classDef service fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef persistence fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
    classDef crosscut fill:#F5B7B1,stroke:#E74C3C,stroke-width:2px;
    classDef bootstrap fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef testing fill:#D6EAF8,stroke:#3498DB,stroke-width:2px;
```
