Skip to content

05 — Master Admin & Website CMS Manual ​

This manual covers executive governance in CRM Master Admin (https://crm.thebridgefinance.lk/crm/admin) and public editorial management in Website CMS (https://thebridgefinance.lk/admin). These two systems use separate URLs, separate authentication mechanisms, and separate D1 databases.


Part A: CRM Master Admin Cockpit (/crm/admin) ​

Accessible exclusively to users with role master_admin (enforced by CrmRoleRoute and Worker middleware requireRole(["master_admin"])).

1. Master Admin Sidebar Items ​

GroupItemPath / HashAuthority Scope
MAIN MENUKPI Summary/crm/adminMaster Admin only
MAIN MENULeads/crm/admin#leadsShared Staff Desk
MAIN MENUBorrowers/crm/admin#borrowersShared Staff Desk
MAIN MENUInvestors/crm/admin#investorsShared Staff Desk
OPERATIONSBookings/crm/admin#bookingsShared Staff Desk
OPERATIONSDocuments/crm/admin#documentsShared Staff Desk
OPERATIONSLive Chat/crm/admin#chatShared Staff Desk
OPERATIONSAccess Analytics/crm/admin#analyticsMaster Admin only
ACCOUNTStaff Management/crm/admin#staffMaster Admin only
ACCOUNTLoan Policies & Limits/crm/admin#policiesMaster Admin only
ACCOUNTProfile/crm/admin#profileShared Staff Profile

(The Security & Audit Trail view is also supported at /crm/admin#audit for CSV audit log export and outcome filtering.)

2. Executive KPI Summary (/crm/admin) ​

  • Metrics Displayed: Total Portfolio Value, Active Borrowers, Active Investors, Monthly Disbursements, Collection / Recovery metrics, and Average Yield.
  • Horizon Switcher: Toggle live aggregation by Weekly, Monthly, or Yearly (GET /api/crm/admin/kpis).

Master Admin Executive KPI Summary

3. Staff & User Management (/crm/admin#staff) ​

  • Summary Strip: Live counts for Active Officers, Super Admins, Total Authorized Staff, and Active.
  • Full CRUD Lifecycle:
    • Create: Click Add User (add-crm-user-btn), specify Full Name, Email, Phone, Role (staff or master_admin), and Department. Creating a user dispatches a welcome email with the https://crm.thebridgefinance.lk/crm/login link via Resend.
    • Read / Filter: Search by name, email, or role; filter dropdown for All Staff & Officers, Staff Officer, or Super Admin.
    • Update: Edit name, department, role, or account status (active / suspended).
    • Delete: Permanently remove an authorized account (also recorded in crm_deleted_users so deleted users do not resurrect).
  • Master Admin Governance & Anti-Lockout Protections:
    • Environment Root Allowlist (MASTER_ADMIN_EMAILS): Emails configured in Cloudflare MASTER_ADMIN_EMAILS are automatically recognized as master_admin during OTP login even if a D1 seed record was missing.
    • Self-Protection: A signed-in master_admin cannot demote, suspend, or delete their own account.
    • Last-Admin Guard: The backend (src/worker/index.ts) blocks any request that would demote, suspend, or delete the last active master_admin across D1 + MASTER_ADMIN_EMAILS (HTTP 400).

Master Admin Staff and Officer Management Directory

4. Loan Policies & Limits (/crm/admin#policies) ​

Configure underwriting parameters (GET/PUT /api/crm/admin/policies):

  • Maximum Loan Facility Limit (LKR): Slider from LKR 500,000 to LKR 2,000,000 (step 100,000, aligned with public sitemap ceiling).
  • Floor APR (%) & Ceiling APR (%): Numeric bounds with a live visual Active APR Band (0% – 30%) bar.
  • Automated Screening Score Threshold: Numeric score split gauge (Manual Desk Audit < threshold vs Expedited Approval >= threshold).
  • PDPA Audit Mode: Sri Lanka Personal Data Protection Act (PDPA No. 9 of 2022) cryptographic hashing and document interaction audit logging (Enforced).
  • Click Save Policy Configuration to persist to D1 (crm_loan_policies).

Master Admin Loan Policies and Limits

5. Security & Audit Trail (/crm/admin#audit) ​

  • Filter audit logs by outcome (All, Success, Flagged) and search by actor, action, or IP/TLS hash (GET /api/crm/admin/audit-logs).
  • Click the export button to compile and download an audit CSV report.

6. Access Analytics Dashboard (/crm/admin#analytics) ​

Enterprise telemetry, marketing attribution, threat monitoring, and UI/UX diagnostics cockpit across both the Public Marketing Website (thebridgefinance.lk) and CRM Portal (crm.thebridgefinance.lk).

  • Super Admin RBAC & PDPA Privacy:
    • Visible and accessible exclusively to master_admin (enforced across CrmSidebar, CrmRoleRoute, defense-in-depth guards in AccessAnalyticsDashboard, and Worker middleware requireRole(["master_admin"]) on every /api/crm/admin/analytics/* route; unauthenticated calls return HTTP 401 and non-admin roles receive HTTP 403).
    • Raw IP addresses (CF-Connecting-IP) are never stored: they are irreversibly hashed via SHA-256 (ip_hash, 16 hex chars) and masked (ip_masked, e.g. 112.134.x.x), while emails, tokens, OTP codes, passwords, and NIC numbers are scrubbed before storage.
  • Cross-Surface Client SDK & Server Security Telemetry:
    • AnalyticsTracker automatically captures route views, UTM campaigns, dwell time, Core Web Vitals (LCP, INP, CLS, FCP, TTFB), scroll-depth milestones (25%–100%), rage clicks, JS runtime errors, and CTA/download clicks across both web (anonymous) and crm (role-attributed without PII) via POST /api/analytics/collect, preserving apps/web bundle isolation.
    • Server-side middleware on /api/* logs auth_success, auth_failure, auth_denied (401/403), rate_limit (429), and api_error (5xx) latency/status telemetry.
  • Global Command Bar:
    • Filter across Time Range (24h, 7d, 30d, 90d), Surface (All, Public Web, CRM Portal), and Role (All, Anonymous, Borrower, Investor, Staff, Super Admin), trigger Refresh, Export CSV / Export JSON, and verify active SHA-256 IP Anonymized status.
  • Five Operational Sub-Tabs:
    • Overview: Displays 6 executive KPI cards with period deltas, interactive dual-series Web vs CRM traffic SVG chart, Surface & User Role breakdown donut/bars, active triggered Watch Rule alert banners, and prioritized Marketing / Security / UX recommendations.

Super Admin Access Analytics Overview

  • Marketing: 5-stage acquisition-to-approval conversion funnel correlated with live D1 records (applications, investor_applications, consultations, inquiries, crm_users, cms_downloads), traffic channels, UTM campaigns, top landing pages, top CTAs, EN/SI/TA language distribution, geo regions, and Download Center metrics.

Super Admin Access Analytics Marketing Intelligence

  • Security: Displays the aggregate Security Posture Score, failed OTP attempts, 401/403 RBAC denials, 5xx errors, suspicious masked-IP alerts, authentication timeline, and Watch Rules Manager (Full 4-Operation CRUD) — defaults to Cards View with a Cards | Table toggle, Create/Edit rule modal, Enable/Disable toggle, Delete confirmation dialog, permanent deletion without resurrection, and real-time threshold evaluation.

Super Admin Access Analytics Security and Watch Rules

  • UI/UX Lab: Core Web Vitals P75 scorecard (LCP, INP, CLS, FCP, TTFB) with Good/Needs Improvement/Poor stacked distribution bars, rage-click hotspots, JS runtime errors, slowest routes, device/browser/viewport breakdown, scroll-depth meters, and an accessible 7×24 hourly usage heatmap.

Super Admin Access Analytics UI UX and Web Vitals Lab

  • Live Logs: Real-time searchable/filterable access event stream (GET /api/crm/admin/analytics/events), defaulting to Cards View with a Cards | Table toggle and horizontally scrollable .crm-table-scroll tables, plus individual event deletion and > 90 days retention purge (POST /api/crm/admin/analytics/purge) with confirmation.

Super Admin Access Analytics Live Logs Explorer

  • Optional Hybrid Marketing Note: If paid Google Ads attribution or Google Search Console keyword reporting is later required, standard GA4 tags may be added strictly to thebridgefinance.lk while keeping this built-in Access Analytics dashboard as the authoritative console for CRM funnels, security threats, and UI/UX telemetry.

Part B: Website CMS (/admin) ​

Accessible at https://thebridgefinance.lk/admin (or /en/admin). Stored in the-bridge-cms-db (D1) and the-bridge-cms (R2).

1. CMS Authentication (/admin/login) ​

  • Unauthenticated requests redirect immediately to /admin/login.
  • First-time authorized users check their email status (POST /api/admin/cms/auth/status), set a password (POST /api/admin/cms/auth/setup-password), and sign in with email + password (POST /api/admin/cms/auth/login) returning an authToken (bridge_cms_token).

2. CMS Roles ​

RoleLabelCapabilities
main_adminMain AdminFull access to Overview, Announcements, Blog & Articles, Download Center, and Team & Access (/admin/users)
writerWriterCreate, edit, and publish Announcements, Blog & Articles, and Download Center; /admin/users is hidden and blocked with HTTP 403

3. CMS Modules & Workflows ​

  • Overview (/admin): Shows counts for published/draft Announcements (plus pinned count), Blog Articles, and active/hidden Download Center resources, with quick-create buttons.

Website CMS Overview Dashboard

  • Announcements (/admin/announcements): Manage press bulletins (Announcements list, /new, and /:id). Supports published / draft status and pinned banner flag for the public homepage.
  • Blog & Articles (/admin/blog):
    • Rich WYSIWYG editor powered by TipTap (headings, tables, highlights, text alignment, inline images).
    • Supports cover image upload to Cloudflare R2 (POST /api/admin/cms/upload → /api/files/:assetId), comma-separated tags, computed read time, custom slug handling (cleanly deletes old slug when renamed without leaving duplicate articles), and a live Google SERP Preview Card (thebridgefinance.lk › en › articles › <slug>).

Website CMS Blog and Articles List

  • Download Center (/admin/downloads): Upload official forms, guides, and fee schedules to R2 (active or hidden visibility) and track download counts.

Website CMS Download Center Manager

  • Team & Access (/admin/users, Main Admin Only): Add (POST /api/admin/cms/users), update, or delete CMS writers and admins (ConfirmDialog guards deletions).
  • QA Feedback Manager (/admin/feedback): Unlisted maintenance route for reviewing and resolving submitted feedback pins (/api/feedback).

The Bridge International Enterprises (Pvt) Ltd.