# kevotowet/bingwa architecture

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

- Interactive diagram: https://gitdiagram.com/kevotowet/bingwa
- Repository: https://github.com/kevotowet/bingwa

## Overview

Bingwa is represented here as a small M-Pesa STK Push payment endpoint. Its visible workflow accepts phone, amount, and package data, obtains a Safaricom OAuth token, then submits a payment prompt and returns Safaricom’s response. The source also configures a callback URL, but no callback handler appears in the file tree. The README provides no further capability details, and the frontend file was not sampled, so its role and wiring are not asserted.

Main entry points: [`stkpush.php`](https://github.com/kevotowet/bingwa/blob/main/stkpush.php) (OAuth token request)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_payment["STK payments"]
  node_input["Validate payment input<br/>[stkpush.php]"]
  node_oauth["OAuth token request<br/>[stkpush.php]"]
  node_stk_request["Build and send STK request<br/>[stkpush.php]"]
end

node_caller(("Payment client"))
node_safaricom_oauth["Safaricom OAuth"]
node_safaricom_stk["Safaricom STK API"]
node_callback["Configured callback receiver"]

node_caller -->|"posts payment details"| node_input
node_input -->|"valid input continues"| node_oauth
node_oauth -->|"requests token"| node_safaricom_oauth
node_oauth -->|"provides access token"| node_stk_request
node_stk_request -->|"submits STK prompt"| node_safaricom_stk
node_stk_request -->|"registers callback URL"| node_callback
node_safaricom_stk -->|"returns raw response"| node_caller

click node_input "https://github.com/kevotowet/bingwa/blob/main/stkpush.php"
click node_oauth "https://github.com/kevotowet/bingwa/blob/main/stkpush.php"
click node_stk_request "https://github.com/kevotowet/bingwa/blob/main/stkpush.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_input,node_oauth,node_stk_request,node_caller toneBlue
class node_safaricom_oauth,node_callback toneIndigo
class node_safaricom_stk toneMint
```

## Components

### STK payments

- [Validate payment input](https://github.com/kevotowet/bingwa/blob/main/stkpush.php): `stkpush.php`
- [OAuth token request](https://github.com/kevotowet/bingwa/blob/main/stkpush.php): `stkpush.php`
- [Build and send STK request](https://github.com/kevotowet/bingwa/blob/main/stkpush.php): `stkpush.php`

### Other components

- **Payment client**
- **Safaricom OAuth**
- **Safaricom STK API**
- **Configured callback receiver**

## Connections

- Payment client → Validate payment input: posts payment details (evidence: `stkpush.php`)
- Validate payment input → OAuth token request: valid input continues (evidence: `stkpush.php`)
- OAuth token request → Safaricom OAuth: requests token (evidence: `stkpush.php`)
- OAuth token request → Build and send STK request: provides access token (evidence: `stkpush.php`)
- Build and send STK request → Safaricom STK API: submits STK prompt (evidence: `stkpush.php`)
- Build and send STK request → Configured callback receiver: registers callback URL (evidence: `stkpush.php`)
- Safaricom STK API → Payment client: returns raw response
