# masud5957/cryptofd-new architecture

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

- Interactive diagram: https://gitdiagram.com/masud5957/cryptofd-new
- Repository: https://github.com/masud5957/cryptofd-new

## Overview

cryptoFD is a crypto fixed-deposit investment platform with user dashboards, wallet and withdrawal flows, referrals, and an administrative portal. The principal user workflow is authentication, viewing account activity, and managing fixed deposits or wallet requests; background-worker code indicates separate earnings and transaction-processing responsibilities. The source index and excerpts support the web, authentication, data, and admin relationships shown. Worker internals and several unsampled features are represented at subsystem level; their unverified connections are omitted.

Main entry points: [`app/api/wallet/route.ts`](https://github.com/masud5957/cryptofd-new/blob/main/app/api/wallet/route.ts) (Wallet and withdrawals), [`backend-worker/src/index.ts`](https://github.com/masud5957/cryptofd-new/blob/main/backend-worker/src/index.ts) (Worker runtime), [`app/dashboard/page.tsx`](https://github.com/masud5957/cryptofd-new/blob/main/app/dashboard/page.tsx) (Account dashboard), [`app/api/auth`](https://github.com/masud5957/cryptofd-new/tree/main/app/api/auth) (Authentication routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_user["User experience"]
  node_authpages["Sign-in and signup"]
  node_dashboard["Account dashboard<br/>[page.tsx]"]
  node_fd["Fixed deposits"]
  node_walletui["Wallet interface<br/>[page.tsx]"]
  node_referrals["Referral program"]
end

subgraph group_core["Application services"]
  node_authapi["Authentication routes"]
  node_authsvc["Identity and sessions<br/>[auth.ts]"]
  node_walletapi["Wallet and withdrawals<br/>[route.ts]"]
  node_queries["User data queries<br/>[queries.ts]"]
  node_database[("Application database<br/>[db.ts]")]
  node_email["Email notifications<br/>[email.ts]"]
end

subgraph group_admin["Administration"]
  node_adminlogin["Admin sign-in<br/>[page.tsx]"]
  node_adminportal["Admin portal"]
  node_adminauth["Admin authentication<br/>[admin-auth.ts]"]
  node_adminqueries["Admin reporting<br/>[admin-queries.ts]"]
  node_adminactions["Admin operations<br/>[admin-actions.ts]"]
  node_adminroutes["Admin API routes"]
end

subgraph group_worker["Background processing"]
  node_worker["Worker runtime<br/>[index.ts]"]
  node_earnings["FD earnings processor"]
  node_scanner["Transaction scanner<br/>[scanner.ts]"]
  node_sweeps["Wallet sweep services<br/>[sweepService.ts]"]
  node_withdrawals["Withdrawal executor"]
  node_workerdb[("Worker database access<br/>[db.ts]")]
end

node_visitor(("User"))
node_chain{{"Crypto network"}}

node_visitor -->|"signs up"| node_authpages
node_authpages -.->|"submits credentials"| node_authapi
node_authapi -->|"uses identity"| node_authsvc
node_authapi -->|"reads and writes"| node_database
node_authapi -->|"sends email"| node_email
node_authsvc -->|"loads user"| node_database
node_visitor -->|"opens account"| node_dashboard
node_dashboard -->|"checks session"| node_authsvc
node_dashboard -->|"loads account data"| node_queries
node_dashboard -.->|"opens deposit features"| node_fd
node_visitor -.->|"manages funds"| node_walletui
node_walletui -.->|"requests wallet actions"| node_walletapi
node_walletapi -->|"checks user"| node_authsvc
node_walletapi -->|"reads and updates"| node_database
node_walletapi -->|"notifies withdrawal"| node_email
node_walletapi -.->|"derives deposit address"| node_chain
node_visitor -->|"views referral program"| node_referrals
node_referrals -->|"links to signup"| node_authpages
node_visitor -->|"signs in as admin"| node_adminlogin
node_adminlogin -->|"authenticates"| node_adminauth
node_adminlogin -->|"opens portal"| node_adminportal
node_adminportal -->|"loads analytics"| node_adminqueries
node_adminportal -->|"invokes controls"| node_adminactions
node_adminroutes -->|"checks admin access"| node_adminauth
node_adminroutes -->|"reads and writes"| node_database
node_worker -.->|"dispatches processing"| node_earnings
node_worker -.->|"dispatches scanning"| node_scanner
node_worker -.->|"dispatches sweeps"| node_sweeps
node_worker -.->|"dispatches withdrawals"| node_withdrawals
node_earnings -.->|"uses persistence"| node_workerdb
node_scanner -.->|"uses persistence"| node_workerdb
node_sweeps -.->|"moves crypto"| node_chain
node_withdrawals -.->|"executes transfers"| node_chain

click node_authpages "https://github.com/masud5957/cryptofd-new/tree/main/app/auth"
click node_dashboard "https://github.com/masud5957/cryptofd-new/blob/main/app/dashboard/page.tsx"
click node_fd "https://github.com/masud5957/cryptofd-new/tree/main/app/dashboard"
click node_walletui "https://github.com/masud5957/cryptofd-new/blob/main/app/dashboard/wallet/page.tsx"
click node_referrals "https://github.com/masud5957/cryptofd-new/blob/main/app/dashboard/referral/referral-client.tsx"
click node_authapi "https://github.com/masud5957/cryptofd-new/tree/main/app/api/auth"
click node_authsvc "https://github.com/masud5957/cryptofd-new/blob/main/lib/auth.ts"
click node_walletapi "https://github.com/masud5957/cryptofd-new/blob/main/app/api/wallet/route.ts"
click node_queries "https://github.com/masud5957/cryptofd-new/blob/main/lib/queries.ts"
click node_database "https://github.com/masud5957/cryptofd-new/blob/main/lib/db.ts"
click node_email "https://github.com/masud5957/cryptofd-new/blob/main/lib/email.ts"
click node_adminlogin "https://github.com/masud5957/cryptofd-new/blob/main/app/admin-login/page.tsx"
click node_adminportal "https://github.com/masud5957/cryptofd-new/tree/main/app/admin"
click node_adminauth "https://github.com/masud5957/cryptofd-new/blob/main/lib/admin-auth.ts"
click node_adminqueries "https://github.com/masud5957/cryptofd-new/blob/main/lib/admin-queries.ts"
click node_adminactions "https://github.com/masud5957/cryptofd-new/blob/main/lib/admin-actions.ts"
click node_adminroutes "https://github.com/masud5957/cryptofd-new/tree/main/app/api/admin"
click node_worker "https://github.com/masud5957/cryptofd-new/blob/main/backend-worker/src/index.ts"
click node_earnings "https://github.com/masud5957/cryptofd-new/blob/main/backend-worker/src/fdEarningsProcessor.ts"
click node_scanner "https://github.com/masud5957/cryptofd-new/blob/main/backend-worker/src/scanner.ts"
click node_sweeps "https://github.com/masud5957/cryptofd-new/blob/main/backend-worker/src/sweepService.ts"
click node_withdrawals "https://github.com/masud5957/cryptofd-new/blob/main/backend-worker/src/withdrawalExecutor.ts"
click node_workerdb "https://github.com/masud5957/cryptofd-new/blob/main/backend-worker/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_authpages,node_dashboard,node_fd,node_walletui,node_referrals,node_visitor toneBlue
class node_authapi,node_authsvc,node_walletapi,node_queries,node_database,node_email toneAmber
class node_adminlogin,node_adminportal,node_adminauth,node_adminqueries,node_adminactions,node_adminroutes toneMint
class node_worker,node_earnings,node_scanner,node_sweeps,node_withdrawals,node_workerdb toneRose
class node_chain toneIndigo
```

## Components

### User experience

- [Sign-in and signup](https://github.com/masud5957/cryptofd-new/tree/main/app/auth): `app/auth`
- [Account dashboard](https://github.com/masud5957/cryptofd-new/blob/main/app/dashboard/page.tsx): `app/dashboard/page.tsx`
- [Fixed deposits](https://github.com/masud5957/cryptofd-new/tree/main/app/dashboard): `app/dashboard`
- [Wallet interface](https://github.com/masud5957/cryptofd-new/blob/main/app/dashboard/wallet/page.tsx): `app/dashboard/wallet/page.tsx`
- [Referral program](https://github.com/masud5957/cryptofd-new/blob/main/app/dashboard/referral/referral-client.tsx): `app/dashboard/referral/referral-client.tsx`

### Application services

- [Authentication routes](https://github.com/masud5957/cryptofd-new/tree/main/app/api/auth): `app/api/auth`
- [Identity and sessions](https://github.com/masud5957/cryptofd-new/blob/main/lib/auth.ts): `lib/auth.ts`
- [Wallet and withdrawals](https://github.com/masud5957/cryptofd-new/blob/main/app/api/wallet/route.ts): `app/api/wallet/route.ts`
- [User data queries](https://github.com/masud5957/cryptofd-new/blob/main/lib/queries.ts): `lib/queries.ts`
- [Application database](https://github.com/masud5957/cryptofd-new/blob/main/lib/db.ts): `lib/db.ts`
- [Email notifications](https://github.com/masud5957/cryptofd-new/blob/main/lib/email.ts): `lib/email.ts`

### Administration

- [Admin sign-in](https://github.com/masud5957/cryptofd-new/blob/main/app/admin-login/page.tsx): `app/admin-login/page.tsx`
- [Admin portal](https://github.com/masud5957/cryptofd-new/tree/main/app/admin): `app/admin`
- [Admin authentication](https://github.com/masud5957/cryptofd-new/blob/main/lib/admin-auth.ts): `lib/admin-auth.ts`
- [Admin reporting](https://github.com/masud5957/cryptofd-new/blob/main/lib/admin-queries.ts): `lib/admin-queries.ts`
- [Admin operations](https://github.com/masud5957/cryptofd-new/blob/main/lib/admin-actions.ts): `lib/admin-actions.ts`
- [Admin API routes](https://github.com/masud5957/cryptofd-new/tree/main/app/api/admin): `app/api/admin`

### Background processing

- [Worker runtime](https://github.com/masud5957/cryptofd-new/blob/main/backend-worker/src/index.ts): `backend-worker/src/index.ts`
- [FD earnings processor](https://github.com/masud5957/cryptofd-new/blob/main/backend-worker/src/fdEarningsProcessor.ts): `backend-worker/src/fdEarningsProcessor.ts`
- [Transaction scanner](https://github.com/masud5957/cryptofd-new/blob/main/backend-worker/src/scanner.ts): `backend-worker/src/scanner.ts`
- [Wallet sweep services](https://github.com/masud5957/cryptofd-new/blob/main/backend-worker/src/sweepService.ts): `backend-worker/src/sweepService.ts`
- [Withdrawal executor](https://github.com/masud5957/cryptofd-new/blob/main/backend-worker/src/withdrawalExecutor.ts): `backend-worker/src/withdrawalExecutor.ts`
- [Worker database access](https://github.com/masud5957/cryptofd-new/blob/main/backend-worker/src/db.ts): `backend-worker/src/db.ts`

### Other components

- **User**
- **Crypto network**

## Connections

- User → Sign-in and signup: signs up (evidence: `app/auth/sign-up/page.tsx`)
- Sign-in and signup → Authentication routes: submits credentials
- Authentication routes → Identity and sessions: uses identity (evidence: `app/api/auth/login/route.ts`)
- Authentication routes → Application database: reads and writes (evidence: `app/api/auth/register/route.ts`)
- Authentication routes → Email notifications: sends email (evidence: `app/api/auth/register/route.ts`)
- Identity and sessions → Application database: loads user (evidence: `lib/auth.ts`)
- User → Account dashboard: opens account (evidence: `app/dashboard/page.tsx`)
- Account dashboard → Identity and sessions: checks session (evidence: `app/dashboard/page.tsx`)
- Account dashboard → User data queries: loads account data (evidence: `app/dashboard/page.tsx`)
- Account dashboard → Fixed deposits: opens deposit features
- User → Wallet interface: manages funds
- Wallet interface → Wallet and withdrawals: requests wallet actions
- Wallet and withdrawals → Identity and sessions: checks user (evidence: `app/api/wallet/route.ts`)
- Wallet and withdrawals → Application database: reads and updates (evidence: `app/api/wallet/route.ts`)
- Wallet and withdrawals → Email notifications: notifies withdrawal (evidence: `app/api/wallet/route.ts`)
- Wallet and withdrawals → Crypto network: derives deposit address
- User → Referral program: views referral program (evidence: `app/dashboard/referral/referral-client.tsx`)
- Referral program → Sign-in and signup: links to signup (evidence: `app/dashboard/referral/referral-client.tsx`)
- User → Admin sign-in: signs in as admin (evidence: `app/admin-login/page.tsx`)
- Admin sign-in → Admin authentication: authenticates (evidence: `app/admin-login/page.tsx`)
- Admin sign-in → Admin portal: opens portal (evidence: `app/admin-login/page.tsx`)
- Admin portal → Admin reporting: loads analytics (evidence: `app/admin/analytics/page.tsx`)
- Admin portal → Admin operations: invokes controls (evidence: `app/admin/analytics/withdrawal-toggle.tsx`)
- Admin API routes → Admin authentication: checks admin access (evidence: `app/api/admin/trading-stats/route.ts`)
- Admin API routes → Application database: reads and writes (evidence: `app/api/admin/trading-stats/route.ts`)
- Worker runtime → FD earnings processor: dispatches processing
- Worker runtime → Transaction scanner: dispatches scanning
- Worker runtime → Wallet sweep services: dispatches sweeps
- Worker runtime → Withdrawal executor: dispatches withdrawals
- FD earnings processor → Worker database access: uses persistence
- Transaction scanner → Worker database access: uses persistence
- Wallet sweep services → Crypto network: moves crypto
- Withdrawal executor → Crypto network: executes transfers
