# ponvishal03/insuredge architecture

> Architecture diagram of the GitHub repository ponvishal03/insuredge, 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/ponvishal03/insuredge
- Repository: https://github.com/ponvishal03/insuredge

## Overview

INSUREDGE combines a web application and Express/MongoDB services with Solidity insurance policies. The main user journey is account access, KYC submission, policy selection and purchase, premium payment, then claim submission and review. The README also describes IPFS/Pinata document storage and MetaMask transactions, though their implementation is not established by the sampled source. The repository contains two server entry points; the graph keeps the separately evidenced claim service distinct. Edges without direct source wiring rely on documented README capabilities.

Main entry points: [`server.js`](https://github.com/ponvishal03/insuredge/blob/main/server.js) (KYC handling), [`public/js/wallet.js`](https://github.com/ponvishal03/insuredge/blob/main/public/js/wallet.js) (Wallet and policies), [`server/routes/claimRoutes.js`](https://github.com/ponvishal03/insuredge/blob/main/server/routes/claimRoutes.js) (Claim endpoints), [`server/controllers/claimController.js`](https://github.com/ponvishal03/insuredge/blob/main/server/controllers/claimController.js) (Claim handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_web_ui["Insurance UI<br/>[index.html]"]
  node_auth_client["Login and signup<br/>[main.js]"]
  node_wallet_client["Wallet and policies<br/>[wallet.js]"]
  node_kyc_client["KYC submission UI<br/>[kyc.js]"]
  node_admin_ui["Admin dashboard<br/>[admin.html]"]
end

subgraph group_identity["Identity and KYC"]
  node_auth_service["Authentication API<br/>[server.js]"]
  node_auth_middleware["JWT authorization<br/>[auth.js]"]
  node_user_model[("User records<br/>[User.js]")]
  node_kyc_api["KYC handling<br/>[server.js]"]
  node_kyc_model[("KYC records<br/>[KYC.js]")]
  node_document_upload["Document uploads<br/>[server.js]"]
end

subgraph group_insurance["Insurance lifecycle"]
  node_term_policy["Term life policy"]
  node_moneyback_policy["Money-back policy"]
  node_claim_api["Claim endpoints<br/>[claimRoutes.js]"]
  node_claim_logic["Claim handling<br/>[claimController.js]"]
  node_claim_model[("Claim records<br/>[Claim.js]")]
end

subgraph group_platform["Services and storage"]
  node_claim_service["Claim service<br/>[server.js]"]
  node_mongo[("MongoDB")]
  node_ipfs[("IPFS / Pinata")]
  node_ethereum[("Ethereum")]
end

node_policyholder(("Policyholder"))
node_metamask(("MetaMask"))

node_policyholder -->|"uses"| node_web_ui
node_web_ui -.->|"loads"| node_auth_client
node_auth_client -->|"authenticates"| node_auth_service
node_auth_service -->|"protects routes"| node_auth_middleware
node_auth_service -->|"reads users"| node_user_model
node_policyholder -->|"submits KYC"| node_kyc_client
node_kyc_client -->|"sends submission"| node_kyc_api
node_kyc_api -->|"guards routes"| node_auth_middleware
node_kyc_api -->|"looks up user"| node_user_model
node_kyc_api -->|"stores KYC"| node_kyc_model
node_kyc_api -->|"accepts documents"| node_document_upload
node_document_upload -.->|"stores documents"| node_ipfs
node_policyholder -->|"selects policy"| node_wallet_client
node_wallet_client -->|"requests payment"| node_metamask
node_metamask -->|"signs transaction"| node_ethereum
node_wallet_client -->|"purchases policy"| node_term_policy
node_wallet_client -->|"purchases policy"| node_moneyback_policy
node_policyholder -->|"submits claim"| node_claim_api
node_claim_service -->|"mounts routes"| node_claim_api
node_claim_api -->|"dispatches"| node_claim_logic
node_claim_logic -->|"saves and queries"| node_claim_model
node_claim_api -->|"updates status"| node_claim_logic
node_claim_logic -.->|"settles claim"| node_ethereum
node_admin_ui -.->|"reviews submissions"| node_kyc_api
node_claim_service -->|"connects"| node_mongo

click node_web_ui "https://github.com/ponvishal03/insuredge/blob/main/public/index.html"
click node_auth_client "https://github.com/ponvishal03/insuredge/blob/main/public/main.js"
click node_wallet_client "https://github.com/ponvishal03/insuredge/blob/main/public/js/wallet.js"
click node_kyc_client "https://github.com/ponvishal03/insuredge/blob/main/public/js/kyc.js"
click node_admin_ui "https://github.com/ponvishal03/insuredge/blob/main/public/admin.html"
click node_auth_service "https://github.com/ponvishal03/insuredge/blob/main/server.js"
click node_auth_middleware "https://github.com/ponvishal03/insuredge/blob/main/middleware/auth.js"
click node_user_model "https://github.com/ponvishal03/insuredge/blob/main/models/User.js"
click node_kyc_api "https://github.com/ponvishal03/insuredge/blob/main/server.js"
click node_kyc_model "https://github.com/ponvishal03/insuredge/blob/main/models/KYC.js"
click node_document_upload "https://github.com/ponvishal03/insuredge/blob/main/server.js"
click node_term_policy "https://github.com/ponvishal03/insuredge/blob/main/contracts/TermLifeInsurance.sol"
click node_moneyback_policy "https://github.com/ponvishal03/insuredge/blob/main/contracts/MoneyBackInsurance.sol"
click node_claim_api "https://github.com/ponvishal03/insuredge/blob/main/server/routes/claimRoutes.js"
click node_claim_logic "https://github.com/ponvishal03/insuredge/blob/main/server/controllers/claimController.js"
click node_claim_model "https://github.com/ponvishal03/insuredge/blob/main/server/models/Claim.js"
click node_claim_service "https://github.com/ponvishal03/insuredge/blob/main/server/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_web_ui,node_auth_client,node_wallet_client,node_kyc_client,node_admin_ui toneBlue
class node_auth_service,node_auth_middleware,node_user_model,node_kyc_api,node_kyc_model,node_document_upload toneAmber
class node_term_policy,node_moneyback_policy,node_claim_api,node_claim_logic,node_claim_model toneMint
class node_claim_service,node_mongo,node_ipfs,node_ethereum toneRose
class node_policyholder,node_metamask toneIndigo
```

## Components

### Web client

- [Insurance UI](https://github.com/ponvishal03/insuredge/blob/main/public/index.html): `public/index.html`
- [Login and signup](https://github.com/ponvishal03/insuredge/blob/main/public/main.js): `public/main.js`
- [Wallet and policies](https://github.com/ponvishal03/insuredge/blob/main/public/js/wallet.js): `public/js/wallet.js`
- [KYC submission UI](https://github.com/ponvishal03/insuredge/blob/main/public/js/kyc.js): `public/js/kyc.js`
- [Admin dashboard](https://github.com/ponvishal03/insuredge/blob/main/public/admin.html): `public/admin.html`

### Identity and KYC

- [Authentication API](https://github.com/ponvishal03/insuredge/blob/main/server.js): `server.js`
- [JWT authorization](https://github.com/ponvishal03/insuredge/blob/main/middleware/auth.js): `middleware/auth.js`
- [User records](https://github.com/ponvishal03/insuredge/blob/main/models/User.js): `models/User.js`
- [KYC handling](https://github.com/ponvishal03/insuredge/blob/main/server.js): `server.js`
- [KYC records](https://github.com/ponvishal03/insuredge/blob/main/models/KYC.js): `models/KYC.js`
- [Document uploads](https://github.com/ponvishal03/insuredge/blob/main/server.js): `server.js`

### Insurance lifecycle

- [Term life policy](https://github.com/ponvishal03/insuredge/blob/main/contracts/TermLifeInsurance.sol): `contracts/TermLifeInsurance.sol`
- [Money-back policy](https://github.com/ponvishal03/insuredge/blob/main/contracts/MoneyBackInsurance.sol): `contracts/MoneyBackInsurance.sol`
- [Claim endpoints](https://github.com/ponvishal03/insuredge/blob/main/server/routes/claimRoutes.js): `server/routes/claimRoutes.js`
- [Claim handling](https://github.com/ponvishal03/insuredge/blob/main/server/controllers/claimController.js): `server/controllers/claimController.js`
- [Claim records](https://github.com/ponvishal03/insuredge/blob/main/server/models/Claim.js): `server/models/Claim.js`

### Services and storage

- [Claim service](https://github.com/ponvishal03/insuredge/blob/main/server/server.js): `server/server.js`
- **MongoDB**
- **IPFS / Pinata**
- **Ethereum**

### Other components

- **Policyholder**
- **MetaMask**

## Connections

- Policyholder → Insurance UI: uses (evidence: `README.md`)
- Insurance UI → Login and signup: loads
- Login and signup → Authentication API: authenticates (evidence: `public/main.js`)
- Authentication API → JWT authorization: protects routes (evidence: `server.js`)
- Authentication API → User records: reads users (evidence: `server.js`)
- Policyholder → KYC submission UI: submits KYC (evidence: `README.md`)
- KYC submission UI → KYC handling: sends submission (evidence: `README.md`)
- KYC handling → JWT authorization: guards routes (evidence: `server.js`)
- KYC handling → User records: looks up user (evidence: `server.js`)
- KYC handling → KYC records: stores KYC (evidence: `server.js`)
- KYC handling → Document uploads: accepts documents (evidence: `server.js`)
- Document uploads → IPFS / Pinata: stores documents (evidence: `README.md`)
- Policyholder → Wallet and policies: selects policy (evidence: `README.md`)
- Wallet and policies → MetaMask: requests payment (evidence: `README.md`)
- MetaMask → Ethereum: signs transaction (evidence: `README.md`)
- Wallet and policies → Term life policy: purchases policy (evidence: `README.md`)
- Wallet and policies → Money-back policy: purchases policy (evidence: `README.md`)
- Policyholder → Claim endpoints: submits claim (evidence: `README.md`)
- Claim service → Claim endpoints: mounts routes (evidence: `server/server.js`)
- Claim endpoints → Claim handling: dispatches (evidence: `server/routes/claimRoutes.js`)
- Claim handling → Claim records: saves and queries (evidence: `server/controllers/claimController.js`)
- Claim endpoints → Claim handling: updates status (evidence: `server/routes/claimRoutes.js`)
- Claim handling → Ethereum: settles claim (evidence: `README.md`)
- Admin dashboard → KYC handling: reviews submissions (evidence: `README.md`)
- Claim service → MongoDB: connects (evidence: `server/server.js`)
