Skip to content

[Feature] Build a protocol-wide analytics dashboard showing TVL, active pools, member growth, and transaction volume #204

Description

@Sendi0011

Getting Started

  1. Fork the repository: https://github.com/JointSave-org/Joint_Save
  2. Clone your fork:
git clone https://github.com/<your-username>/Joint_Save.git
cd Joint_Save
  1. Create a new branch:
git checkout -b feat/protocol-analytics-dashboard

Overview

JointSave has no public-facing analytics page that shows overall protocol health. Users and potential integrators have no way to see how much total value is locked across all pools, how many active pools exist, member growth trends, or transaction volume over time. The factory contract tracks deployed pools via get_all_pools() but this data is never surfaced at the protocol level.

Checked frontend/app/explore/page.tsx — shows individual pool cards but no aggregate stats. The Supabase pools table has created_at and total_saved columns that could power aggregate queries, but no API route aggregates them.

This issue adds a public analytics dashboard accessible from the landing page and navbar, displaying key protocol metrics with historical charts powered by Chart.js or Recharts.

Requirements

API Changes

  • New route: GET /api/analytics/protocol
    • Returns cached (5-minute TTL) aggregate metrics:
      • total_value_locked: sum of total_saved across all pools
      • active_pools: count of pools where status is not 'completed'
      • total_pools_created: count of all pools
      • total_members: distinct count of wallet addresses across all pool_members records
      • total_transactions: count of rows in pool_activity
      • pools_by_type: { rotational: N, target: N, flexible: N }
      • tvl_by_type: { rotational: X, target: X, flexible: X }
    • Historical data: daily_stats array for the last 30 days with date, tvl, new_pools, new_members, transaction_count
    • Computed from Supabase queries against pools, pool_members, and pool_activity tables
    • Rate limited with the existing readLimiter

Frontend Changes

  • New page: frontend/app/analytics/page.tsx
    • Public page (no wallet connection required)
    • Hero section with 4 large metric cards: TVL, Active Pools, Total Members, Total Transactions
    • TVL trend line chart (30-day history) using Recharts
    • Pool type distribution donut chart (Rotational / Target / Flexible)
    • Daily new pools bar chart (30-day)
    • Member growth area chart (30-day)
    • All charts use a responsive grid layout (2 columns on desktop, 1 on mobile)
    • Skeleton loading states while data fetches
  • New component: frontend/components/analytics/protocol-charts.tsx
    • Encapsulates all Recharts components
    • Shared color palette: Rotational=#3b82f6 (blue), Target=#8b5cf6 (purple), Flexible=#10b981 (emerald)
    • Tooltips on hover showing exact values
    • Responsive: charts resize and stack vertically below 768px
  • New component: frontend/components/analytics/metric-card.tsx
    • Displays a single metric with icon, label, value, and optional trend indicator (+12% this week)
    • Animated counter on page load (counts up from 0 to final value)
  • Navigation:
    • Add "Analytics" link to the landing page navbar and the dashboard sidebar
    • Add /analytics to the public routes in the layout

Dependencies

recharts@^2.12.0

Data Pipeline

  • For historical data, create a Supabase Edge Function or Vercel Cron (/api/cron/snapshot-daily) that runs daily at midnight UTC and inserts a row into a new protocol_daily_snapshots table:
    • date (date, PK)
    • tvl (numeric)
    • active_pools (integer)
    • total_members (integer)
    • transaction_count (integer)
    • new_pools (integer)
    • new_members (integer)
  • The analytics API reads from this snapshots table for historical charts, and computes live values for the current-day metrics

Acceptance Criteria

  • /api/analytics/protocol returns all specified metrics with correct values
  • Historical daily snapshots are created by the cron job
  • Analytics page renders all 4 metric cards with correct values
  • TVL trend chart shows 30-day history with correct data points
  • Pool type distribution donut chart renders correctly
  • Charts are responsive and stack on mobile
  • Page loads with skeleton states before data arrives
  • Animated counters count up smoothly on initial load
  • Analytics link appears in navbar and dashboard sidebar
  • API route is rate limited and returns within 3 seconds

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignfeatureNew functionality to addhigh-complexityLarge scope, multiple systems/files. Needs planning

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions