# piprapay/piprapay architecture

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

- Interactive diagram: https://gitdiagram.com/piprapay/piprapay
- Repository: https://github.com/piprapay/piprapay

## Overview

#### 1. Purpose and runtime
PipraPay is a self-hosted PHP payment-automation platform. It unifies API-backed, manual, and SMS-verified payment methods through pluggable gateway modules, with customer-facing checkout/payment pages and an administrative control plane. It is deployed behind an Apache-compatible web server (`.htaccess`) and initialized against a SQL schema.

Paths: `index.php`, `.htaccess`, `pp-content/pp-install/db.sql`

#### 2. Application bootstrap and shared core
The public request entry point is `index.php`; installation has a separate entry point. Shared adapter and function layers under `pp-include` are the likely core boundary between page controllers, persistence, and modules. Maintenance and requirement scripts support operational gating and environment checks.

Paths: `index.php`, `pp-content/pp-include/pp-adapter.php`, `pp-content/pp-install/index.php`

#### 3. Public payment workflow and themes
A theme module owns public checkout, gateway selection, payment-link, invoice, and checkout-status views. This separates branded/public payment presentation from payment orchestration. A payment link or invoice routes a payer into the active theme, which presents enabled gateways and then reports payment status.

Paths: `pp-content/pp-modules/pp-themes/twenty-six/checkout.php`, `pp-content/pp-modules/pp-themes/twenty-six/gateway.php`, `pp-content/pp-modules/pp-themes/twenty-six/checkout-status.php`

#### 4. Gateway plugin boundary
Each payment connector is isolated in a gateway directory with a `class.php` implementation and gateway-specific assets. The core/admin configuration selects and configures gateways; the public flow delegates provider interactions to the matching module. Modules include direct APIs (Stripe, PayPal, SSLCommerz, aamarPay), crypto providers, and manual/mobile-wallet verification variants.

Paths: `pp-content/pp-modules/pp-gateways/stripe/class.php`, `pp-content/pp-modules/pp-gateways/bkash-api-tokenized/class.php`, `pp-content/pp-modules/pp-gateways/nowpayments/class.php`

#### 5. Administrative control plane
The PHP admin area provides authentication including 2FA/recovery, then routes privileged users to dashboard and domain management screens. It manages brands, customers, gateway definitions, payment links, invoices, transactions, staff permissions, and reporting. This is the principal configuration and operational boundary for the payment system.

Paths: `pp-content/pp-admin/login.php`, `pp-content/pp-admin/2fa.php`, `pp-content/pp-admin/pp-root/dashboard.php`

#### 6. Verification, transaction, and device operations
Payment lifecycle management spans transaction records, balance verification, SMS data, and device management. This reflects the platform’s non-API payment automation model: companion-device/SMS inputs can support verification alongside gateway callbacks or manual flows. Cron-job settings imply scheduled reconciliation or background processing, though the scheduler runtime is externally provisioned.

Paths: `pp-content/pp-admin/pp-root/transaction/index.php`, `pp-content/pp-admin/pp-root/devices/balance-verification.php`, `pp-content/pp-admin/pp-root/sms-data.php`

#### 7. Branding, integrations, and infrastructure
Multi-brand behavior is configured through brand and global settings, including themes, currencies, FAQs, and API settings. Domains are managed in the admin surface, suggesting branded/domain-specific payment endpoints. External dependencies include payment-provider APIs, an Android companion application for verification, and the FPDF and Google Authenticator libraries for invoice/document generation and 2FA.

Paths: `pp-content/pp-admin/pp-root/brands/index.php`, `pp-content/pp-admin/pp-root/brand-setting/api-setting.php`, `pp-media/sdk/fpdf/fpdf.php`

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public payment flow"]
  node_web{{"Apache web server<br/>web runtime<br/>[.htaccess]"}}
  node_entry["Public entry point<br/>PHP bootstrap<br/>[index.php]"]
  node_theme_checkout["Checkout view<br/>theme page<br/>[checkout.php]"]
  node_theme_gateway["Gateway selection<br/>theme page<br/>[gateway.php]"]
  node_theme_status["Checkout status<br/>theme page"]
end

subgraph group_core["Application core"]
  node_adapter["Shared adapter layer<br/>PHP core<br/>[pp-adapter.php]"]
  node_database[("SQL database<br/>persistence<br/>[db.sql]")]
  node_installer["Installer<br/>PHP setup<br/>[index.php]"]
end

subgraph group_admin["Admin control plane"]
  node_admin_login["Admin authentication<br/>admin page<br/>[login.php]"]
  node_dashboard["Admin dashboard<br/>admin controller<br/>[dashboard.php]"]
  node_brands["Brands and domains<br/>admin management<br/>[index.php]"]
  node_api_settings["Brand API settings<br/>admin settings<br/>[api-setting.php]"]
  node_transactions["Transactions<br/>payment operations<br/>[index.php]"]
  node_verification["Device verification<br/>payment operations"]
  node_sms_data["SMS data<br/>verification input<br/>[sms-data.php]"]
end

subgraph group_integrations["External integrations"]
  node_stripe["Stripe gateway<br/>gateway plugin<br/>[class.php]"]
  node_bkash["bKash tokenized gateway<br/>gateway plugin<br/>[class.php]"]
  node_nowpayments["NOWPayments gateway<br/>gateway plugin<br/>[class.php]"]
  node_providers{{"Payment provider APIs<br/>external service"}}
  node_android{{"Android companion app<br/>external device app"}}
  node_fpdf["FPDF library<br/>document library<br/>[fpdf.php]"]
end

node_web -->|"routes"| node_entry
node_entry -->|"boots"| node_adapter
node_entry -->|"serves"| node_theme_checkout
node_theme_checkout -->|"selects payment method"| node_theme_gateway
node_theme_gateway -->|"reports outcome"| node_theme_status
node_theme_checkout -->|"loads payment context"| node_adapter
node_adapter -->|"reads and writes"| node_database
node_installer -->|"initializes schema"| node_database
node_admin_login -->|"authenticates access"| node_dashboard
node_dashboard -->|"manages"| node_brands
node_brands -->|"configures"| node_api_settings
node_dashboard -->|"operates"| node_transactions
node_dashboard -->|"manages"| node_verification
node_verification -->|"uses"| node_sms_data
node_android -->|"supplies verification data"| node_sms_data
node_dashboard -->|"uses core services"| node_adapter
node_api_settings -->|"configures"| node_stripe
node_api_settings -->|"configures"| node_bkash
node_api_settings -->|"configures"| node_nowpayments
node_theme_gateway -->|"delegates payment"| node_stripe
node_theme_gateway -->|"delegates payment"| node_bkash
node_theme_gateway -->|"delegates payment"| node_nowpayments
node_stripe -->|"API calls"| node_providers
node_bkash -->|"API calls"| node_providers
node_nowpayments -->|"API calls"| node_providers
node_transactions -->|"generates invoices"| node_fpdf

click node_web "https://github.com/piprapay/piprapay/blob/main/.htaccess"
click node_entry "https://github.com/piprapay/piprapay/blob/main/index.php"
click node_theme_checkout "https://github.com/piprapay/piprapay/blob/main/pp-content/pp-modules/pp-themes/twenty-six/checkout.php"
click node_theme_gateway "https://github.com/piprapay/piprapay/blob/main/pp-content/pp-modules/pp-themes/twenty-six/gateway.php"
click node_theme_status "https://github.com/piprapay/piprapay/blob/main/pp-content/pp-modules/pp-themes/twenty-six/checkout-status.php"
click node_adapter "https://github.com/piprapay/piprapay/blob/main/pp-content/pp-include/pp-adapter.php"
click node_database "https://github.com/piprapay/piprapay/blob/main/pp-content/pp-install/db.sql"
click node_installer "https://github.com/piprapay/piprapay/blob/main/pp-content/pp-install/index.php"
click node_admin_login "https://github.com/piprapay/piprapay/blob/main/pp-content/pp-admin/login.php"
click node_dashboard "https://github.com/piprapay/piprapay/blob/main/pp-content/pp-admin/pp-root/dashboard.php"
click node_brands "https://github.com/piprapay/piprapay/blob/main/pp-content/pp-admin/pp-root/brands/index.php"
click node_api_settings "https://github.com/piprapay/piprapay/blob/main/pp-content/pp-admin/pp-root/brand-setting/api-setting.php"
click node_transactions "https://github.com/piprapay/piprapay/blob/main/pp-content/pp-admin/pp-root/transaction/index.php"
click node_verification "https://github.com/piprapay/piprapay/blob/main/pp-content/pp-admin/pp-root/devices/balance-verification.php"
click node_sms_data "https://github.com/piprapay/piprapay/blob/main/pp-content/pp-admin/pp-root/sms-data.php"
click node_stripe "https://github.com/piprapay/piprapay/blob/main/pp-content/pp-modules/pp-gateways/stripe/class.php"
click node_bkash "https://github.com/piprapay/piprapay/blob/main/pp-content/pp-modules/pp-gateways/bkash-api-tokenized/class.php"
click node_nowpayments "https://github.com/piprapay/piprapay/blob/main/pp-content/pp-modules/pp-gateways/nowpayments/class.php"
click node_fpdf "https://github.com/piprapay/piprapay/blob/main/pp-media/sdk/fpdf/fpdf.php"

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_web,node_entry,node_theme_checkout,node_theme_gateway,node_theme_status toneBlue
class node_adapter,node_database,node_installer toneAmber
class node_admin_login,node_dashboard,node_brands,node_api_settings,node_transactions,node_verification,node_sms_data toneMint
class node_stripe,node_bkash,node_nowpayments,node_providers,node_android,node_fpdf toneRose
```

## Components

### Public payment flow

- [Apache web server](https://github.com/piprapay/piprapay/blob/main/.htaccess): web runtime · Routes public requests through rewrite rules. · `.htaccess`
- [Public entry point](https://github.com/piprapay/piprapay/blob/main/index.php): PHP bootstrap · `index.php`
- [Checkout view](https://github.com/piprapay/piprapay/blob/main/pp-content/pp-modules/pp-themes/twenty-six/checkout.php): theme page · Presents payment links and enabled gateways. · `pp-content/pp-modules/pp-themes/twenty-six/checkout.php`
- [Gateway selection](https://github.com/piprapay/piprapay/blob/main/pp-content/pp-modules/pp-themes/twenty-six/gateway.php): theme page · `pp-content/pp-modules/pp-themes/twenty-six/gateway.php`
- [Checkout status](https://github.com/piprapay/piprapay/blob/main/pp-content/pp-modules/pp-themes/twenty-six/checkout-status.php): theme page · `pp-content/pp-modules/pp-themes/twenty-six/checkout-status.php`

### Application core

- [Shared adapter layer](https://github.com/piprapay/piprapay/blob/main/pp-content/pp-include/pp-adapter.php): PHP core · Connects controllers, persistence, and gateway modules. · `pp-content/pp-include/pp-adapter.php`
- [SQL database](https://github.com/piprapay/piprapay/blob/main/pp-content/pp-install/db.sql): persistence · Stores platform configuration and payment operations. · `pp-content/pp-install/db.sql`
- [Installer](https://github.com/piprapay/piprapay/blob/main/pp-content/pp-install/index.php): PHP setup · `pp-content/pp-install/index.php`

### Admin control plane

- [Admin authentication](https://github.com/piprapay/piprapay/blob/main/pp-content/pp-admin/login.php): admin page · Includes 2FA and recovery access flow. · `pp-content/pp-admin/login.php`
- [Admin dashboard](https://github.com/piprapay/piprapay/blob/main/pp-content/pp-admin/pp-root/dashboard.php): admin controller · Privileged operational entry point. · `pp-content/pp-admin/pp-root/dashboard.php`
- [Brands and domains](https://github.com/piprapay/piprapay/blob/main/pp-content/pp-admin/pp-root/brands/index.php): admin management · Controls multi-brand public endpoints and presentation. · `pp-content/pp-admin/pp-root/brands/index.php`
- [Brand API settings](https://github.com/piprapay/piprapay/blob/main/pp-content/pp-admin/pp-root/brand-setting/api-setting.php): admin settings · `pp-content/pp-admin/pp-root/brand-setting/api-setting.php`
- [Transactions](https://github.com/piprapay/piprapay/blob/main/pp-content/pp-admin/pp-root/transaction/index.php): payment operations · Manages payment lifecycle records. · `pp-content/pp-admin/pp-root/transaction/index.php`
- [Device verification](https://github.com/piprapay/piprapay/blob/main/pp-content/pp-admin/pp-root/devices/balance-verification.php): payment operations · Supports balance and non-API payment verification. · `pp-content/pp-admin/pp-root/devices/balance-verification.php`
- [SMS data](https://github.com/piprapay/piprapay/blob/main/pp-content/pp-admin/pp-root/sms-data.php): verification input · `pp-content/pp-admin/pp-root/sms-data.php`

### External integrations

- [Stripe gateway](https://github.com/piprapay/piprapay/blob/main/pp-content/pp-modules/pp-gateways/stripe/class.php): gateway plugin · `pp-content/pp-modules/pp-gateways/stripe/class.php`
- [bKash tokenized gateway](https://github.com/piprapay/piprapay/blob/main/pp-content/pp-modules/pp-gateways/bkash-api-tokenized/class.php): gateway plugin · `pp-content/pp-modules/pp-gateways/bkash-api-tokenized/class.php`
- [NOWPayments gateway](https://github.com/piprapay/piprapay/blob/main/pp-content/pp-modules/pp-gateways/nowpayments/class.php): gateway plugin · `pp-content/pp-modules/pp-gateways/nowpayments/class.php`
- **Payment provider APIs**: external service
- **Android companion app**: external device app · Supplies device and SMS-assisted verification inputs.
- [FPDF library](https://github.com/piprapay/piprapay/blob/main/pp-media/sdk/fpdf/fpdf.php): document library · Generates invoice documents. · `pp-media/sdk/fpdf/fpdf.php`

## Connections

- Apache web server → Public entry point: routes
- Public entry point → Shared adapter layer: boots
- Public entry point → Checkout view: serves
- Checkout view → Gateway selection: selects payment method
- Gateway selection → Checkout status: reports outcome
- Checkout view → Shared adapter layer: loads payment context
- Shared adapter layer → SQL database: reads and writes
- Installer → SQL database: initializes schema
- Admin authentication → Admin dashboard: authenticates access
- Admin dashboard → Brands and domains: manages
- Brands and domains → Brand API settings: configures
- Admin dashboard → Transactions: operates
- Admin dashboard → Device verification: manages
- Device verification → SMS data: uses
- Android companion app → SMS data: supplies verification data
- Admin dashboard → Shared adapter layer: uses core services
- Brand API settings → Stripe gateway: configures
- Brand API settings → bKash tokenized gateway: configures
- Brand API settings → NOWPayments gateway: configures
- Gateway selection → Stripe gateway: delegates payment
- Gateway selection → bKash tokenized gateway: delegates payment
- Gateway selection → NOWPayments gateway: delegates payment
- Stripe gateway → Payment provider APIs: API calls
- bKash tokenized gateway → Payment provider APIs: API calls
- NOWPayments gateway → Payment provider APIs: API calls
- Transactions → FPDF library: generates invoices
