# herneto/receptor_prt architecture

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

- Interactive diagram: https://gitdiagram.com/herneto/receptor_prt
- Repository: https://github.com/herneto/receptor_prt

## Overview

This Elixir application bridges a PRT TCP session to a configured HTTP payment API. It opens a session, reads framed PRT requests, dispatches each through a pooled GenServer worker, and sends the configured field from the HTTP response back over the session. YAML supplies the PRT and API settings. The sampled source shows the request and response path; the README gives no further capability detail, and unsampled YAML contents are not assumed.

Main entry points: [`lib/poolboy_prt/worker.ex`](https://github.com/herneto/receptor_prt/blob/main/lib/poolboy_prt/worker.ex) (HTTP worker), [`lib/receptor_prt.ex`](https://github.com/herneto/receptor_prt/blob/main/lib/receptor_prt.ex) (Session and framing), [`lib/receptor_prt/application.ex`](https://github.com/herneto/receptor_prt/blob/main/lib/receptor_prt/application.ex) (Application supervisor), [`lib/receptor_prt/config.ex`](https://github.com/herneto/receptor_prt/blob/main/lib/receptor_prt/config.ex) (Config loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["PRT Gateway"]
  node_gateway_session["Session and framing<br/>[receptor_prt.ex]"]
  node_request_dispatch["Request dispatch<br/>[receptor_prt.ex]"]
  node_response_relay["Response relay<br/>[receptor_prt.ex]"]
  node_application["Application supervisor<br/>[application.ex]"]
end

subgraph group_http["HTTP Bridge"]
  node_worker_pool["Worker pool<br/>[application.ex]"]
  node_http_worker["HTTP worker<br/>[worker.ex]"]
end

subgraph group_config["Configuration"]
  node_yaml_config["Application YAML<br/>[receptor_app.yaml]"]
  node_config_loader["Config loader<br/>[config.ex]"]
end

node_prt_client(("PRT peer"))
node_payment_api(("Payment API"))

node_prt_client -->|"sends frames"| node_gateway_session
node_gateway_session -->|"opens session"| node_prt_client
node_gateway_session -->|"dispatches request"| node_request_dispatch
node_request_dispatch -->|"checks out worker"| node_worker_pool
node_request_dispatch -->|"calls worker"| node_http_worker
node_http_worker -->|"posts request"| node_payment_api
node_http_worker -->|"sends response"| node_response_relay
node_response_relay -->|"writes response"| node_prt_client
node_application -->|"loads settings"| node_config_loader
node_config_loader -->|"reads YAML"| node_yaml_config
node_application -->|"starts session task"| node_gateway_session
node_application -->|"starts pool"| node_worker_pool
node_http_worker -->|"loads API settings"| node_config_loader

click node_gateway_session "https://github.com/herneto/receptor_prt/blob/main/lib/receptor_prt.ex"
click node_request_dispatch "https://github.com/herneto/receptor_prt/blob/main/lib/receptor_prt.ex"
click node_response_relay "https://github.com/herneto/receptor_prt/blob/main/lib/receptor_prt.ex"
click node_worker_pool "https://github.com/herneto/receptor_prt/blob/main/lib/receptor_prt/application.ex"
click node_http_worker "https://github.com/herneto/receptor_prt/blob/main/lib/poolboy_prt/worker.ex"
click node_application "https://github.com/herneto/receptor_prt/blob/main/lib/receptor_prt/application.ex"
click node_yaml_config "https://github.com/herneto/receptor_prt/blob/main/receptor_app.yaml"
click node_config_loader "https://github.com/herneto/receptor_prt/blob/main/lib/receptor_prt/config.ex"

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_gateway_session,node_request_dispatch,node_response_relay,node_application toneBlue
class node_worker_pool,node_http_worker toneAmber
class node_yaml_config,node_config_loader,node_payment_api toneMint
class node_prt_client toneIndigo
```

## Components

### PRT Gateway

- [Session and framing](https://github.com/herneto/receptor_prt/blob/main/lib/receptor_prt.ex): `lib/receptor_prt.ex`
- [Request dispatch](https://github.com/herneto/receptor_prt/blob/main/lib/receptor_prt.ex): `lib/receptor_prt.ex`
- [Response relay](https://github.com/herneto/receptor_prt/blob/main/lib/receptor_prt.ex): `lib/receptor_prt.ex`
- [Application supervisor](https://github.com/herneto/receptor_prt/blob/main/lib/receptor_prt/application.ex): `lib/receptor_prt/application.ex`

### HTTP Bridge

- [Worker pool](https://github.com/herneto/receptor_prt/blob/main/lib/receptor_prt/application.ex): `lib/receptor_prt/application.ex`
- [HTTP worker](https://github.com/herneto/receptor_prt/blob/main/lib/poolboy_prt/worker.ex): `lib/poolboy_prt/worker.ex`

### Configuration

- [Application YAML](https://github.com/herneto/receptor_prt/blob/main/receptor_app.yaml): `receptor_app.yaml`
- [Config loader](https://github.com/herneto/receptor_prt/blob/main/lib/receptor_prt/config.ex): `lib/receptor_prt/config.ex`

### Other components

- **PRT peer**
- **Payment API**

## Connections

- PRT peer → Session and framing: sends frames (evidence: `lib/receptor_prt.ex`)
- Session and framing → PRT peer: opens session (evidence: `lib/receptor_prt.ex`)
- Session and framing → Request dispatch: dispatches request (evidence: `lib/receptor_prt.ex`)
- Request dispatch → Worker pool: checks out worker (evidence: `lib/receptor_prt.ex`)
- Request dispatch → HTTP worker: calls worker (evidence: `lib/receptor_prt.ex`)
- HTTP worker → Payment API: posts request (evidence: `lib/poolboy_prt/worker.ex`)
- HTTP worker → Response relay: sends response (evidence: `lib/poolboy_prt/worker.ex`)
- Response relay → PRT peer: writes response (evidence: `lib/receptor_prt.ex`)
- Application supervisor → Config loader: loads settings (evidence: `lib/receptor_prt/application.ex`)
- Config loader → Application YAML: reads YAML (evidence: `lib/receptor_prt/config.ex`)
- Application supervisor → Session and framing: starts session task (evidence: `lib/receptor_prt/application.ex`)
- Application supervisor → Worker pool: starts pool (evidence: `lib/receptor_prt/application.ex`)
- HTTP worker → Config loader: loads API settings (evidence: `lib/poolboy_prt/worker.ex`)
