Skip to content

Investments System #20

Description

@VisibleNasir

📘 Overview

Allow users to invest in mutual funds (₹100+), digital gold (₹1+), and insurance premium payments.
This adds a high-margin revenue stream and attracts wealth-building users.


💡 Why Add It

  • Revenue Potential: Paytm sees 30% of users invest monthly, earning 0.5–2% affiliate commission.
  • Retention: Wealth features increase stickiness (40%+ user return rate).
  • Market Fit: India’s investment market is growing (₹10K/month avg per user).

⚙️ Implementation

🧑‍💻 Userapp (Next.js)

  • Page: /app/invest/page.tsx → Investment options dashboard.

  • UI Components:

    • Tabs for Mutual Funds, Digital Gold, Insurance.
    • Input fields for investment amount.
    • Dropdowns for fund/gold/insurance selection.
    • Confirm button → Razorpay payment.
    • Styling consistent with repo (bg-zinc-800, text-zinc-100, border-zinc-700).
  • API Routes:

    • GET /app/api/invest/funds → Fetch mutual fund options (via Groww/Zerodha/Kuvera API).
    • GET /app/api/invest/gold → Fetch gold prices (e.g., Augmont API).
    • GET /app/api/invest/insurance → Fetch insurance plans (Policybazaar or direct APIs).
    • POST /app/api/invest/purchase → Initiate investment via Razorpay.
  • State Management:

    • useState → Selected investment type and amount.
    • TanStack Query → Fetch options & track status.
  • Error Handling:

    • Show inline errors for invalid inputs (e.g., “Minimum ₹100”) → border-red-500, bg-zinc-700.
    • Disable buttons during API calls (disabled:bg-zinc-600/50).

🌐 Webhook (Express)

  • Endpoint: /webhook/investment

  • Logic Flow:

    1. Receive Razorpay payment confirmation (payment.succeeded) or external provider confirmation.
    2. Update Investment table (SUCCESS, FAILED).
    3. Trigger notification via FCM/email → “₹500 invested in SBI Bluechip”.
  • Security:

    • Validate webhook signatures (Razorpay/Groww/Augmont).
    • Log failed attempts for fraud monitoring.

🗄️ Database (Prisma)

Add to schema.prisma:

model Investment {
  id        Int      @id @default(autoincrement())
  userId    Int
  type      String   // MUTUAL_FUND, GOLD, INSURANCE
  amount    Int      // in paise
  assetId   String   // fund ISIN, gold grams, insurance policy ID
  status    String   // PENDING, SUCCESS, FAILED
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions