# kopilkaiser/bankapplicationku architecture

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

- Interactive diagram: https://gitdiagram.com/kopilkaiser/bankapplicationku
- Repository: https://github.com/kopilkaiser/bankapplicationku

## Overview

##### Main components
- Presentation Layer:
- Client/browser: Users interact with web pages.
- Views: Razor (.cshtml) files in the Views folder (organized by Account, Customer, Home, Shared layouts etc.).
- Controllers: Under the Controllers folder (AccountController.cs, CustomerController.cs, HomeController.cs) that receive HTTP requests and orchestrate responses.
- Business / Application Layer:
- Base classes and Extensions: “Base” folder objects (BaseController.cs, BaseRepository.cs) and extension methods to configure services.
- Services: Contain business logic and cross-cutting concerns like session management and password encryption (SessionManager, PasswordEncrypter, AutoMapperProfile, etc.).
- ViewModels: Responsible for shaping data for the views.
- Data Access Layer:
- Database context and repositories: “Database” folder contains BankAppDbContext.cs and Repository subfolder with classes (AccountRepository, CustomerRepository, TransactionRepository) that encapsulate data access logic using Entity Framework Core.
- Migrations: All Migration files detailing database changes and schema snapshots.
- Interfaces: Abstraction (IBaseRepository) to enforce repository contracts.
- Domain / Model Layer:
- Models: In the Models folder (Bank, Account, Customer, DebitAccount, SavingAccount, Transaction, etc.) representing the domain entities.
- Configuration and Settings:
- appsettings.json (and environment-specific JSON files) for configuration.
- Settings: Specific application settings (CustomerDetailsSetting, GoogleApiSettings).
- Infrastructure and Third-Party Components:
- External libraries: Includes Bootstrap, JQuery, Font Awesome, PopperJS, etc., provided under wwwroot.
- Logging: NLog configuration file (nlog.config).
- External API: References to the Google Map JavaScript API.

- From the web server, show a flow to Controllers which process requests.
- Repositories interact with the EF Core DbContext (BankAppDbContext) which then communicates with the SQL Server database.
- External integrations (e.g., Google Maps API, NLog) should be depicted as separate components that interface with the application (e.g., NLog attached to various layers for logging; Google Maps invoked by views or specific controllers).

##### Architectural Patterns and Key Design Principles
- MVC Pattern: Emphasize the separation between Models, Views, and Controllers.
- Dependency Injection: Note the use of Microsoft’s built-in DI framework (with extension methods from the Extensions folder) that injects dependencies (e.g., services, repositories) into controllers.
- Code-First Entity Framework Approach: Include the migrations and the DbContext to show how the domain models drive the database schema.
- Modularity and Configuration: The use of extension methods for configuring services, seeding data, and utility functions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        A["Browser (Client)"]:::presentation
        B["Views (Razor .cshtml)"]:::presentation
        C["Controllers (Account, Customer, Home)"]:::presentation
    end

    subgraph "Business/Application Layer"
        D["Base Classes (BaseController, BaseRepository)"]:::business
        E["Service Extensions (ConfigureServicesExtension, SeedDataInitializerExtension, UtilitiesExtension)"]:::business
        F["Services (AutoMapperProfile, PasswordEncrypter, SessionManager)"]:::business
        G["ViewModels (AccountViewModel, CustomerViewModel)"]:::business
    end

    subgraph "Data Access Layer"
        H["Repositories (AccountRepository, CustomerRepository, TransactionRepository)"]:::data
        I["Repository Interfaces (IBaseRepository)"]:::data
        J["DbContext (BankAppDbContext)"]:::data
        K["Migrations"]:::data
        L["SQL Server Database"]:::data
    end

    subgraph "Domain/Model Layer"
        M["Models (Bank, Account, Customer, DebitAccount, SavingAccount, Transaction, etc.)"]:::data
    end

    subgraph "Configuration & Settings"
        N["App Configuration Files (appsettings.json, appsettings.Development.json)"]:::config
        O["Application Settings (CustomerDetailsSetting, GoogleApiSettings)"]:::config
    end

    subgraph "Infrastructure"
        P["External Libraries (Bootstrap, JQuery, Font Awesome, etc.)"]:::infra
        Q["NLog Logging"]:::infra
        R["Google Maps API"]:::infra
    end

    %% Flow relationships
    A -->|"HTTPRequest"| C
    C -->|"Render"| B
    C -->|"Uses"| F
    C -->|"Inherits"| D
    F -->|"Calls"| H
    H -->|"Executes"| J
    J -->|"Persists"| L
    H -->|"Implements"| I
    F -->|"Prepares"| G
    E -->|"Configures"| F
    E -->|"Configures"| C
    C -->|"Logs"| Q
    F -->|"Logs"| Q
    H -->|"Logs"| Q
    B -->|"Leverages"| P
    B -->|"Calls"| R
    N -->|"Configures"| F
    N -->|"Configures"| J
    O -->|"Holds"| F
    M -->|"Used_by"| J

    %% Styling
    classDef presentation fill:#FFC107,stroke:#000,stroke-width:2px;
    classDef business fill:#4CAF50,stroke:#000,stroke-width:2px;
    classDef data fill:#03A9F4,stroke:#000,stroke-width:2px;
    classDef config fill:#9C27B0,stroke:#000,stroke-width:2px;
    classDef infra fill:#F44336,stroke:#000,stroke-width:2px;

    %% Click Events
    click B "https://github.com/kopilkaiser/bankapplicationku/tree/master/BankingWebApp/Views"
    click C "https://github.com/kopilkaiser/bankapplicationku/tree/master/BankingWebApp/Controllers"
    click D "https://github.com/kopilkaiser/bankapplicationku/tree/master/BankingWebApp/Base"
    click E "https://github.com/kopilkaiser/bankapplicationku/tree/master/BankingWebApp/Extensions"
    click F "https://github.com/kopilkaiser/bankapplicationku/tree/master/BankingWebApp/Services"
    click G "https://github.com/kopilkaiser/bankapplicationku/tree/master/BankingWebApp/ViewModels"
    click J "https://github.com/kopilkaiser/bankapplicationku/blob/master/BankingWebApp/Database/BankAppDbContext.cs"
    click H "https://github.com/kopilkaiser/bankapplicationku/tree/master/BankingWebApp/Database/Repositories"
    click I "https://github.com/kopilkaiser/bankapplicationku/tree/master/BankingWebApp/Interfaces"
    click K "https://github.com/kopilkaiser/bankapplicationku/tree/master/BankingWebApp/Migrations"
    click M "https://github.com/kopilkaiser/bankapplicationku/tree/master/BankingWebApp/Models"
    click N "https://github.com/kopilkaiser/bankapplicationku/blob/master/BankingWebApp/appsettings.json"
    click O "https://github.com/kopilkaiser/bankapplicationku/tree/master/BankingWebApp/Settings"
    click Q "https://github.com/kopilkaiser/bankapplicationku/blob/master/BankingWebApp/nlog.config"
    click P "https://github.com/kopilkaiser/bankapplicationku/tree/master/BankingWebApp/wwwroot"
    click R "https://github.com/kopilkaiser/bankapplicationku/blob/master/BankingWebApp/wwwroot/js/loadGoogleMap.js"
```
