# aarohanbasnet/payflow-api architecture

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

- Interactive diagram: https://gitdiagram.com/aarohanbasnet/payflow-api
- Repository: https://github.com/aarohanbasnet/payflow-api

## Overview

PayFlow is a learning-focused wallet and payments API. Its main user journey is registration and email verification, followed by login, then authenticated account operations such as peer transfers or utility payments; transaction records can also be retrieved and used for invoice PDFs. The graph separates HTTP routing, identity, wallet operations, and supporting services. Relationships are based on the README and the supplied excerpts and SOURCE INDEX; unsampled route and service details are represented only where those references support them.

Main entry points: [`src/app.ts`](https://github.com/aarohanbasnet/payflow-api/blob/main/src/app.ts) (Express application), [`src/modules/services/email/email.service.ts`](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/services/email/email.service.ts) (Email delivery), [`src/modules/transaction/transaction.service.ts`](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/transaction/transaction.service.ts) (Transfers and payments), [`src/config/prisma.ts`](https://github.com/aarohanbasnet/payflow-api/blob/main/src/config/prisma.ts) (Relational database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API surface"]
  node_app["Express application<br/>[app.ts]"]
  node_auth_routes["Auth routes<br/>[auth.route.ts]"]
  node_user_routes["User routes<br/>[user.routes.ts]"]
  node_account_routes["Account routes<br/>[account.route.ts]"]
  node_transaction_routes["Transaction routes"]
  node_invoice_routes["Invoice routes<br/>[invoice.route.ts]"]
  node_middleware["Request middleware"]
end

subgraph group_identity["Identity and users"]
  node_auth_controller["Auth handlers<br/>[auth.controller.ts]"]
  node_auth_service["Authentication logic<br/>[auth.services.ts]"]
  node_auth_schema["Auth validation<br/>[auth.schema.ts]"]
  node_user_controller["User handlers<br/>[user.controller.ts]"]
  node_user_service["User profile and MPIN<br/>[user.service.ts]"]
  node_user_schema["User validation<br/>[user.schema.ts]"]
  node_identity_utils["Identity utilities"]
end

subgraph group_wallet["Wallet operations"]
  node_account_controller["Account handlers"]
  node_account_service["Account operations<br/>[account.service.ts]"]
  node_account_schema["Account validation<br/>[account.schema.ts]"]
  node_transaction_controller["Transaction handlers"]
  node_transaction_service["Transfers and payments"]
  node_transaction_schema["Transaction validation"]
  node_invoice_controller["Invoice handlers"]
  node_invoice_service["Invoice data<br/>[invoice.service.ts]"]
  node_pdf["PDF generation<br/>[invoice.pdf.ts]"]
end

subgraph group_support["Supporting services"]
  node_database[("Relational database<br/>[prisma.ts]")]
  node_email_service["Email delivery<br/>[email.service.ts]"]
  node_email_templates["Email templates<br/>[email.template.ts]"]
  node_transaction_limit["Transaction limits<br/>[limit.service.ts]"]
  node_mpin_check["MPIN verification"]
  node_configuration["Environment settings<br/>[env.ts]"]
end

node_client(("API client"))
node_resend["Resend"]

node_client -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_auth_routes
node_app -->|"mounts routes"| node_user_routes
node_app -->|"mounts routes"| node_account_routes
node_app -->|"mounts routes"| node_transaction_routes
node_app -->|"mounts routes"| node_invoice_routes
node_auth_routes -->|"dispatches to"| node_auth_controller
node_auth_routes -->|"uses validation and limits"| node_middleware
node_user_routes -->|"dispatches to"| node_user_controller
node_user_routes -->|"authenticates and validates"| node_middleware
node_auth_controller -->|"calls"| node_auth_service
node_auth_controller -->|"uses input types"| node_auth_schema
node_auth_service -->|"reads and writes"| node_database
node_auth_service -->|"uses token and credential helpers"| node_identity_utils
node_auth_service -->|"sends OTP email"| node_email_service
node_user_controller -->|"calls"| node_user_service
node_user_controller -->|"uses input types"| node_user_schema
node_account_controller -->|"calls"| node_account_service
node_account_controller -->|"uses validation"| node_account_schema
node_account_service -->|"reads and writes"| node_database
node_account_service -->|"uses email delivery"| node_email_service
node_account_service -->|"checks MPIN"| node_mpin_check
node_transaction_controller -->|"calls"| node_transaction_service
node_transaction_controller -->|"uses validation"| node_transaction_schema
node_transaction_service -->|"reads and writes"| node_database
node_transaction_service -->|"checks limits"| node_transaction_limit
node_transaction_service -->|"checks MPIN"| node_mpin_check
node_transaction_service -->|"sends alerts"| node_email_service
node_invoice_controller -->|"calls"| node_invoice_service
node_invoice_controller -->|"uses PDF generation"| node_pdf
node_invoice_service -->|"reads records"| node_database
node_email_service -->|"renders messages"| node_email_templates
node_email_service -->|"sends email"| node_resend
node_email_service -->|"reads credentials"| node_configuration
node_database -->|"gets connection settings"| node_configuration

click node_app "https://github.com/aarohanbasnet/payflow-api/blob/main/src/app.ts"
click node_auth_routes "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/auth/auth.route.ts"
click node_user_routes "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/user/user.routes.ts"
click node_account_routes "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/account/account.route.ts"
click node_transaction_routes "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/transaction/transaction.route.ts"
click node_invoice_routes "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/invoice/invoice.route.ts"
click node_middleware "https://github.com/aarohanbasnet/payflow-api/tree/main/src/middlewares"
click node_auth_controller "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/auth/auth.controller.ts"
click node_auth_service "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/auth/auth.services.ts"
click node_auth_schema "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/auth/auth.schema.ts"
click node_user_controller "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/user/user.controller.ts"
click node_user_service "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/user/user.service.ts"
click node_user_schema "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/user/user.schema.ts"
click node_identity_utils "https://github.com/aarohanbasnet/payflow-api/tree/main/src/utils"
click node_account_controller "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/account/account.controller.ts"
click node_account_service "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/account/account.service.ts"
click node_account_schema "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/account/account.schema.ts"
click node_transaction_controller "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/transaction/transaction.controller.ts"
click node_transaction_service "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/transaction/transaction.service.ts"
click node_transaction_schema "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/transaction/transaction.schema.ts"
click node_invoice_controller "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/invoice/invoice.controller.ts"
click node_invoice_service "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/invoice/invoice.service.ts"
click node_pdf "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/invoice/pdf/invoice.pdf.ts"
click node_database "https://github.com/aarohanbasnet/payflow-api/blob/main/src/config/prisma.ts"
click node_email_service "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/services/email/email.service.ts"
click node_email_templates "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/services/email/email.template.ts"
click node_transaction_limit "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/services/limit.service.ts"
click node_mpin_check "https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/services/verify-mpin.service.ts"
click node_configuration "https://github.com/aarohanbasnet/payflow-api/blob/main/src/config/env.ts"

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_app,node_auth_routes,node_user_routes,node_account_routes,node_transaction_routes,node_invoice_routes,node_middleware,node_client toneBlue
class node_auth_controller,node_auth_service,node_auth_schema,node_user_controller,node_user_service,node_user_schema,node_identity_utils toneAmber
class node_account_controller,node_account_service,node_account_schema,node_transaction_controller,node_transaction_service,node_transaction_schema,node_invoice_controller,node_invoice_service,node_pdf toneMint
class node_database,node_email_service,node_email_templates,node_transaction_limit,node_mpin_check,node_configuration toneRose
class node_resend toneIndigo
```

## Components

### API surface

- [Express application](https://github.com/aarohanbasnet/payflow-api/blob/main/src/app.ts): `src/app.ts`
- [Auth routes](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/auth/auth.route.ts): `src/modules/auth/auth.route.ts`
- [User routes](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/user/user.routes.ts): `src/modules/user/user.routes.ts`
- [Account routes](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/account/account.route.ts): `src/modules/account/account.route.ts`
- [Transaction routes](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/transaction/transaction.route.ts): `src/modules/transaction/transaction.route.ts`
- [Invoice routes](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/invoice/invoice.route.ts): `src/modules/invoice/invoice.route.ts`
- [Request middleware](https://github.com/aarohanbasnet/payflow-api/tree/main/src/middlewares): `src/middlewares`

### Identity and users

- [Auth handlers](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/auth/auth.controller.ts): `src/modules/auth/auth.controller.ts`
- [Authentication logic](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/auth/auth.services.ts): `src/modules/auth/auth.services.ts`
- [Auth validation](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/auth/auth.schema.ts): `src/modules/auth/auth.schema.ts`
- [User handlers](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/user/user.controller.ts): `src/modules/user/user.controller.ts`
- [User profile and MPIN](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/user/user.service.ts): `src/modules/user/user.service.ts`
- [User validation](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/user/user.schema.ts): `src/modules/user/user.schema.ts`
- [Identity utilities](https://github.com/aarohanbasnet/payflow-api/tree/main/src/utils): `src/utils`

### Wallet operations

- [Account handlers](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/account/account.controller.ts): `src/modules/account/account.controller.ts`
- [Account operations](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/account/account.service.ts): `src/modules/account/account.service.ts`
- [Account validation](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/account/account.schema.ts): `src/modules/account/account.schema.ts`
- [Transaction handlers](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/transaction/transaction.controller.ts): `src/modules/transaction/transaction.controller.ts`
- [Transfers and payments](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/transaction/transaction.service.ts): `src/modules/transaction/transaction.service.ts`
- [Transaction validation](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/transaction/transaction.schema.ts): `src/modules/transaction/transaction.schema.ts`
- [Invoice handlers](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/invoice/invoice.controller.ts): `src/modules/invoice/invoice.controller.ts`
- [Invoice data](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/invoice/invoice.service.ts): `src/modules/invoice/invoice.service.ts`
- [PDF generation](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/invoice/pdf/invoice.pdf.ts): `src/modules/invoice/pdf/invoice.pdf.ts`

### Supporting services

- [Relational database](https://github.com/aarohanbasnet/payflow-api/blob/main/src/config/prisma.ts): `src/config/prisma.ts`
- [Email delivery](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/services/email/email.service.ts): `src/modules/services/email/email.service.ts`
- [Email templates](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/services/email/email.template.ts): `src/modules/services/email/email.template.ts`
- [Transaction limits](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/services/limit.service.ts): `src/modules/services/limit.service.ts`
- [MPIN verification](https://github.com/aarohanbasnet/payflow-api/blob/main/src/modules/services/verify-mpin.service.ts): `src/modules/services/verify-mpin.service.ts`
- [Environment settings](https://github.com/aarohanbasnet/payflow-api/blob/main/src/config/env.ts): `src/config/env.ts`

### Other components

- **API client**
- **Resend**

## Connections

- API client → Express application: sends requests (evidence: `src/app.ts`)
- Express application → Auth routes: mounts routes (evidence: `src/app.ts`)
- Express application → User routes: mounts routes (evidence: `src/app.ts`)
- Express application → Account routes: mounts routes (evidence: `src/app.ts`)
- Express application → Transaction routes: mounts routes (evidence: `src/app.ts`)
- Express application → Invoice routes: mounts routes (evidence: `src/app.ts`)
- Auth routes → Auth handlers: dispatches to (evidence: `src/modules/auth/auth.route.ts`)
- Auth routes → Request middleware: uses validation and limits (evidence: `src/modules/auth/auth.route.ts`)
- User routes → User handlers: dispatches to (evidence: `src/modules/user/user.routes.ts`)
- User routes → Request middleware: authenticates and validates (evidence: `src/modules/user/user.routes.ts`)
- Auth handlers → Authentication logic: calls (evidence: `src/modules/auth/auth.controller.ts`)
- Auth handlers → Auth validation: uses input types (evidence: `src/modules/auth/auth.controller.ts`)
- Authentication logic → Relational database: reads and writes (evidence: `src/modules/auth/auth.services.ts`)
- Authentication logic → Identity utilities: uses token and credential helpers (evidence: `src/modules/auth/auth.services.ts`)
- Authentication logic → Email delivery: sends OTP email (evidence: `src/modules/auth/auth.services.ts`)
- User handlers → User profile and MPIN: calls (evidence: `src/modules/user/user.controller.ts`)
- User handlers → User validation: uses input types (evidence: `src/modules/user/user.controller.ts`)
- Account handlers → Account operations: calls (evidence: `src/modules/account/account.controller.ts`)
- Account handlers → Account validation: uses validation (evidence: `src/modules/account/account.controller.ts`)
- Account operations → Relational database: reads and writes (evidence: `src/modules/account/account.service.ts`)
- Account operations → Email delivery: uses email delivery (evidence: `src/modules/account/account.service.ts`)
- Account operations → MPIN verification: checks MPIN (evidence: `src/modules/account/account.service.ts`)
- Transaction handlers → Transfers and payments: calls (evidence: `src/modules/transaction/transaction.controller.ts`)
- Transaction handlers → Transaction validation: uses validation (evidence: `src/modules/transaction/transaction.controller.ts`)
- Transfers and payments → Relational database: reads and writes (evidence: `src/modules/transaction/transaction.service.ts`)
- Transfers and payments → Transaction limits: checks limits (evidence: `src/modules/transaction/transaction.service.ts`)
- Transfers and payments → MPIN verification: checks MPIN (evidence: `src/modules/transaction/transaction.service.ts`)
- Transfers and payments → Email delivery: sends alerts (evidence: `src/modules/transaction/transaction.service.ts`)
- Invoice handlers → Invoice data: calls (evidence: `src/modules/invoice/invoice.controller.ts`)
- Invoice handlers → PDF generation: uses PDF generation (evidence: `src/modules/invoice/invoice.controller.ts`)
- Invoice data → Relational database: reads records (evidence: `src/modules/invoice/invoice.service.ts`)
- Email delivery → Email templates: renders messages (evidence: `src/modules/services/email/email.service.ts`)
- Email delivery → Resend: sends email (evidence: `src/modules/services/email/email.service.ts`)
- Email delivery → Environment settings: reads credentials (evidence: `src/modules/services/email/email.service.ts`)
- Relational database → Environment settings: gets connection settings (evidence: `src/config/prisma.ts`)
