# menegais1/payment-processing architecture

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

- Interactive diagram: https://gitdiagram.com/menegais1/payment-processing
- Repository: https://github.com/menegais1/payment-processing

## Overview

This is a .NET payment-processing API for customer organizations. The principal workflow is: register and authenticate an organization, create an authorized transaction, persist it for idempotency, publish a processing message, and have a consumer update its status. Clients can also retrieve or synchronously cancel eligible transactions. The graph includes organization authentication, transaction persistence, and queue processing as distinct product stages. Edges are limited to excerpted calls, SOURCE INDEX references, or README statements; unsampled implementation details are not inferred.

Main entry points: [`PaymentProcessing/Program.cs`](https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Program.cs) (Application wiring), [`PaymentProcessing/Controllers/PaymentTransactionController/PaymentTransactionController.cs`](https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Controllers/PaymentTransactionController/PaymentTransactionController.cs) (Transaction endpoints), [`PaymentProcessing.Data/Repositories/Transaction/TransactionRepository.cs`](https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing.Data/Repositories/Transaction/TransactionRepository.cs) (Transaction repository), [`PaymentProcessing/Services/QueueServices/RabbitMqAsyncPaymentTransactionQueue.cs`](https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Services/QueueServices/RabbitMqAsyncPaymentTransactionQueue.cs) (RabbitMQ queue adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and identity"]
  node_org_controller["Organization endpoints"]
  node_auth["JWT authentication"]
  node_program["Application wiring<br/>[Program.cs]"]
end

subgraph group_transactions["Transaction lifecycle"]
  node_tx_controller["Transaction endpoints"]
  node_tx_model["Transaction model<br/>[Transaction.cs]"]
end

subgraph group_data["Persistence"]
  node_org_repo["Organization repository<br/>[Organization]"]
  node_org_model["Organization model<br/>[Organization.cs]"]
  node_tx_repo["Transaction repository"]
  node_db_context[("EF database context")]
end

subgraph group_messaging["Async processing"]
  node_queue_payload["Processing message"]
  node_publisher["RabbitMQ queue adapter"]
  node_worker["Transaction processor"]
end

node_client(("API client"))

node_client -->|"registers or authenticates"| node_org_controller
node_org_controller -->|"creates or validates"| node_org_repo
node_org_controller -->|"generates token"| node_auth
node_org_repo -->|"uses context"| node_db_context
node_org_model -->|"has transactions"| node_tx_model
node_client -->|"creates, reads, cancels"| node_tx_controller
node_tx_controller -->|"checks, saves, updates"| node_tx_repo
node_tx_repo -->|"reads and writes"| node_db_context
node_tx_controller -->|"publishes message"| node_publisher
node_tx_controller -->|"creates payload"| node_queue_payload
node_publisher -->|"serializes payload"| node_queue_payload
node_worker -->|"consumes messages"| node_publisher
node_worker -->|"updates status"| node_tx_repo
node_program -->|"registers queue"| node_publisher
node_program -->|"registers processor"| node_worker
node_program -->|"registers repository"| node_tx_repo
node_program -->|"registers repository"| node_org_repo

click node_org_controller "https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Controllers/OrganizationController/OrganizationController.cs"
click node_auth "https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Services/AuthenticationService.cs"
click node_org_repo "https://github.com/menegais1/payment-processing/tree/master/PaymentProcessing.Data/Repositories/Organization"
click node_org_model "https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing.Data/Models/Organization.cs"
click node_tx_controller "https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Controllers/PaymentTransactionController/PaymentTransactionController.cs"
click node_tx_model "https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing.Data/Models/Transaction.cs"
click node_tx_repo "https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing.Data/Repositories/Transaction/TransactionRepository.cs"
click node_db_context "https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing.Data/Database/PaymentProcessingContext.cs"
click node_queue_payload "https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Services/QueueServices/Schemas/PaymentTransactionMessagePayload.cs"
click node_publisher "https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Services/QueueServices/RabbitMqAsyncPaymentTransactionQueue.cs"
click node_worker "https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Services/PaymentTransactionService.cs"
click node_program "https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Program.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_org_controller,node_auth,node_program,node_client toneBlue
class node_tx_controller,node_tx_model toneAmber
class node_org_repo,node_org_model,node_tx_repo,node_db_context toneMint
class node_queue_payload,node_publisher,node_worker toneRose
```

## Components

### API and identity

- [Organization endpoints](https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Controllers/OrganizationController/OrganizationController.cs): `PaymentProcessing/Controllers/OrganizationController/OrganizationController.cs`
- [JWT authentication](https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Services/AuthenticationService.cs): `PaymentProcessing/Services/AuthenticationService.cs`
- [Application wiring](https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Program.cs): `PaymentProcessing/Program.cs`

### Transaction lifecycle

- [Transaction endpoints](https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Controllers/PaymentTransactionController/PaymentTransactionController.cs): `PaymentProcessing/Controllers/PaymentTransactionController/PaymentTransactionController.cs`
- [Transaction model](https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing.Data/Models/Transaction.cs): `PaymentProcessing.Data/Models/Transaction.cs`

### Persistence

- [Organization repository](https://github.com/menegais1/payment-processing/tree/master/PaymentProcessing.Data/Repositories/Organization): `PaymentProcessing.Data/Repositories/Organization`
- [Organization model](https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing.Data/Models/Organization.cs): `PaymentProcessing.Data/Models/Organization.cs`
- [Transaction repository](https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing.Data/Repositories/Transaction/TransactionRepository.cs): `PaymentProcessing.Data/Repositories/Transaction/TransactionRepository.cs`
- [EF database context](https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing.Data/Database/PaymentProcessingContext.cs): `PaymentProcessing.Data/Database/PaymentProcessingContext.cs`

### Async processing

- [Processing message](https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Services/QueueServices/Schemas/PaymentTransactionMessagePayload.cs): `PaymentProcessing/Services/QueueServices/Schemas/PaymentTransactionMessagePayload.cs`
- [RabbitMQ queue adapter](https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Services/QueueServices/RabbitMqAsyncPaymentTransactionQueue.cs): `PaymentProcessing/Services/QueueServices/RabbitMqAsyncPaymentTransactionQueue.cs`
- [Transaction processor](https://github.com/menegais1/payment-processing/blob/master/PaymentProcessing/Services/PaymentTransactionService.cs): `PaymentProcessing/Services/PaymentTransactionService.cs`

### Other components

- **API client**

## Connections

- API client → Organization endpoints: registers or authenticates (evidence: `README.md`)
- Organization endpoints → Organization repository: creates or validates (evidence: `PaymentProcessing/Controllers/OrganizationController/OrganizationController.cs`)
- Organization endpoints → JWT authentication: generates token (evidence: `PaymentProcessing/Controllers/OrganizationController/OrganizationController.cs`)
- Organization repository → EF database context: uses context (evidence: `PaymentProcessing.Data/Repositories/Organization/OrganizationRepository.cs`)
- Organization model → Transaction model: has transactions (evidence: `PaymentProcessing.Data/Models/Organization.cs`)
- API client → Transaction endpoints: creates, reads, cancels (evidence: `PaymentProcessing/Controllers/PaymentTransactionController/PaymentTransactionController.cs`)
- Transaction endpoints → Transaction repository: checks, saves, updates (evidence: `PaymentProcessing/Controllers/PaymentTransactionController/PaymentTransactionController.cs`)
- Transaction repository → EF database context: reads and writes (evidence: `PaymentProcessing.Data/Repositories/Transaction/TransactionRepository.cs`)
- Transaction endpoints → RabbitMQ queue adapter: publishes message (evidence: `PaymentProcessing/Controllers/PaymentTransactionController/PaymentTransactionController.cs`)
- Transaction endpoints → Processing message: creates payload (evidence: `PaymentProcessing/Controllers/PaymentTransactionController/PaymentTransactionController.cs`)
- RabbitMQ queue adapter → Processing message: serializes payload (evidence: `PaymentProcessing/Services/QueueServices/RabbitMqAsyncPaymentTransactionQueue.cs`)
- Transaction processor → RabbitMQ queue adapter: consumes messages (evidence: `PaymentProcessing/Services/PaymentTransactionService.cs`)
- Transaction processor → Transaction repository: updates status (evidence: `PaymentProcessing/Services/PaymentTransactionService.cs`)
- Application wiring → RabbitMQ queue adapter: registers queue (evidence: `PaymentProcessing/Program.cs`)
- Application wiring → Transaction processor: registers processor (evidence: `PaymentProcessing/Program.cs`)
- Application wiring → Transaction repository: registers repository (evidence: `PaymentProcessing/Program.cs`)
- Application wiring → Organization repository: registers repository (evidence: `PaymentProcessing/Program.cs`)
