# mahmoud-nasser1/schnellpay-backend architecture

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

- Interactive diagram: https://gitdiagram.com/mahmoud-nasser1/schnellpay-backend
- Repository: https://github.com/mahmoud-nasser1/schnellpay-backend

## Overview

Schnell-Pay is a digital-wallet backend exposing REST APIs for accounts, authentication, identity checks, and financial operations, backed by MS SQL Server. The main workflow is a client request entering the API, passing through route-level authentication or authorization where configured, and reaching a controller that performs domain actions and persists state. Major branches include transfers, deposits, bill payments, ATM operations, KYC review, MFA, and administration. The graph reflects documented capabilities and indexed references; unsampled route/controller wiring is omitted where the evidence does not establish the call.

Main entry points: [`api/index.js`](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/api/index.js) (API Entry), [`utils/notificationHelper.js`](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/utils/notificationHelper.js) (Notifications), [`controllers/atm/atmController.js`](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/atm/atmController.js) (ATM Operations), [`models/transactionModel.js`](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/models/transactionModel.js) (Transaction Records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and Security"]
  node_api["API Entry<br/>[index.js]"]
  node_auth_routes["Auth Routes<br/>[authRoute.js]"]
  node_mfa_routes["MFA Routes<br/>[twoFaRoutes.js]"]
  node_atm_routes["ATM Routes<br/>[atmRoutes.js]"]
  node_kyc_routes["KYC Routes<br/>[kycRoutes.js]"]
  node_activity_routes["Activity Routes"]
end

subgraph group_identity["Identity and Access"]
  node_auth["Account Authentication<br/>[login.js]"]
  node_mfa["Two-Factor Authentication<br/>[twoFaController.js]"]
  node_users["User Management"]
  node_kyc["Identity Verification<br/>[kycController.js]"]
end

subgraph group_finance["Wallet Operations"]
  node_transfers["Transfers and Refunds"]
  node_deposits["Payment Deposits"]
  node_bills["Bill Payments<br/>[billsController.js]"]
  node_atm["ATM Operations<br/>[atmController.js]"]
end

subgraph group_governance["Administration"]
  node_activity["Activity Logging"]
  node_kyc_admin["KYC Administration"]
  node_admin_stats["Admin Statistics"]
end

subgraph group_storage["Persistence and Services"]
  node_transaction_store[("Transaction Records")]
  node_wallet_store[("Wallet Records<br/>[walletModel.js]")]
  node_user_store[("User Records<br/>[userModel.js]")]
  node_kyc_store[("KYC Records<br/>[kycModel.js]")]
  node_notifications["Notifications"]
  node_notification_store[("Notification Records")]
  node_database[("SQL Server<br/>[db.js]")]
  node_activity_store[("Activity Log Records")]
end

node_client(("API Client"))
node_atm_client(("ATM Client"))

node_client -->|"sends requests"| node_api
node_atm_client -->|"uses REST API"| node_api
node_api -->|"mounts routes"| node_auth_routes
node_api -->|"mounts routes"| node_mfa_routes
node_api -->|"mounts routes"| node_atm_routes
node_api -->|"mounts routes"| node_kyc_routes
node_api -->|"mounts routes"| node_activity_routes
node_mfa_routes -->|"routes to"| node_mfa
node_atm_routes -->|"routes to"| node_atm
node_kyc_routes -->|"routes to"| node_kyc
node_kyc_routes -->|"routes to"| node_kyc_admin
node_activity_routes -->|"routes to"| node_activity
node_mfa -->|"reads account"| node_user_store
node_mfa -->|"sends MFA email"| node_notifications
node_atm -->|"looks up user"| node_user_store
node_atm -->|"updates balance"| node_wallet_store
node_atm -->|"records operation"| node_transaction_store
node_atm -->|"creates notice"| node_notifications
node_transfers -->|"looks up parties"| node_user_store
node_transfers -->|"changes balances"| node_wallet_store
node_transfers -->|"records transfer"| node_transaction_store
node_transfers -->|"creates notices"| node_notifications
node_deposits -->|"updates balance"| node_wallet_store
node_deposits -->|"records deposit"| node_transaction_store
node_deposits -->|"creates notice"| node_notifications
node_bills -->|"uses wallet"| node_wallet_store
node_bills -->|"uses transactions"| node_transaction_store
node_kyc -->|"submits records"| node_kyc_store
node_kyc_admin -->|"reviews records"| node_kyc_store
node_kyc_admin -->|"notifies user"| node_notifications
node_activity -->|"checks user"| node_user_store
node_activity -->|"queries logs"| node_activity_store
node_notifications -->|"inserts notice"| node_notification_store
node_user_store -->|"queries SQL"| node_database
node_wallet_store -->|"queries SQL"| node_database
node_transaction_store -->|"queries SQL"| node_database
node_kyc_store -->|"queries SQL"| node_database
node_notification_store -->|"queries SQL"| node_database

click node_api "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/api/index.js"
click node_auth_routes "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/routes/auth/authRoute.js"
click node_mfa_routes "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/routes/auth/twoFaRoutes.js"
click node_atm_routes "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/routes/atm/atmRoutes.js"
click node_kyc_routes "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/routes/kyc/kycRoutes.js"
click node_activity_routes "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/routes/activityLog/activityLogRoutes.js"
click node_auth "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/auth/login.js"
click node_mfa "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/auth/twoFaController.js"
click node_users "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/users/updateUserController.js"
click node_kyc "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/kyc/kycController.js"
click node_transfers "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/transactions/transactionsController.js"
click node_deposits "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/paymentMethods/depositMethodController.js"
click node_bills "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/bills/billsController.js"
click node_atm "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/atm/atmController.js"
click node_transaction_store "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/models/transactionModel.js"
click node_wallet_store "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/models/walletModel.js"
click node_user_store "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/models/userModel.js"
click node_kyc_store "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/models/kycModel.js"
click node_activity "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/activityLog/activityLogController.js"
click node_kyc_admin "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/kyc/kycAdminController.js"
click node_admin_stats "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/admin/adminStatsController.js"
click node_notifications "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/utils/notificationHelper.js"
click node_notification_store "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/models/notificationModel.js"
click node_database "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/config/db.js"
click node_activity_store "https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/models/activityLogModel.js"

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_api,node_auth_routes,node_mfa_routes,node_atm_routes,node_kyc_routes,node_activity_routes,node_client,node_atm_client toneBlue
class node_auth,node_mfa,node_users,node_kyc toneAmber
class node_transfers,node_deposits,node_bills,node_atm toneMint
class node_activity,node_kyc_admin,node_admin_stats toneRose
class node_transaction_store,node_wallet_store,node_user_store,node_kyc_store,node_notifications,node_notification_store,node_database,node_activity_store toneIndigo
```

## Components

### API and Security

- [API Entry](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/api/index.js): `api/index.js`
- [Auth Routes](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/routes/auth/authRoute.js): `routes/auth/authRoute.js`
- [MFA Routes](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/routes/auth/twoFaRoutes.js): `routes/auth/twoFaRoutes.js`
- [ATM Routes](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/routes/atm/atmRoutes.js): `routes/atm/atmRoutes.js`
- [KYC Routes](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/routes/kyc/kycRoutes.js): `routes/kyc/kycRoutes.js`
- [Activity Routes](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/routes/activityLog/activityLogRoutes.js): `routes/activityLog/activityLogRoutes.js`

### Identity and Access

- [Account Authentication](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/auth/login.js): `controllers/auth/login.js`
- [Two-Factor Authentication](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/auth/twoFaController.js): `controllers/auth/twoFaController.js`
- [User Management](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/users/updateUserController.js): `controllers/users/updateUserController.js`
- [Identity Verification](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/kyc/kycController.js): `controllers/kyc/kycController.js`

### Wallet Operations

- [Transfers and Refunds](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/transactions/transactionsController.js): `controllers/transactions/transactionsController.js`
- [Payment Deposits](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/paymentMethods/depositMethodController.js): `controllers/paymentMethods/depositMethodController.js`
- [Bill Payments](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/bills/billsController.js): `controllers/bills/billsController.js`
- [ATM Operations](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/atm/atmController.js): `controllers/atm/atmController.js`

### Administration

- [Activity Logging](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/activityLog/activityLogController.js): `controllers/activityLog/activityLogController.js`
- [KYC Administration](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/kyc/kycAdminController.js): `controllers/kyc/kycAdminController.js`
- [Admin Statistics](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/controllers/admin/adminStatsController.js): `controllers/admin/adminStatsController.js`

### Persistence and Services

- [Transaction Records](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/models/transactionModel.js): `models/transactionModel.js`
- [Wallet Records](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/models/walletModel.js): `models/walletModel.js`
- [User Records](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/models/userModel.js): `models/userModel.js`
- [KYC Records](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/models/kycModel.js): `models/kycModel.js`
- [Notifications](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/utils/notificationHelper.js): `utils/notificationHelper.js`
- [Notification Records](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/models/notificationModel.js): `models/notificationModel.js`
- [SQL Server](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/config/db.js): `config/db.js`
- [Activity Log Records](https://github.com/mahmoud-nasser1/schnellpay-backend/blob/main/models/activityLogModel.js): `models/activityLogModel.js`

### Other components

- **API Client**
- **ATM Client**

## Connections

- API Client → API Entry: sends requests (evidence: `README.md`)
- ATM Client → API Entry: uses REST API (evidence: `README.md`)
- API Entry → Auth Routes: mounts routes (evidence: `api/index.js`)
- API Entry → MFA Routes: mounts routes (evidence: `api/index.js`)
- API Entry → ATM Routes: mounts routes (evidence: `api/index.js`)
- API Entry → KYC Routes: mounts routes (evidence: `api/index.js`)
- API Entry → Activity Routes: mounts routes (evidence: `api/index.js`)
- MFA Routes → Two-Factor Authentication: routes to (evidence: `routes/auth/twoFaRoutes.js`)
- ATM Routes → ATM Operations: routes to (evidence: `routes/atm/atmRoutes.js`)
- KYC Routes → Identity Verification: routes to (evidence: `routes/kyc/kycRoutes.js`)
- KYC Routes → KYC Administration: routes to (evidence: `routes/kyc/kycRoutes.js`)
- Activity Routes → Activity Logging: routes to (evidence: `routes/activityLog/activityLogRoutes.js`)
- Two-Factor Authentication → User Records: reads account (evidence: `controllers/auth/twoFaController.js`)
- Two-Factor Authentication → Notifications: sends MFA email (evidence: `controllers/auth/twoFaController.js`)
- ATM Operations → User Records: looks up user (evidence: `controllers/atm/atmController.js`)
- ATM Operations → Wallet Records: updates balance (evidence: `controllers/atm/atmController.js`)
- ATM Operations → Transaction Records: records operation (evidence: `models/transactionModel.js`)
- ATM Operations → Notifications: creates notice (evidence: `controllers/atm/atmController.js`)
- Transfers and Refunds → User Records: looks up parties (evidence: `controllers/transactions/transactionsController.js`)
- Transfers and Refunds → Wallet Records: changes balances (evidence: `controllers/transactions/transactionsController.js`)
- Transfers and Refunds → Transaction Records: records transfer (evidence: `controllers/transactions/transactionsController.js`)
- Transfers and Refunds → Notifications: creates notices (evidence: `controllers/transactions/transactionsController.js`)
- Payment Deposits → Wallet Records: updates balance (evidence: `controllers/paymentMethods/depositMethodController.js`)
- Payment Deposits → Transaction Records: records deposit (evidence: `controllers/paymentMethods/depositMethodController.js`)
- Payment Deposits → Notifications: creates notice (evidence: `controllers/paymentMethods/depositMethodController.js`)
- Bill Payments → Wallet Records: uses wallet (evidence: `controllers/bills/billsController.js`)
- Bill Payments → Transaction Records: uses transactions (evidence: `controllers/bills/billsController.js`)
- Identity Verification → KYC Records: submits records (evidence: `controllers/kyc/kycController.js`)
- KYC Administration → KYC Records: reviews records (evidence: `controllers/kyc/kycAdminController.js`)
- KYC Administration → Notifications: notifies user (evidence: `controllers/kyc/kycAdminController.js`)
- Activity Logging → User Records: checks user (evidence: `controllers/activityLog/activityLogController.js`)
- Activity Logging → Activity Log Records: queries logs (evidence: `controllers/activityLog/activityLogController.js`)
- Notifications → Notification Records: inserts notice (evidence: `utils/notificationHelper.js`)
- User Records → SQL Server: queries SQL (evidence: `models/userModel.js`)
- Wallet Records → SQL Server: queries SQL (evidence: `models/walletModel.js`)
- Transaction Records → SQL Server: queries SQL (evidence: `models/transactionModel.js`)
- KYC Records → SQL Server: queries SQL (evidence: `models/kycModel.js`)
- Notification Records → SQL Server: queries SQL (evidence: `models/notificationModel.js`)
