# abhisheksingh-dev22/whatsapp-otp architecture

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

- Interactive diagram: https://gitdiagram.com/abhisheksingh-dev22/whatsapp-otp
- Repository: https://github.com/abhisheksingh-dev22/whatsapp-otp

## Overview

This repository is a WhatsApp OTP test harness: a user submits a mobile number, requests an OTP delivered through MSG91, then submits the code for backend verification. Angular’s bootstrap and root component host the form; its service makes HTTP requests to Express, which manages OTP state and talks to MSG91. The backend uses an in-memory map with expiry, cooldown, and attempt limits. The graph follows the sampled source and README; the integration guide and form template were not provided, so their details are not inferred.

Main entry points: [`frontend/src/app/otp.service.ts`](https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/frontend/src/app/otp.service.ts) (OTP service), [`backend/server.js`](https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/backend/server.js) (Send endpoint), [`frontend/src/app/whatsapp-otp-test/whatsapp-otp-test.component.ts`](https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/frontend/src/app/whatsapp-otp-test/whatsapp-otp-test.component.ts) (OTP form), [`frontend/src/main.ts`](https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/frontend/src/main.ts) (App bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_angular["Angular application"]
  node_bootstrap["App bootstrap<br/>[main.ts]"]
  node_root["Root component<br/>[app.component.ts]"]
  node_form["OTP form"]
  node_service["OTP service<br/>[otp.service.ts]"]
  node_config["HTTP configuration<br/>[app.config.ts]"]
end

subgraph group_backend["OTP backend"]
  node_send["Send endpoint<br/>[server.js]"]
  node_verify["Verify endpoint<br/>[server.js]"]
  node_otpstate[("OTP state<br/>[server.js]")]
end

subgraph group_delivery["WhatsApp delivery"]
  node_msg91["MSG91 API"]
end

node_user(("User"))

node_user -->|"uses"| node_form
node_bootstrap -->|"bootstraps"| node_root
node_bootstrap -->|"configures"| node_config
node_root -->|"hosts"| node_form
node_form -->|"requests OTP"| node_service
node_service -->|"POSTs send"| node_send
node_service -->|"POSTs verify"| node_verify
node_send -->|"stores code"| node_otpstate
node_verify -->|"checks code"| node_otpstate
node_send -->|"sends WhatsApp"| node_msg91

click node_bootstrap "https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/frontend/src/main.ts"
click node_root "https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/frontend/src/app/app.component.ts"
click node_form "https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/frontend/src/app/whatsapp-otp-test/whatsapp-otp-test.component.ts"
click node_service "https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/frontend/src/app/otp.service.ts"
click node_config "https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/frontend/src/app/app.config.ts"
click node_send "https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/backend/server.js"
click node_verify "https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/backend/server.js"
click node_otpstate "https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/backend/server.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_bootstrap,node_root,node_form,node_service,node_config,node_user toneBlue
class node_send,node_verify,node_otpstate toneAmber
class node_msg91 toneMint
```

## Components

### Angular application

- [App bootstrap](https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/frontend/src/main.ts): `frontend/src/main.ts`
- [Root component](https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/frontend/src/app/app.component.ts): `frontend/src/app/app.component.ts`
- [OTP form](https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/frontend/src/app/whatsapp-otp-test/whatsapp-otp-test.component.ts): `frontend/src/app/whatsapp-otp-test/whatsapp-otp-test.component.ts`
- [OTP service](https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/frontend/src/app/otp.service.ts): `frontend/src/app/otp.service.ts`
- [HTTP configuration](https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/frontend/src/app/app.config.ts): `frontend/src/app/app.config.ts`

### OTP backend

- [Send endpoint](https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/backend/server.js): `backend/server.js`
- [Verify endpoint](https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/backend/server.js): `backend/server.js`
- [OTP state](https://github.com/abhisheksingh-dev22/whatsapp-otp/blob/main/backend/server.js): `backend/server.js`

### WhatsApp delivery

- **MSG91 API**

### Other components

- **User**

## Connections

- User → OTP form: uses (evidence: `README.md`)
- App bootstrap → Root component: bootstraps (evidence: `frontend/src/main.ts`)
- App bootstrap → HTTP configuration: configures (evidence: `frontend/src/main.ts`)
- Root component → OTP form: hosts (evidence: `frontend/src/app/app.component.ts`)
- OTP form → OTP service: requests OTP (evidence: `frontend/src/app/whatsapp-otp-test/whatsapp-otp-test.component.ts`)
- OTP service → Send endpoint: POSTs send (evidence: `frontend/src/app/otp.service.ts`)
- OTP service → Verify endpoint: POSTs verify (evidence: `frontend/src/app/otp.service.ts`)
- Send endpoint → OTP state: stores code (evidence: `backend/server.js`)
- Verify endpoint → OTP state: checks code (evidence: `backend/server.js`)
- Send endpoint → MSG91 API: sends WhatsApp (evidence: `backend/server.js`)
