# 1fancy/sms8-sms-gateway architecture

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

- Interactive diagram: https://gitdiagram.com/1fancy/sms8-sms-gateway
- Repository: https://github.com/1fancy/sms8-sms-gateway

## Overview

SMS8 is an SMS/OTP gateway exposed through an MCP server, with companion CLI, web, React, native-plugin, and mobile-SDK interfaces. The primary workflow is an AI client calling an MCP tool: the PHP entry point dispatches JSON-RPC, the registry authenticates and invokes a tool handler, and SMS8 routes messaging through a paired Android phone. The README documents the broader product capabilities and client packages. Several tool implementations and package internals were not excerpted, so their connections are shown only where the README or source index supports them.

Main entry points: [`lib/ToolRegistry.php`](https://github.com/1fancy/sms8-sms-gateway/blob/main/lib/ToolRegistry.php) (Tool registry), [`index.php`](https://github.com/1fancy/sms8-sms-gateway/blob/main/index.php) (HTTP entry), [`sdks/sms8-android/sms8/src/main/java/io/sms8/SMS8.kt`](https://github.com/1fancy/sms8-sms-gateway/blob/main/sdks/sms8-android/sms8/src/main/java/io/sms8/SMS8.kt) (Android SDK), [`sdks/sms8-swift/Sources/SMS8/SMS8.swift`](https://github.com/1fancy/sms8-sms-gateway/blob/main/sdks/sms8-swift/Sources/SMS8/SMS8.swift) (Swift SDK)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mcp["MCP server"]
  node_entry["HTTP entry<br/>[index.php]"]
  node_rpc["JSON-RPC dispatch<br/>[JsonRpc.php]"]
  node_registry["Tool registry<br/>[ToolRegistry.php]"]
  node_auth["API-key auth<br/>[Auth.php]"]
end

subgraph group_tools["Gateway tools"]
  node_setup["Setup context<br/>[setup_sms8.php]"]
  node_send["Send SMS<br/>[send_sms.php]"]
  node_sendotp["Send OTP<br/>[send_otp.php]"]
  node_verify["Verify OTP<br/>[send_otp.php]"]
  node_wait["Wait for OTP<br/>[wait_for_otp.php]"]
  node_messages["Read messages<br/>[get_messages.php]"]
  node_devices["List devices<br/>[list_devices.php]"]
  node_balance["Check balance<br/>[get_balance.php]"]
  node_webhook["Configure webhook<br/>[create_webhook.php]"]
end

subgraph group_clients["Client packages"]
  node_mcpclient["MCP launcher<br/>[sms8-mcp.js]"]
  node_cli["SMS command-line clients<br/>[sms8.js]"]
  node_react["React OTP hook<br/>[react.tsx]"]
  node_form["OTP form<br/>[OtpForm.tsx]"]
  node_input["OTP input<br/>[OtpInput.tsx]"]
  node_capacitor["Capacitor plugin<br/>[definitions.ts]"]
  node_cordova["Cordova plugin<br/>[SmsOtp.js]"]
end

subgraph group_mobile["Mobile SDKs"]
  node_androidsdk["Android SDK<br/>[SMS8.kt]"]
  node_autofill["Android autofill<br/>[SMSRetriever.kt]"]
  node_swiftsdk["Swift SDK<br/>[SMS8.swift]"]
  node_otpfield["iOS OTP field<br/>[OTPTextField.swift]"]
end

subgraph group_web["Web presence"]
  node_docs["Documentation pages<br/>[api.php]"]
end

node_ai(("AI coding tool"))
node_platform["SMS8 platform"]
node_phone["Paired Android phone"]

node_ai -->|"calls MCP"| node_entry
node_entry -->|"dispatches"| node_rpc
node_entry -->|"loads tools"| node_registry
node_rpc -->|"routes tool calls"| node_registry
node_registry -->|"authenticates"| node_auth
node_registry -.->|"invokes"| node_setup
node_registry -.->|"invokes"| node_send
node_registry -.->|"invokes"| node_sendotp
node_registry -.->|"invokes"| node_verify
node_registry -.->|"invokes"| node_wait
node_registry -.->|"invokes"| node_messages
node_registry -.->|"invokes"| node_devices
node_registry -.->|"invokes"| node_balance
node_registry -.->|"invokes"| node_webhook
node_send -.->|"sends through"| node_platform
node_sendotp -.->|"sends through"| node_platform
node_wait -.->|"waits for code"| node_phone
node_platform -.->|"routes SMS"| node_phone
node_ai -->|"launches"| node_mcpclient
node_cli -.->|"uses gateway"| node_platform
node_react -->|"calls MCP API"| node_platform
node_form -->|"renders"| node_input
node_capacitor -.->|"provides OTP access"| node_platform
node_cordova -.->|"provides OTP access"| node_platform
node_androidsdk -.->|"uses API"| node_platform
node_androidsdk -.->|"offers autofill"| node_autofill
node_swiftsdk -.->|"uses API"| node_platform
node_swiftsdk -.->|"offers autofill field"| node_otpfield
node_docs -.->|"documents integration"| node_ai

click node_entry "https://github.com/1fancy/sms8-sms-gateway/blob/main/index.php"
click node_rpc "https://github.com/1fancy/sms8-sms-gateway/blob/main/lib/JsonRpc.php"
click node_registry "https://github.com/1fancy/sms8-sms-gateway/blob/main/lib/ToolRegistry.php"
click node_auth "https://github.com/1fancy/sms8-sms-gateway/blob/main/lib/Auth.php"
click node_setup "https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/setup_sms8.php"
click node_send "https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/send_sms.php"
click node_sendotp "https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/send_otp.php"
click node_verify "https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/send_otp.php"
click node_wait "https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/wait_for_otp.php"
click node_messages "https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/get_messages.php"
click node_devices "https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/list_devices.php"
click node_balance "https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/get_balance.php"
click node_webhook "https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/create_webhook.php"
click node_mcpclient "https://github.com/1fancy/sms8-sms-gateway/blob/main/npm-packages/sms8-mcp/bin/sms8-mcp.js"
click node_cli "https://github.com/1fancy/sms8-sms-gateway/blob/main/npm-packages/sms8-cli/bin/sms8.js"
click node_react "https://github.com/1fancy/sms8-sms-gateway/blob/main/npm-packages/react-sms-otp/src/react.tsx"
click node_form "https://github.com/1fancy/sms8-sms-gateway/blob/main/npm-packages/react-sms-otp/src/OtpForm.tsx"
click node_input "https://github.com/1fancy/sms8-sms-gateway/blob/main/npm-packages/react-sms-otp/src/OtpInput.tsx"
click node_capacitor "https://github.com/1fancy/sms8-sms-gateway/blob/main/npm-packages/capacitor-sms-otp-send-verify/src/definitions.ts"
click node_cordova "https://github.com/1fancy/sms8-sms-gateway/blob/main/npm-packages/cordova-plugin-sms-otp-send/www/SmsOtp.js"
click node_androidsdk "https://github.com/1fancy/sms8-sms-gateway/blob/main/sdks/sms8-android/sms8/src/main/java/io/sms8/SMS8.kt"
click node_autofill "https://github.com/1fancy/sms8-sms-gateway/blob/main/sdks/sms8-android/sms8/src/main/java/io/sms8/autofill/SMSRetriever.kt"
click node_swiftsdk "https://github.com/1fancy/sms8-sms-gateway/blob/main/sdks/sms8-swift/Sources/SMS8/SMS8.swift"
click node_otpfield "https://github.com/1fancy/sms8-sms-gateway/blob/main/sdks/sms8-swift/Sources/SMS8/OTPTextField.swift"
click node_docs "https://github.com/1fancy/sms8-sms-gateway/blob/main/pages/api.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_entry,node_rpc,node_registry,node_auth toneBlue
class node_setup,node_send,node_sendotp,node_verify,node_wait,node_messages,node_devices,node_balance,node_webhook toneAmber
class node_mcpclient,node_cli,node_react,node_form,node_input,node_capacitor,node_cordova toneMint
class node_androidsdk,node_autofill,node_swiftsdk,node_otpfield toneRose
class node_docs,node_ai,node_platform,node_phone toneIndigo
```

## Components

### MCP server

- [HTTP entry](https://github.com/1fancy/sms8-sms-gateway/blob/main/index.php): `index.php`
- [JSON-RPC dispatch](https://github.com/1fancy/sms8-sms-gateway/blob/main/lib/JsonRpc.php): `lib/JsonRpc.php`
- [Tool registry](https://github.com/1fancy/sms8-sms-gateway/blob/main/lib/ToolRegistry.php): `lib/ToolRegistry.php`
- [API-key auth](https://github.com/1fancy/sms8-sms-gateway/blob/main/lib/Auth.php): `lib/Auth.php`

### Gateway tools

- [Setup context](https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/setup_sms8.php): `tools/setup_sms8.php`
- [Send SMS](https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/send_sms.php): `tools/send_sms.php`
- [Send OTP](https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/send_otp.php): `tools/send_otp.php`
- [Verify OTP](https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/send_otp.php): `tools/send_otp.php`
- [Wait for OTP](https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/wait_for_otp.php): `tools/wait_for_otp.php`
- [Read messages](https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/get_messages.php): `tools/get_messages.php`
- [List devices](https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/list_devices.php): `tools/list_devices.php`
- [Check balance](https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/get_balance.php): `tools/get_balance.php`
- [Configure webhook](https://github.com/1fancy/sms8-sms-gateway/blob/main/tools/create_webhook.php): `tools/create_webhook.php`

### Client packages

- [MCP launcher](https://github.com/1fancy/sms8-sms-gateway/blob/main/npm-packages/sms8-mcp/bin/sms8-mcp.js): `npm-packages/sms8-mcp/bin/sms8-mcp.js`
- [SMS command-line clients](https://github.com/1fancy/sms8-sms-gateway/blob/main/npm-packages/sms8-cli/bin/sms8.js): `npm-packages/sms8-cli/bin/sms8.js`
- [React OTP hook](https://github.com/1fancy/sms8-sms-gateway/blob/main/npm-packages/react-sms-otp/src/react.tsx): `npm-packages/react-sms-otp/src/react.tsx`
- [OTP form](https://github.com/1fancy/sms8-sms-gateway/blob/main/npm-packages/react-sms-otp/src/OtpForm.tsx): `npm-packages/react-sms-otp/src/OtpForm.tsx`
- [OTP input](https://github.com/1fancy/sms8-sms-gateway/blob/main/npm-packages/react-sms-otp/src/OtpInput.tsx): `npm-packages/react-sms-otp/src/OtpInput.tsx`
- [Capacitor plugin](https://github.com/1fancy/sms8-sms-gateway/blob/main/npm-packages/capacitor-sms-otp-send-verify/src/definitions.ts): `npm-packages/capacitor-sms-otp-send-verify/src/definitions.ts`
- [Cordova plugin](https://github.com/1fancy/sms8-sms-gateway/blob/main/npm-packages/cordova-plugin-sms-otp-send/www/SmsOtp.js): `npm-packages/cordova-plugin-sms-otp-send/www/SmsOtp.js`

### Mobile SDKs

- [Android SDK](https://github.com/1fancy/sms8-sms-gateway/blob/main/sdks/sms8-android/sms8/src/main/java/io/sms8/SMS8.kt): `sdks/sms8-android/sms8/src/main/java/io/sms8/SMS8.kt`
- [Android autofill](https://github.com/1fancy/sms8-sms-gateway/blob/main/sdks/sms8-android/sms8/src/main/java/io/sms8/autofill/SMSRetriever.kt): `sdks/sms8-android/sms8/src/main/java/io/sms8/autofill/SMSRetriever.kt`
- [Swift SDK](https://github.com/1fancy/sms8-sms-gateway/blob/main/sdks/sms8-swift/Sources/SMS8/SMS8.swift): `sdks/sms8-swift/Sources/SMS8/SMS8.swift`
- [iOS OTP field](https://github.com/1fancy/sms8-sms-gateway/blob/main/sdks/sms8-swift/Sources/SMS8/OTPTextField.swift): `sdks/sms8-swift/Sources/SMS8/OTPTextField.swift`

### Web presence

- [Documentation pages](https://github.com/1fancy/sms8-sms-gateway/blob/main/pages/api.php): `pages/api.php`

### Other components

- **AI coding tool**
- **SMS8 platform**
- **Paired Android phone**

## Connections

- AI coding tool → HTTP entry: calls MCP (evidence: `README.md`)
- HTTP entry → JSON-RPC dispatch: dispatches (evidence: `index.php`)
- HTTP entry → Tool registry: loads tools (evidence: `index.php`)
- JSON-RPC dispatch → Tool registry: routes tool calls (evidence: `lib/JsonRpc.php`)
- Tool registry → API-key auth: authenticates (evidence: `lib/ToolRegistry.php`)
- Tool registry → Setup context: invokes (evidence: `tools/setup_sms8.php`)
- Tool registry → Send SMS: invokes
- Tool registry → Send OTP: invokes
- Tool registry → Verify OTP: invokes
- Tool registry → Wait for OTP: invokes (evidence: `tools/wait_for_otp.php`)
- Tool registry → Read messages: invokes
- Tool registry → List devices: invokes
- Tool registry → Check balance: invokes
- Tool registry → Configure webhook: invokes (evidence: `tools/create_webhook.php`)
- Send SMS → SMS8 platform: sends through (evidence: `README.md`)
- Send OTP → SMS8 platform: sends through (evidence: `README.md`)
- Wait for OTP → Paired Android phone: waits for code (evidence: `README.md`)
- SMS8 platform → Paired Android phone: routes SMS (evidence: `README.md`)
- AI coding tool → MCP launcher: launches (evidence: `README.md`)
- SMS command-line clients → SMS8 platform: uses gateway (evidence: `README.md`)
- React OTP hook → SMS8 platform: calls MCP API
- OTP form → OTP input: renders (evidence: `npm-packages/react-sms-otp/src/OtpForm.tsx`)
- Capacitor plugin → SMS8 platform: provides OTP access (evidence: `README.md`)
- Cordova plugin → SMS8 platform: provides OTP access (evidence: `README.md`)
- Android SDK → SMS8 platform: uses API (evidence: `README.md`)
- Android SDK → Android autofill: offers autofill (evidence: `README.md`)
- Swift SDK → SMS8 platform: uses API (evidence: `README.md`)
- Swift SDK → iOS OTP field: offers autofill field (evidence: `README.md`)
- Documentation pages → AI coding tool: documents integration (evidence: `pages/api.php`)
