Competitive intelligence dashboard for fintech promotions tracking — built with Next.js 15, TypeScript, and Tailwind CSS.
| View | Description |
|---|---|
| Monitor | Shows the live pricing comparison table per market/competitor, with active promo alerts and KPI cards. Data comes from a published Google Sheet (CSV). |
| Insights | AI-powered analysis of the raw promo feed. Shows period KPIs, bar charts per product/competitor, and 4 Anthropic-generated strategic bullets. |
/app
page.tsx ← Client-side dashboard (Monitor + Insights views)
layout.tsx ← Root layout + metadata
globals.css ← CSS custom properties (design tokens) + base styles
/api
/monitor-data/route.ts ← Server: proxies + parses Monitor Google Sheet CSV
/promo-raw/route.ts ← Server: proxies + parses Promo Raw Google Sheet CSV
/insights/route.ts ← Server: calls Anthropic API for AI analysis
/components
DashboardHeader.tsx ← Sticky top bar with refresh button
Sidebar.tsx ← Left nav (markets + insights link)
StatsCards.tsx ← 4-column KPI strip
PromoAlerts.tsx ← Active promo alert cards
MarketTable.tsx ← Per-market competitor pricing table
InsightsView.tsx ← Full Insights panel (AI cards + charts + raw table)
BarChart.tsx ← Horizontal bar chart
Toast.tsx ← Toast notification system
/lib
types.ts ← All TypeScript interfaces
csv.ts ← RFC 4180 CSV parser
format.ts ← Date parsing, flag emoji, status/delta helpers
constants.ts ← Google Sheet URLs, keyword lists
cd promo-pricing-monitor
npm install
cp .env.example .env.local
Edit .env.local:
# Required for AI analysis (Insights view)
ANTHROPIC_API_KEY=sk-ant-...
# Optional: override the Google Sheets URLs
# MONITOR_SHEET_URL=https://...
# PROMO_RAW_SHEET_URL=https://...
Note: If
ANTHROPIC_API_KEYis not set, the app still works — the Monitor view is fully functional, and the Insights view will show data/charts but display an error message where the AI cards should appear.
npm run dev
Open http://localhost:3000.
npm i -g vercel
vercel
Follow the prompts, then add environment variables:
vercel env add ANTHROPIC_API_KEY
| Key | Value | Required |
|---|---|---|
ANTHROPIC_API_KEY |
sk-ant-... |
For Insights AI |
MONITOR_SHEET_URL |
Your CSV URL | Optional (has default) |
PROMO_RAW_SHEET_URL |
Your CSV URL | Optional (has default) |
Your sheets must be published as CSV:
.env.local.Expected columns (first data row after header must have “market” in col A):
Market | Competitor | Product | Status | Base ∆ | Promo Impact | Promo ∆ | Promo Description
Promo Impact column should contain the word Active if the promo is active.The parser auto-detects the header row by looking for ≥2 cells matching known keywords:
date, competitor, market, product, promo type, status, active, etc.
Monitor view: open the app. If the Google Sheet is correctly published and the URL is set, you should see KPI cards, promo alerts (if any), and per-market tables.
Insights view: click “✦ Promo Insights” in the sidebar. Charts render immediately from the sheet data. AI cards render once the Anthropic API responds (5–15 seconds). If ANTHROPIC_API_KEY is missing, the AI cards show a clear error.
Refresh: click “Actualizar” in the header to reload all data from both sheets.
| Variable | Default | Secret? | Notes |
|---|---|---|---|
ANTHROPIC_API_KEY |
— | ✅ Yes | Never expose in client code |
MONITOR_SHEET_URL |
Hardcoded fallback | No | Override with your own sheet |
PROMO_RAW_SHEET_URL |
Hardcoded fallback | No | Override with your own sheet |
NEXT_PUBLIC_APP_NAME |
Promo Pricing Monitor |
No | Browser-visible |
runtime = "nodejs" — compatible with Vercel’s Node.js serverless functions./api/insights has maxDuration = 60 (requires Vercel Pro for durations > 10 s on Hobby plan). On Hobby, reduce max_tokens or use a faster model if timeouts occur./api/search-competitor)/api/scan-urls)/api/extract)