# erwinkramer/bank-api architecture

> Architecture diagram of the GitHub repository erwinkramer/bank-api, 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/erwinkramer/bank-api
- Repository: https://github.com/erwinkramer/bank-api

## Overview

##### Main Components

a) API Layer (Multiple Versions)
- BankApi.Service.Beta
- BankApi.Service.Stable
These should be represented as parallel API endpoints with different versioning

b) Core Layer (BankApi.Core)
Three main subdivisions:
- Defaults (Configuration and Builders)
- Implementation (Business Logic)
- DownstreamClients (External API Integration)

c) Orchestration Layer (BankApi.Orchestration)
- .NET Aspire orchestration component
- Service discovery and configuration

d) Infrastructure Components
- Authentication services (JWT, API Key, OpenID)
- Caching system (Hybrid Cache)
- Rate Limiting
- Compliance Engine
- OpenTelemetry monitoring

e) External Systems
- GitHub API (as downstream service)
- Azure services integration

##### Component Relationships

**[Client Applications]**
- ↓
**[Load Balancer/API Gateway]**
- ↓
**[API Layer]**
- [Beta API Service]
- [Stable API Service]
- ↓
**[Core Layer]**
- [Defaults]
- Authentication
- Rate Limiting
- Error Handling
- [Implementation]
- Bank Operations
- Teller Operations
- [DownstreamClients]
- GitHub Client
- ↓
**[Infrastructure]**
- [Aspire Orchestration]
- [OpenTelemetry]
- [Compliance Engine]
- [Caching System]

##### Technical Details

- ASP.NET Core 9.0 Minimal API framework
- Authentication methods (JWT, API Key, OpenID)
- Health check endpoints
- Rate limiting configuration
- CORS policy
- Gridify integration for data operations
- Kiota-generated clients

##### Documentation Elements

- Version information for major components
- Compliance certification flows
- Document the main data flows
- Error handling paths

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Applications"]
        App[Client Apps]
    end

    subgraph Gateway["API Gateway"]
        LB[Load Balancer]
    end

    subgraph APILayer["API Layer"]
        Beta["Beta API Service"]:::api
        Stable["Stable API Service"]:::api
    end

    subgraph CoreLayer["Core Layer"]
        subgraph Defaults["Defaults & Configuration"]
            Auth["Authentication"]:::core
            RateLimit["Rate Limiting"]:::core
            ErrorHandle["Error Handling"]:::core
            Cors["CORS Policy"]:::core
            AzureConfig["Azure Configuration"]:::core
        end

        subgraph Implementation["Business Logic"]
            BankOps["Bank Operations"]:::core
            TellerOps["Teller Operations"]:::core
            DataOps["Data Operations"]:::core
        end

        subgraph Downstream["Downstream Clients"]
            GitHub["GitHub Client"]:::external
        end
    end

    subgraph Infrastructure["Infrastructure Layer"]
        Aspire["Aspire Orchestration"]:::infra
        OpenTel["OpenTelemetry"]:::infra
        Compliance["Compliance Engine"]:::infra
        Cache["Hybrid Cache"]:::infra
        Testing["API Testing"]:::infra
        InfraTemplates["Infrastructure Templates"]:::infra
    end

    subgraph External["External Systems"]
        GitHubAPI["GitHub API"]:::external
        Azure["Azure Services"]:::external
    end

    subgraph Documentation["Documentation"]
        OpenAPI["OpenAPI Specs"]:::docs
        DownstreamSpecs["Downstream Specs"]:::docs
    end

    %% Relationships
    App --> LB
    LB --> Beta & Stable
    Beta & Stable --> Auth
    Auth --> |Authentication| CoreLayer
    RateLimit --> |Rate Control| CoreLayer
    ErrorHandle --> |Error Management| CoreLayer
    Cors --> |CORS Security| CoreLayer
    AzureConfig --> Azure
    BankOps & TellerOps --> DataOps
    GitHub --> GitHubAPI
    Aspire --> |Orchestration| CoreLayer
    OpenTel --> |Monitoring| CoreLayer
    Compliance --> |Validation| CoreLayer
    Cache --> |Data Caching| CoreLayer

    %% Styling
    classDef api fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef infra fill:#FFE4B5,stroke:#333,stroke-width:2px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef docs fill:#DDA0DD,stroke:#333,stroke-width:2px

    %% Click Events
    click Beta "https://github.com/erwinkramer/bank-api/tree/main/BankApi.Service.Beta/"
    click Stable "https://github.com/erwinkramer/bank-api/tree/main/BankApi.Service.Stable/"
    click Implementation "https://github.com/erwinkramer/bank-api/tree/main/BankApi.Core/Implementation/"
    click Aspire "https://github.com/erwinkramer/bank-api/tree/main/BankApi.Orchestration/"
    click Auth "https://github.com/erwinkramer/bank-api/blob/main/BankApi.Core/Defaults/Builder.Auth.cs"
    click RateLimit "https://github.com/erwinkramer/bank-api/blob/main/BankApi.Core/Defaults/Builder.RateLimit.cs"
    click Compliance "https://github.com/erwinkramer/bank-api/blob/main/BankApi.Core/Defaults/Builder.Compliance.cs"
    click ErrorHandle "https://github.com/erwinkramer/bank-api/blob/main/BankApi.Core/Defaults/Builder.ErrorHandling.cs"
    click Cors "https://github.com/erwinkramer/bank-api/blob/main/BankApi.Core/Defaults/Builder.Cors.cs"
    click GitHub "https://github.com/erwinkramer/bank-api/tree/main/BankApi.Core/DownstreamClients/GitHub/"
    click OpenAPI "https://github.com/erwinkramer/bank-api/tree/main/Specs.Generated/"
    click AzureConfig "https://github.com/erwinkramer/bank-api/blob/main/BankApi.Core/Defaults/Builder.AzureClients.cs"
    click DataOps "https://github.com/erwinkramer/bank-api/blob/main/BankApi.Core/Defaults/Helper.GridPaging.cs"
    click BankOps "https://github.com/erwinkramer/bank-api/blob/main/BankApi.Core/Implementation/Operation.Bank.cs"
    click TellerOps "https://github.com/erwinkramer/bank-api/blob/main/BankApi.Core/Implementation/Operation.Teller.cs"
    click Testing "https://github.com/erwinkramer/bank-api/tree/main/BankApi.Tests/"
    click InfraTemplates "https://github.com/erwinkramer/bank-api/tree/main/Infra.Generated/"
    click DownstreamSpecs "https://github.com/erwinkramer/bank-api/tree/main/Specs.Downstream/"
```
