How It Works

Account Creation (rate-limited, 5/min/IP)
   -> D1 (accounts / transactions / subscriptions / branches / employees)
   -> Credit / Debit APIs (validated, atomic balance updates)
   -> Hourly Cron -> dummy companies auto-charge subscribed accounts
      (skips a cycle rather than overdrawing)
   -> Full transaction ledger per account
				

API Endpoints

Endpoint Purpose
GET /bank/branches List all branches with IFSC, address, manager and employees
GET /bank/leadership List the CEO and CFO
GET /bank/leaderboard Public leaderboard of every account plus bank-wide totals (economy, transaction count, account count)
POST /api/auth/sign-up/email Create an account (Better Auth): name, email, password, optional image
POST /api/auth/sign-in/email Sign in with email and password
GET /api/auth/get-session Get the current signed-in user, if any
POST /bank/account Open a new account at a branch (requires sign-in; rate-limited to 2/hour/IP)
GET /bank/account/:id Get account details and current balance
POST /bank/account/:id/credit Credit an amount into the account (owner only)
POST /bank/account/:id/debit Debit an amount from the account (owner only; rejected if insufficient balance)
POST /bank/account/:id/subscribe Register a dummy company that auto-charges this account every hour (owner only)
POST /bank/account/:id/transfer Send money via NEFT / IMPS / UPI / wire (owner only; internal APNA destinations are credited instantly)
POST /bank/account/:id/tick Add one random transaction (owner only, rate-limited to 6/minute/account) - powers the "Live Ticking" dashboard button
GET /bank/account/:id/transactions List the account's transaction ledger

Note: Every account, branch, IFSC and transaction here is entirely dummy data. Bank of Apna Nagar is not a real bank and holds no real money.

Links