# biasmanan2010/zeppay architecture

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

- Interactive diagram: https://gitdiagram.com/biasmanan2010/zeppay
- Repository: https://github.com/biasmanan2010/zeppay

## Overview

#### Purpose and Targets
Zep Pay is an offline-first UPI payment product centered on QR payment initiation, biometric confirmation, and Android USSD/123PAY dialing; users enter their UPI PIN outside the app. The primary client is Flutter, with Android-native telephony integration. Separate React PWA/iPhone web delivery supports `upi://` handoff rather than offline dialing.
- `lib/main.dart`
- `zeppay-pwa/src/main.jsx`
- `.github/workflows/android-apk.yml`

#### Application Bootstrap, State, and Navigation
Flutter starts in `main.dart`, composes app-wide Riverpod providers, theme, locale, routing, and persisted state. Presentation screens consume services and repositories rather than directly owning platform/network operations. The home shell is the central post-auth navigation boundary.
- `lib/main.dart`
- `lib/presentation/providers/app_providers.dart`
- `lib/core/routing/app_router.dart`

#### Identity and Onboarding
The auth flow collects onboarding permissions, phone identity, and OTP verification before payment use. OTP behavior is split between Flutter client services and a server-side proxy; a development fallback code is documented. Biometric checks provide local confirmation before payment rail handoff.
- `lib/presentation/screens/auth/onboarding_permissions.dart`
- `lib/presentation/screens/auth/otp_screen.dart`
- `lib/data/services/otp_service.dart`

#### Payment Orchestration
Payment flow moves from QR parsing/scanning to recipient and amount capture, confirmation/biometric approval, then a payment session/rail decision. Status tracking and verification are separate from UI, allowing call/USSD completion to drive the outcome stage.
- `lib/presentation/screens/pay/scan_screen.dart`
- `lib/data/services/payment_session.dart`
- `lib/data/services/rail_engine.dart`

#### Android Platform Boundary
Flutter reaches Android features through platform-specific service implementations. Kotlin bridges detect telephony/carrier conditions, initiate calls, and handle USSD interaction/accessibility overlays; these capabilities are Android-only. The manifest and accessibility service configuration define the privileged OS boundary.
- `android/app/src/main/kotlin/in/zeppay/zeppay/MainActivity.kt`
- `android/app/src/main/kotlin/in/zeppay/zeppay/TelephonyBridge.kt`
- `android/app/src/main/kotlin/in/zeppay/zeppay/UssdAccessibilityService.kt`

#### Data, Offline Domain Features, and Sync
Local JSON-backed storage is the primary persistence layer and supports offline-first payment-adjacent state. Domain services cover cards/NFC, contacts, autopay, splits, referrals, inventory/semiconductor workflows, notifications, and sync. Repositories isolate persisted models from screens and permit a future backend-store replacement.
- `lib/data/local/app_store.dart`
- `lib/data/services/user_card_repository.dart`
- `lib/data/services/sync_service.dart`

#### Backend and External Infrastructure
A Node service, intended for Render, keeps Twilio credentials and Supabase service-role access off-device. It provides OTP/proxy operations and health checks. Supabase SQL schemas define hosted user, OTP, app configuration, referral, card, and semiconductor data; Flutter’s Supabase service is the client integration seam.
- `backend/server.js`
- `backend/db.js`
- `supabase/schema.sql`

#### Web and Deployment Variants
The Flutter web target supports Android-browser usage and iOS redirect behavior. The independent React PWA is the iPhone-oriented site, using UPI deep-link handoff. GitHub Actions produces APK and web artifacts, while GitHub Pages hosts published static variants.
- `lib/core/ios_web_redirect.dart`
- `zeppay-pwa/src/App.jsx`
- `gh-pages-root/zeppay/profile/index.html`

Main entry points: [`lib/main.dart`](https://github.com/biasmanan2010/zeppay/blob/main/lib/main.dart) (App bootstrap), [`lib/core/routing/app_router.dart`](https://github.com/biasmanan2010/zeppay/blob/main/lib/core/routing/app_router.dart) (App router), [`lib/data/services/payment_session.dart`](https://github.com/biasmanan2010/zeppay/blob/main/lib/data/services/payment_session.dart) (Payment session), [`lib/data/local/app_store.dart`](https://github.com/biasmanan2010/zeppay/blob/main/lib/data/local/app_store.dart) (Local app store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_flutter["Flutter app"]
  node_bootstrap["App bootstrap<br/>Flutter entry<br/>[main.dart]"]
  node_providers["App providers<br/>Riverpod state<br/>[app_providers.dart]"]
  node_router["App router<br/>Navigation<br/>[app_router.dart]"]
  node_onboarding["Onboarding and OTP<br/>Auth screens<br/>[otp_screen.dart]"]
  node_otp["OTP service<br/>Client service<br/>[otp_service.dart]"]
  node_scan["QR scan and payment entry<br/>Payment UI<br/>[scan_screen.dart]"]
  node_payment_session["Payment session<br/>Payment orchestration"]
  node_rail_engine["Rail engine<br/>Rail selection<br/>[rail_engine.dart]"]
  node_app_store[("Local app store<br/>JSON persistence<br/>[app_store.dart]")]
  node_card_repository["Card repository<br/>Domain repository"]
  node_sync["Sync service<br/>Synchronization<br/>[sync_service.dart]"]
end

subgraph group_android["Android platform"]
  node_main_activity["Flutter Android bridge<br/>Kotlin activity<br/>[MainActivity.kt]"]
  node_telephony["Telephony bridge<br/>Kotlin telephony<br/>[TelephonyBridge.kt]"]
  node_ussd["USSD accessibility<br/>Android accessibility"]
end

subgraph group_backend["Backend and data"]
  node_node_backend["OTP proxy backend<br/>Node service<br/>[server.js]"]
  node_backend_db["Backend data access<br/>Node data layer<br/>[db.js]"]
  node_supabase_schema[("Supabase schema<br/>Hosted data schema<br/>[schema.sql]")]
end

subgraph group_web["Web variants and delivery"]
  node_ios_redirect["iOS web redirect<br/>Flutter web behavior"]
  node_pwa["iPhone React PWA<br/>[App.jsx]"]
  node_ci["APK and web build<br/>GitHub Actions<br/>[android-apk.yml]"]
  node_pages["Published static site<br/>GitHub Pages output<br/>[index.html]"]
end

node_bootstrap -->|"initializes"| node_providers
node_bootstrap -->|"configures"| node_router
node_router -->|"routes unauthenticated users"| node_onboarding
node_onboarding -->|"verifies phone"| node_otp
node_otp -->|"proxies OTP"| node_node_backend
node_router -->|"opens payment flow"| node_scan
node_scan -->|"creates session"| node_payment_session
node_payment_session -->|"requests rail decision"| node_rail_engine
node_rail_engine -->|"invokes Android rail"| node_main_activity
node_main_activity -->|"bridges calls"| node_telephony
node_telephony -->|"drives USSD interaction"| node_ussd
node_payment_session -->|"persists status offline"| node_app_store
node_card_repository -->|"reads and writes"| node_app_store
node_sync -->|"syncs local state"| node_app_store
node_node_backend -->|"uses"| node_backend_db
node_backend_db -->|"accesses"| node_supabase_schema
node_bootstrap -.->|"applies on Flutter web"| node_ios_redirect
node_pwa -->|"published as static site"| node_pages
node_ci -->|"publishes web artifacts"| node_pages
node_ci -.->|"builds Flutter targets"| node_bootstrap

click node_bootstrap "https://github.com/biasmanan2010/zeppay/blob/main/lib/main.dart"
click node_providers "https://github.com/biasmanan2010/zeppay/blob/main/lib/presentation/providers/app_providers.dart"
click node_router "https://github.com/biasmanan2010/zeppay/blob/main/lib/core/routing/app_router.dart"
click node_onboarding "https://github.com/biasmanan2010/zeppay/blob/main/lib/presentation/screens/auth/otp_screen.dart"
click node_otp "https://github.com/biasmanan2010/zeppay/blob/main/lib/data/services/otp_service.dart"
click node_scan "https://github.com/biasmanan2010/zeppay/blob/main/lib/presentation/screens/pay/scan_screen.dart"
click node_payment_session "https://github.com/biasmanan2010/zeppay/blob/main/lib/data/services/payment_session.dart"
click node_rail_engine "https://github.com/biasmanan2010/zeppay/blob/main/lib/data/services/rail_engine.dart"
click node_app_store "https://github.com/biasmanan2010/zeppay/blob/main/lib/data/local/app_store.dart"
click node_card_repository "https://github.com/biasmanan2010/zeppay/blob/main/lib/data/services/user_card_repository.dart"
click node_sync "https://github.com/biasmanan2010/zeppay/blob/main/lib/data/services/sync_service.dart"
click node_main_activity "https://github.com/biasmanan2010/zeppay/blob/main/android/app/src/main/kotlin/in/zeppay/zeppay/MainActivity.kt"
click node_telephony "https://github.com/biasmanan2010/zeppay/blob/main/android/app/src/main/kotlin/in/zeppay/zeppay/TelephonyBridge.kt"
click node_ussd "https://github.com/biasmanan2010/zeppay/blob/main/android/app/src/main/kotlin/in/zeppay/zeppay/UssdAccessibilityService.kt"
click node_node_backend "https://github.com/biasmanan2010/zeppay/blob/main/backend/server.js"
click node_backend_db "https://github.com/biasmanan2010/zeppay/blob/main/backend/db.js"
click node_supabase_schema "https://github.com/biasmanan2010/zeppay/blob/main/supabase/schema.sql"
click node_ios_redirect "https://github.com/biasmanan2010/zeppay/blob/main/lib/core/ios_web_redirect.dart"
click node_pwa "https://github.com/biasmanan2010/zeppay/blob/main/zeppay-pwa/src/App.jsx"
click node_ci "https://github.com/biasmanan2010/zeppay/blob/main/.github/workflows/android-apk.yml"
click node_pages "https://github.com/biasmanan2010/zeppay/blob/main/gh-pages-root/zeppay/profile/index.html"

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_bootstrap,node_providers,node_router,node_onboarding,node_otp,node_scan,node_payment_session,node_rail_engine,node_app_store,node_card_repository,node_sync toneBlue
class node_main_activity,node_telephony,node_ussd toneAmber
class node_node_backend,node_backend_db,node_supabase_schema toneMint
class node_ios_redirect,node_pwa,node_ci,node_pages toneRose
```

## Components

### Flutter app

Offline-first payment client.

- [App bootstrap](https://github.com/biasmanan2010/zeppay/blob/main/lib/main.dart): Flutter entry · Composes providers, theme, locale, routing, and persisted state. · `lib/main.dart`
- [App providers](https://github.com/biasmanan2010/zeppay/blob/main/lib/presentation/providers/app_providers.dart): Riverpod state · `lib/presentation/providers/app_providers.dart`
- [App router](https://github.com/biasmanan2010/zeppay/blob/main/lib/core/routing/app_router.dart): Navigation · Routes onboarding and post-auth home flows. · `lib/core/routing/app_router.dart`
- [Onboarding and OTP](https://github.com/biasmanan2010/zeppay/blob/main/lib/presentation/screens/auth/otp_screen.dart): Auth screens · Collects permissions, phone identity, and OTP. · `lib/presentation/screens/auth/otp_screen.dart`
- [OTP service](https://github.com/biasmanan2010/zeppay/blob/main/lib/data/services/otp_service.dart): Client service · Uses server proxy behavior with a development fallback. · `lib/data/services/otp_service.dart`
- [QR scan and payment entry](https://github.com/biasmanan2010/zeppay/blob/main/lib/presentation/screens/pay/scan_screen.dart): Payment UI · Parses QR, captures recipient and amount, and requests confirmation. · `lib/presentation/screens/pay/scan_screen.dart`
- [Payment session](https://github.com/biasmanan2010/zeppay/blob/main/lib/data/services/payment_session.dart): Payment orchestration · Tracks payment stages and outcome verification apart from UI. · `lib/data/services/payment_session.dart`
- [Rail engine](https://github.com/biasmanan2010/zeppay/blob/main/lib/data/services/rail_engine.dart): Rail selection · Selects the applicable payment rail after biometric approval. · `lib/data/services/rail_engine.dart`
- [Local app store](https://github.com/biasmanan2010/zeppay/blob/main/lib/data/local/app_store.dart): JSON persistence · Primary offline-first persisted state. · `lib/data/local/app_store.dart`
- [Card repository](https://github.com/biasmanan2010/zeppay/blob/main/lib/data/services/user_card_repository.dart): Domain repository · Isolates persisted card and NFC models from screens. · `lib/data/services/user_card_repository.dart`
- [Sync service](https://github.com/biasmanan2010/zeppay/blob/main/lib/data/services/sync_service.dart): Synchronization · Synchronizes offline domain state when connectivity permits. · `lib/data/services/sync_service.dart`

### Android platform

Native telephony and USSD boundary.

- [Flutter Android bridge](https://github.com/biasmanan2010/zeppay/blob/main/android/app/src/main/kotlin/in/zeppay/zeppay/MainActivity.kt): Kotlin activity · Platform channel entry point for Android capabilities. · `android/app/src/main/kotlin/in/zeppay/zeppay/MainActivity.kt`
- [Telephony bridge](https://github.com/biasmanan2010/zeppay/blob/main/android/app/src/main/kotlin/in/zeppay/zeppay/TelephonyBridge.kt): Kotlin telephony · Detects carrier conditions and initiates calls. · `android/app/src/main/kotlin/in/zeppay/zeppay/TelephonyBridge.kt`
- [USSD accessibility](https://github.com/biasmanan2010/zeppay/blob/main/android/app/src/main/kotlin/in/zeppay/zeppay/UssdAccessibilityService.kt): Android accessibility · Handles USSD interaction and overlays; users enter PIN outside the app. · `android/app/src/main/kotlin/in/zeppay/zeppay/UssdAccessibilityService.kt`

### Backend and data

Protected server integrations and hosted schema.

- [OTP proxy backend](https://github.com/biasmanan2010/zeppay/blob/main/backend/server.js): Node service · Keeps Twilio and Supabase service-role credentials off-device. · `backend/server.js`
- [Backend data access](https://github.com/biasmanan2010/zeppay/blob/main/backend/db.js): Node data layer · `backend/db.js`
- [Supabase schema](https://github.com/biasmanan2010/zeppay/blob/main/supabase/schema.sql): Hosted data schema · Defines user, OTP, configuration, referral, card, and semiconductor data. · `supabase/schema.sql`

### Web variants and delivery

Browser-specific payment handoff and publishing.

- [iOS web redirect](https://github.com/biasmanan2010/zeppay/blob/main/lib/core/ios_web_redirect.dart): Flutter web behavior · Redirects iOS browser users to UPI handoff. · `lib/core/ios_web_redirect.dart`
- [iPhone React PWA](https://github.com/biasmanan2010/zeppay/blob/main/zeppay-pwa/src/App.jsx): React PWA · Uses upi:// deep-link handoff instead of offline dialing. · `zeppay-pwa/src/App.jsx`
- [APK and web build](https://github.com/biasmanan2010/zeppay/blob/main/.github/workflows/android-apk.yml): GitHub Actions · Builds Android APK and web artifacts. · `.github/workflows/android-apk.yml`
- [Published static site](https://github.com/biasmanan2010/zeppay/blob/main/gh-pages-root/zeppay/profile/index.html): GitHub Pages output · `gh-pages-root/zeppay/profile/index.html`

## Connections

- App bootstrap → App providers: initializes
- App bootstrap → App router: configures
- App router → Onboarding and OTP: routes unauthenticated users
- Onboarding and OTP → OTP service: verifies phone
- OTP service → OTP proxy backend: proxies OTP
- App router → QR scan and payment entry: opens payment flow
- QR scan and payment entry → Payment session: creates session
- Payment session → Rail engine: requests rail decision
- Rail engine → Flutter Android bridge: invokes Android rail
- Flutter Android bridge → Telephony bridge: bridges calls
- Telephony bridge → USSD accessibility: drives USSD interaction
- Payment session → Local app store: persists status offline
- Card repository → Local app store: reads and writes
- Sync service → Local app store: syncs local state
- OTP proxy backend → Backend data access: uses
- Backend data access → Supabase schema: accesses
- App bootstrap → iOS web redirect: applies on Flutter web
- iPhone React PWA → Published static site: published as static site
- APK and web build → Published static site: publishes web artifacts
- APK and web build → App bootstrap: builds Flutter targets
