# mohansai12-1/alf_full architecture

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

- Interactive diagram: https://gitdiagram.com/mohansai12-1/alf_full
- Repository: https://github.com/mohansai12-1/alf_full

## Overview

Alance is a wallet-based finance platform: users authenticate with a signed wallet, register into a referral network, and use API capabilities for staking, swaps, bonds, DAO participation, rewards, settlement, and financial history. The frontend is a public-facing ecosystem and governance experience; the backend is the authenticated product API and its reward-processing services. The README gives no architecture detail, so backend links use the supplied source index and excerpts; unsampled subsystem internals are represented at their existing directory paths.

Main entry points: [`Alance-finance-user-backend-main/src/index.ts`](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/index.ts) (Backend API), [`Alance-finance-user-frontend-main/src/App.tsx`](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-frontend-main/src/App.tsx) (Alance site), [`Alance-finance-user-backend-main/src/staking/service.ts`](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/staking/service.ts) (Staking), [`Alance-finance-user-backend-main/src/rewards/worker.ts`](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/rewards/worker.ts) (Reward worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_frontend["Alance site<br/>[App.tsx]"]
  node_ecosystem["Ecosystem content<br/>[Ecosystem.tsx]"]
  node_governance["Governance content<br/>[Governance.tsx]"]
  node_token["Token content<br/>[TokenSection.tsx]"]
  node_transparency["Transparency content<br/>[Transparency.tsx]"]
end

subgraph group_identity["Identity and wallets"]
  node_auth["Wallet authentication<br/>[service.ts]"]
  node_authguard["Session guard<br/>[middleware.ts]"]
  node_wallet["Wallet onboarding<br/>[onboarding.ts]"]
  node_userstore[("User records<br/>[User.ts]")]
end

subgraph group_finance["Finance APIs"]
  node_staking["Staking<br/>[service.ts]"]
  node_bond["Bond purchases"]
  node_swap["Token swaps"]
  node_dao["DAO services<br/>[service.ts]"]
  node_referral["Referral network<br/>[service.ts]"]
  node_ledger["Transaction ledger"]
  node_daorevenue["DAO revenue"]
end

subgraph group_rewards["Rewards and settlement"]
  node_rewardengine["Reward calculation"]
  node_teamrewards["Team rewards"]
  node_settlement["Claims and proofs"]
  node_worker["Reward worker<br/>[worker.ts]"]
end

subgraph group_runtime["Backend runtime"]
  node_api["Backend API<br/>[index.ts]"]
  node_chain["Chain access<br/>[chain.ts]"]
  node_database[("MongoDB<br/>[db.ts]")]
end

node_visitor(("Visitor"))
node_chainservice{{"Polygon network"}}

node_visitor -->|"browses"| node_frontend
node_frontend -->|"renders"| node_ecosystem
node_frontend -->|"renders"| node_governance
node_frontend -->|"renders"| node_token
node_frontend -->|"renders"| node_transparency
node_api -->|"routes auth"| node_auth
node_api -->|"routes wallet"| node_wallet
node_api -->|"routes staking"| node_staking
node_api -->|"routes bonds"| node_bond
node_api -->|"routes swaps"| node_swap
node_api -->|"routes DAO"| node_dao
node_api -->|"routes referrals"| node_referral
node_api -->|"routes ledger"| node_ledger
node_api -->|"routes revenue"| node_daorevenue
node_api -->|"routes claims"| node_settlement
node_api -->|"starts worker"| node_worker
node_auth -->|"creates users"| node_userstore
node_authguard -->|"verifies sessions"| node_auth
node_chain -->|"reads chain"| node_chainservice
node_wallet -->|"resolves creation"| node_chain
node_staking -->|"reads receipts"| node_chain
node_staking -->|"loads users"| node_userstore
node_staking -->|"loads stake rewards"| node_rewardengine
node_referral -->|"reads referrals"| node_userstore
node_settlement -->|"reads team rewards"| node_teamrewards
node_worker -->|"runs calculations"| node_rewardengine
node_worker -->|"runs epochs"| node_teamrewards
node_worker -->|"reconciles claims"| node_settlement

click node_frontend "https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-frontend-main/src/App.tsx"
click node_ecosystem "https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-frontend-main/src/components/Ecosystem.tsx"
click node_governance "https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-frontend-main/src/components/Governance.tsx"
click node_token "https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-frontend-main/src/components/TokenSection.tsx"
click node_transparency "https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-frontend-main/src/components/Transparency.tsx"
click node_api "https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/index.ts"
click node_auth "https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/auth/service.ts"
click node_authguard "https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/auth/middleware.ts"
click node_wallet "https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/wallet/onboarding.ts"
click node_userstore "https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/models/User.ts"
click node_chain "https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/lib/chain.ts"
click node_staking "https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/staking/service.ts"
click node_bond "https://github.com/mohansai12-1/alf_full/tree/main/Alance-finance-user-backend-main/src/bond"
click node_swap "https://github.com/mohansai12-1/alf_full/tree/main/Alance-finance-user-backend-main/src/swap"
click node_dao "https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/dao/service.ts"
click node_referral "https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/referral/service.ts"
click node_ledger "https://github.com/mohansai12-1/alf_full/tree/main/Alance-finance-user-backend-main/src/ledger"
click node_daorevenue "https://github.com/mohansai12-1/alf_full/tree/main/Alance-finance-user-backend-main/src/daoRevenue"
click node_rewardengine "https://github.com/mohansai12-1/alf_full/tree/main/Alance-finance-user-backend-main/src/rewards"
click node_teamrewards "https://github.com/mohansai12-1/alf_full/tree/main/Alance-finance-user-backend-main/src/rewards/team"
click node_settlement "https://github.com/mohansai12-1/alf_full/tree/main/Alance-finance-user-backend-main/src/settlement"
click node_worker "https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/rewards/worker.ts"
click node_database "https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/db.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_frontend,node_ecosystem,node_governance,node_token,node_transparency toneBlue
class node_auth,node_authguard,node_wallet,node_userstore toneAmber
class node_staking,node_bond,node_swap,node_dao,node_referral,node_ledger,node_daorevenue toneMint
class node_rewardengine,node_teamrewards,node_settlement,node_worker toneRose
class node_api,node_chain,node_database,node_visitor,node_chainservice toneIndigo
```

## Components

### Web experience

- [Alance site](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-frontend-main/src/App.tsx): `Alance-finance-user-frontend-main/src/App.tsx`
- [Ecosystem content](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-frontend-main/src/components/Ecosystem.tsx): `Alance-finance-user-frontend-main/src/components/Ecosystem.tsx`
- [Governance content](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-frontend-main/src/components/Governance.tsx): `Alance-finance-user-frontend-main/src/components/Governance.tsx`
- [Token content](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-frontend-main/src/components/TokenSection.tsx): `Alance-finance-user-frontend-main/src/components/TokenSection.tsx`
- [Transparency content](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-frontend-main/src/components/Transparency.tsx): `Alance-finance-user-frontend-main/src/components/Transparency.tsx`

### Identity and wallets

- [Wallet authentication](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/auth/service.ts): `Alance-finance-user-backend-main/src/auth/service.ts`
- [Session guard](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/auth/middleware.ts): `Alance-finance-user-backend-main/src/auth/middleware.ts`
- [Wallet onboarding](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/wallet/onboarding.ts): `Alance-finance-user-backend-main/src/wallet/onboarding.ts`
- [User records](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/models/User.ts): `Alance-finance-user-backend-main/src/models/User.ts`

### Finance APIs

- [Staking](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/staking/service.ts): `Alance-finance-user-backend-main/src/staking/service.ts`
- [Bond purchases](https://github.com/mohansai12-1/alf_full/tree/main/Alance-finance-user-backend-main/src/bond): `Alance-finance-user-backend-main/src/bond`
- [Token swaps](https://github.com/mohansai12-1/alf_full/tree/main/Alance-finance-user-backend-main/src/swap): `Alance-finance-user-backend-main/src/swap`
- [DAO services](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/dao/service.ts): `Alance-finance-user-backend-main/src/dao/service.ts`
- [Referral network](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/referral/service.ts): `Alance-finance-user-backend-main/src/referral/service.ts`
- [Transaction ledger](https://github.com/mohansai12-1/alf_full/tree/main/Alance-finance-user-backend-main/src/ledger): `Alance-finance-user-backend-main/src/ledger`
- [DAO revenue](https://github.com/mohansai12-1/alf_full/tree/main/Alance-finance-user-backend-main/src/daoRevenue): `Alance-finance-user-backend-main/src/daoRevenue`

### Rewards and settlement

- [Reward calculation](https://github.com/mohansai12-1/alf_full/tree/main/Alance-finance-user-backend-main/src/rewards): `Alance-finance-user-backend-main/src/rewards`
- [Team rewards](https://github.com/mohansai12-1/alf_full/tree/main/Alance-finance-user-backend-main/src/rewards/team): `Alance-finance-user-backend-main/src/rewards/team`
- [Claims and proofs](https://github.com/mohansai12-1/alf_full/tree/main/Alance-finance-user-backend-main/src/settlement): `Alance-finance-user-backend-main/src/settlement`
- [Reward worker](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/rewards/worker.ts): `Alance-finance-user-backend-main/src/rewards/worker.ts`

### Backend runtime

- [Backend API](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/index.ts): `Alance-finance-user-backend-main/src/index.ts`
- [Chain access](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/lib/chain.ts): `Alance-finance-user-backend-main/src/lib/chain.ts`
- [MongoDB](https://github.com/mohansai12-1/alf_full/blob/main/Alance-finance-user-backend-main/src/db.ts): `Alance-finance-user-backend-main/src/db.ts`

### Other components

- **Visitor**
- **Polygon network**

## Connections

- Visitor → Alance site: browses (evidence: `Alance-finance-user-frontend-main/src/App.tsx`)
- Alance site → Ecosystem content: renders (evidence: `Alance-finance-user-frontend-main/src/App.tsx`)
- Alance site → Governance content: renders (evidence: `Alance-finance-user-frontend-main/src/App.tsx`)
- Alance site → Token content: renders (evidence: `Alance-finance-user-frontend-main/src/App.tsx`)
- Alance site → Transparency content: renders (evidence: `Alance-finance-user-frontend-main/src/App.tsx`)
- Backend API → Wallet authentication: routes auth (evidence: `Alance-finance-user-backend-main/src/index.ts`)
- Backend API → Wallet onboarding: routes wallet (evidence: `Alance-finance-user-backend-main/src/index.ts`)
- Backend API → Staking: routes staking (evidence: `Alance-finance-user-backend-main/src/index.ts`)
- Backend API → Bond purchases: routes bonds (evidence: `Alance-finance-user-backend-main/src/index.ts`)
- Backend API → Token swaps: routes swaps (evidence: `Alance-finance-user-backend-main/src/index.ts`)
- Backend API → DAO services: routes DAO (evidence: `Alance-finance-user-backend-main/src/index.ts`)
- Backend API → Referral network: routes referrals (evidence: `Alance-finance-user-backend-main/src/index.ts`)
- Backend API → Transaction ledger: routes ledger (evidence: `Alance-finance-user-backend-main/src/index.ts`)
- Backend API → DAO revenue: routes revenue (evidence: `Alance-finance-user-backend-main/src/index.ts`)
- Backend API → Claims and proofs: routes claims (evidence: `Alance-finance-user-backend-main/src/index.ts`)
- Backend API → Reward worker: starts worker (evidence: `Alance-finance-user-backend-main/src/rewards/worker.ts`)
- Wallet authentication → User records: creates users (evidence: `Alance-finance-user-backend-main/src/auth/service.ts`)
- Session guard → Wallet authentication: verifies sessions (evidence: `Alance-finance-user-backend-main/src/auth/middleware.ts`)
- Chain access → Polygon network: reads chain (evidence: `Alance-finance-user-backend-main/src/lib/chain.ts`)
- Wallet onboarding → Chain access: resolves creation (evidence: `Alance-finance-user-backend-main/src/lib/chain.ts`)
- Staking → Chain access: reads receipts (evidence: `Alance-finance-user-backend-main/src/staking/service.ts`)
- Staking → User records: loads users (evidence: `Alance-finance-user-backend-main/src/staking/service.ts`)
- Staking → Reward calculation: loads stake rewards (evidence: `Alance-finance-user-backend-main/src/staking/service.ts`)
- Referral network → User records: reads referrals (evidence: `Alance-finance-user-backend-main/src/referral/service.ts`)
- Claims and proofs → Team rewards: reads team rewards (evidence: `Alance-finance-user-backend-main/src/settlement/routes.ts`)
- Reward worker → Reward calculation: runs calculations (evidence: `Alance-finance-user-backend-main/src/rewards/worker.ts`)
- Reward worker → Team rewards: runs epochs (evidence: `Alance-finance-user-backend-main/src/rewards/worker.ts`)
- Reward worker → Claims and proofs: reconciles claims (evidence: `Alance-finance-user-backend-main/src/rewards/worker.ts`)
