# adrianuscharlie/.net-api-services architecture

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

- Interactive diagram: https://gitdiagram.com/adrianuscharlie/.net-api-services
- Repository: https://github.com/adrianuscharlie/.net-api-services

## Overview

##### Project Type & Purpose
- The project is a full-stack back-end API built with .NET Core 8. It aggregates cashout and reversal transactions and works as an intermediary between client APIs and partner APIs.
- The system is designed to support partner-specific transaction requirements, JWT/B2B authentication, structured logging (Serilog), and Redis caching. It is containerized with Docker for deployment ease.

##### Analyzing the File Structure
- There are two primary source code directories under “src”:
– CashoutServices: Contains controllers (Cashout, Reversal), services (e.g., RedisServices, PartnerHandler, CashoutServices, KredigramServices), models, certificate management, and a Dockerfile.
– PartnerAPI: Contains similar elements (controllers, models, certificates, and Dockerfile) to handle partner-specific API operations.
- Additional files such as the solution files (*.sln), Docker Compose files, launchSettings, and appsettings indicate an infrastructure that supports both local development and containerized deployments.
- The “DB” folder holds the SQL file for the database schema, and there are explicit configuration files (appsettings.json, appsettings.Development.json) for environmental settings.

##### Key Components in the Architecture
a. CashoutServices API:
– Controllers for Cashout and Reversal transactions.
– Service layer for handling business logic (e.g., CashoutServices, Redis-based caching, and partner-specific processing).
– Certificate management for secure partner communication.
b. PartnerAPI Service:
– Provides endpoints and logic to interact with partner systems (e.g., additional controllers, certificate components).
c. Database:
– MySQL (or related SQL engine) is suggested by the cashoutservices.sql file for persisting transaction data.
d. External Services & Infrastructure:
– JWT/B2B authentication mechanism.
– Redis DB for caching tokens.
– Docker containerization and orchestration through Docker Compose.
– Logging and error handling, likely using structured logging (Serilog).

##### Diagramming the System
– Client/API Consumers: Illustrate external clients/partners interacting over HTTP.
– API Gateway/Entry Point: Represents the end points exposed by CashoutServices and PartnerAPI.
– CashoutServices Module: Highlight the controllers, services, and helper components (e.g., PartnerHandler, RedisServices).
– PartnerAPI Module: Similar breakdown as above but tailored for partner interactions.
– Database (MySQL): Indicate the database schema source from cashoutservices.sql.
– Redis Cache: Emphasize the use of Redis for B2B token caching.
– How client requests flow into the respective API endpoints.
– Interactions from CashoutServices to the database and external caching.
– Communication with PartnerAPI where CashoutServices aggregates responses from customized partner processing.
- Notes on authentication/authorization flow (JWT based) and error handling/reporting paths.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Client/API Consumers"]:::external

    subgraph "CashoutServices API Module"
        CS1["Cashout Controller"]:::api_cashout
        CS2["Reversal Controller"]:::api_cashout
        CS_services["Service Layer"]:::api_cashout
        CS3["Certificate Management"]:::api_cashout
        CS4["Docker Container"]:::api_cashout
    end

    subgraph "PartnerAPI Service Module"
        PA1["B2BTokencs Controller"]:::api_partner
        PA2["Cashout Controller"]:::api_partner
        PA3["Reversal Controller"]:::api_partner
        PA4["Certificate Components"]:::api_partner
        PA5["Docker Container"]:::api_partner
    end

    DB["Database (cashoutservices.sql)"]:::infra
    Redis["Redis Cache"]:::infra
    Docker["Docker Compose Orchestration"]:::infra

    A -->|"HTTP_Request"| CS1
    A -->|"HTTP_Request"| PA1

    CS1 -->|"Calls_Service"| CS_services
    CS2 -->|"Calls_Service"| CS_services
    CS_services -->|"Executes_Logic"| DB
    CS_services -->|"Caches_Tokens"| Redis
    CS1 -.->|"Delegates_To_Partner"| PA2

    CS4 -->|"Managed_By"| Docker
    PA5 -->|"Managed_By"| Docker

    click CS1 "https://github.com/adrianuscharlie/.net-api-services/blob/main/src/CashoutServices/Controllers/Cashout.cs"
    click CS2 "https://github.com/adrianuscharlie/.net-api-services/blob/main/src/CashoutServices/Controllers/Reversal.cs"
    click CS_services "https://github.com/adrianuscharlie/.net-api-services/tree/main/src/CashoutServices/Services"
    click CS3 "https://github.com/adrianuscharlie/.net-api-services/tree/main/src/CashoutServices/Certificate"
    click CS4 "https://github.com/adrianuscharlie/.net-api-services/tree/main/src/CashoutServices/Dockerfile"

    click PA1 "https://github.com/adrianuscharlie/.net-api-services/blob/main/src/PartnerAPI/Controllers/B2BTokencs.cs"
    click PA2 "https://github.com/adrianuscharlie/.net-api-services/blob/main/src/PartnerAPI/Controllers/Cashout.cs"
    click PA3 "https://github.com/adrianuscharlie/.net-api-services/blob/main/src/PartnerAPI/Controllers/Reversal.cs"
    click PA4 "https://github.com/adrianuscharlie/.net-api-services/tree/main/src/PartnerAPI/Certificates"
    click PA5 "https://github.com/adrianuscharlie/.net-api-services/tree/main/src/PartnerAPI/Dockerfile"

    click DB "https://github.com/adrianuscharlie/.net-api-services/blob/main/DB/cashoutservices.sql"
    click Redis "https://github.com/adrianuscharlie/.net-api-services/blob/main/src/CashoutServices/Services/RedisServices.cs"
    click Docker "https://github.com/adrianuscharlie/.net-api-services/blob/main/docker-compose.yml"

    classDef external fill:#ccf,stroke:#333,stroke-width:2px;
    classDef api_cashout fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef api_partner fill:#aed6f1,stroke:#333,stroke-width:2px;
    classDef infra fill:#fad7a0,stroke:#333,stroke-width:2px;
```
