# rcbtst/payment-webhook-test-app architecture

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

- Interactive diagram: https://gitdiagram.com/rcbtst/payment-webhook-test-app
- Repository: https://github.com/rcbtst/payment-webhook-test-app

## Overview

This is a Sanic API for user and account administration, bearer-token authentication, and signed transaction webhooks. Users sign up or log in to receive JWTs; authenticated users can inspect their profile, accounts, and transactions, while admins manage users. A signed webhook creates or finds an account, records an idempotent transaction, and updates its balance. The graph follows calls visible in the excerpts and module references in the source index; startup wiring and migration details are not expanded.

Main entry points: [`src/rest_api/services/auth.py`](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/services/auth.py) (Token and signature checks), [`src/rest_api/routes/v1/auth.py`](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/routes/v1/auth.py) (Login and signup), [`src/rest_api/routes/v1/users.py`](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/routes/v1/users.py) (User administration), [`src/database/crud.py`](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/database/crud.py) (Database operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routes"]
  node_auth_routes["Login and signup<br/>[auth.py]"]
  node_profile_routes["Profile and activity<br/>[me.py]"]
  node_admin_routes["User administration<br/>[users.py]"]
  node_webhook_routes["Transaction webhook<br/>[webhooks.py]"]
end

subgraph group_auth["Authentication"]
  node_access_control["Token and signature checks<br/>[auth.py]"]
  node_jwt["JWT handling<br/>[jwt.py]"]
  node_passwords["Password hashing<br/>[passwords.py]"]
  node_signature["Signature utility<br/>[signature.py]"]
end

subgraph group_data["Persistence"]
  node_crud["Database operations<br/>[crud.py]"]
  node_schema[("User account transaction schema<br/>[schema.py]")]
end

subgraph group_domain["Contracts and configuration"]
  node_auth_models["Authentication contracts<br/>[auth.py]"]
  node_user_models["User contracts<br/>[user.py]"]
  node_webhook_models["Webhook contract<br/>[webhooks.py]"]
  node_settings["Runtime settings<br/>[config.py]"]
end

node_client(("API client"))

node_client -->|"requests"| node_auth_routes
node_client -->|"requests"| node_profile_routes
node_client -->|"requests"| node_admin_routes
node_client -->|"posts transaction"| node_webhook_routes
node_auth_routes -->|"reads and writes users"| node_crud
node_auth_routes -->|"hashes and verifies"| node_passwords
node_auth_routes -->|"creates tokens"| node_jwt
node_auth_routes -->|"validates and returns"| node_auth_models
node_profile_routes -->|"checks scopes"| node_access_control
node_profile_routes -->|"reads profile and activity"| node_crud
node_profile_routes -->|"returns"| node_user_models
node_admin_routes -->|"checks admin scope"| node_access_control
node_admin_routes -->|"manages users"| node_crud
node_admin_routes -->|"hashes passwords"| node_passwords
node_admin_routes -->|"validates and returns"| node_user_models
node_webhook_routes -->|"checks signature"| node_access_control
node_webhook_routes -->|"processes transaction"| node_crud
node_webhook_routes -->|"validates request"| node_webhook_models
node_access_control -->|"decodes tokens"| node_jwt
node_access_control -->|"verifies signatures"| node_signature
node_access_control -->|"parses token payload"| node_auth_models
node_crud -->|"queries and updates"| node_schema
node_jwt -->|"uses token settings"| node_settings
node_signature -->|"uses webhook secret"| node_settings

click node_auth_routes "https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/routes/v1/auth.py"
click node_profile_routes "https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/routes/v1/me.py"
click node_admin_routes "https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/routes/v1/users.py"
click node_webhook_routes "https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/routes/v1/webhooks.py"
click node_access_control "https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/services/auth.py"
click node_jwt "https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/utils/jwt.py"
click node_passwords "https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/utils/passwords.py"
click node_signature "https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/utils/signature.py"
click node_crud "https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/database/crud.py"
click node_schema "https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/database/schema.py"
click node_auth_models "https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/models/auth.py"
click node_user_models "https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/models/user.py"
click node_webhook_models "https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/models/webhooks.py"
click node_settings "https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/config.py"

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_auth_routes,node_profile_routes,node_admin_routes,node_webhook_routes,node_client toneBlue
class node_access_control,node_jwt,node_passwords,node_signature toneAmber
class node_crud,node_schema toneMint
class node_auth_models,node_user_models,node_webhook_models,node_settings toneRose
```

## Components

### API routes

- [Login and signup](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/routes/v1/auth.py): `src/rest_api/routes/v1/auth.py`
- [Profile and activity](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/routes/v1/me.py): `src/rest_api/routes/v1/me.py`
- [User administration](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/routes/v1/users.py): `src/rest_api/routes/v1/users.py`
- [Transaction webhook](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/routes/v1/webhooks.py): `src/rest_api/routes/v1/webhooks.py`

### Authentication

- [Token and signature checks](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/services/auth.py): `src/rest_api/services/auth.py`
- [JWT handling](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/utils/jwt.py): `src/utils/jwt.py`
- [Password hashing](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/utils/passwords.py): `src/utils/passwords.py`
- [Signature utility](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/utils/signature.py): `src/utils/signature.py`

### Persistence

- [Database operations](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/database/crud.py): `src/database/crud.py`
- [User account transaction schema](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/database/schema.py): `src/database/schema.py`

### Contracts and configuration

- [Authentication contracts](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/models/auth.py): `src/rest_api/models/auth.py`
- [User contracts](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/models/user.py): `src/rest_api/models/user.py`
- [Webhook contract](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/rest_api/models/webhooks.py): `src/rest_api/models/webhooks.py`
- [Runtime settings](https://github.com/rcbtst/payment-webhook-test-app/blob/main/src/config.py): `src/config.py`

### Other components

- **API client**

## Connections

- API client → Login and signup: requests (evidence: `src/rest_api/routes/v1/auth.py`)
- API client → Profile and activity: requests (evidence: `src/rest_api/routes/v1/me.py`)
- API client → User administration: requests (evidence: `src/rest_api/routes/v1/users.py`)
- API client → Transaction webhook: posts transaction (evidence: `src/rest_api/routes/v1/webhooks.py`)
- Login and signup → Database operations: reads and writes users (evidence: `src/rest_api/routes/v1/auth.py`)
- Login and signup → Password hashing: hashes and verifies (evidence: `src/rest_api/routes/v1/auth.py`)
- Login and signup → JWT handling: creates tokens (evidence: `src/rest_api/routes/v1/auth.py`)
- Login and signup → Authentication contracts: validates and returns (evidence: `src/rest_api/routes/v1/auth.py`)
- Profile and activity → Token and signature checks: checks scopes (evidence: `src/rest_api/routes/v1/me.py`)
- Profile and activity → Database operations: reads profile and activity (evidence: `src/rest_api/routes/v1/me.py`)
- Profile and activity → User contracts: returns (evidence: `src/rest_api/routes/v1/me.py`)
- User administration → Token and signature checks: checks admin scope (evidence: `src/rest_api/routes/v1/users.py`)
- User administration → Database operations: manages users (evidence: `src/rest_api/routes/v1/users.py`)
- User administration → Password hashing: hashes passwords (evidence: `src/rest_api/routes/v1/users.py`)
- User administration → User contracts: validates and returns (evidence: `src/rest_api/routes/v1/users.py`)
- Transaction webhook → Token and signature checks: checks signature (evidence: `src/rest_api/routes/v1/webhooks.py`)
- Transaction webhook → Database operations: processes transaction (evidence: `src/rest_api/routes/v1/webhooks.py`)
- Transaction webhook → Webhook contract: validates request (evidence: `src/rest_api/routes/v1/webhooks.py`)
- Token and signature checks → JWT handling: decodes tokens (evidence: `src/rest_api/services/auth.py`)
- Token and signature checks → Signature utility: verifies signatures (evidence: `src/rest_api/services/auth.py`)
- Token and signature checks → Authentication contracts: parses token payload (evidence: `src/rest_api/services/auth.py`)
- Database operations → User account transaction schema: queries and updates (evidence: `src/database/crud.py`)
- JWT handling → Runtime settings: uses token settings (evidence: `src/utils/jwt.py`)
- Signature utility → Runtime settings: uses webhook secret (evidence: `src/utils/signature.py`)
