feat(nip): Narrative Insurance Protocol — coverage and underwriting UI#35
Open
feat(nip): Narrative Insurance Protocol — coverage and underwriting UI#35
Conversation
Innovation Cycle #47 — The Living Story Protocol ## What's included ### Types & Mock Data - `src/types/insurance.ts` — Complete type definitions for events, policies, stakes, API contracts, and helper utilities (formatUSDC, calcPremium, etc.) - `src/lib/insurance-mock-data.ts` — Realistic mock dataset with 6 events across 3 stories, demo user positions for dev/demo mode ### API Routes (6 total) - `GET /api/insurance/events` — List open events w/ filters + pagination - `GET /api/insurance/events/[id]` — Single event details - `POST /api/insurance/policies` — Buy coverage (mock → real tx hook ready) - `POST /api/insurance/underwrite` — Stake as underwriter w/ APY estimate - `GET /api/insurance/stats` — Platform-wide insurance statistics - `GET /api/insurance/user-positions` — User's policies & stakes ### UI Components (7 total) - `InsuranceStats` — 4-metric platform overview with auto-refresh - `RiskBadge` — Risk tier indicator (LOW/MEDIUM/HIGH/EXTREME) - `SurvivalMeter` — Animated probability bar with color gradient - `InsuranceEventCard` — Full event card with coverage + underwrite CTAs - `BuyCoverageModal` — 3-step flow: configure → confirm → success/error - `UnderwriteModal` — 3-step flow: stake amount → confirm → success/error - `UserPositions` — Tabbed view of user's active policies and stakes ### Page - `/insurance` — Full page with hero, stats, risk-tier filters, event grid, FAQ explainer, and My Positions panel ### Navigation - Added 🛡️ Insure link to Navbar ## Design system compliance - Follows Ruins of the Future palette (gold, drift-teal, drift-purple) - Font: Cinzel (display), Space Grotesk (body), JetBrains Mono (numbers) - Glassmorphism cards with proper hover states - Fully responsive (mobile-first grid layout) - Framer Motion animations on all cards and modals ## Architecture decisions - Mock-first: Data layer uses realistic mock until DB migration runs - API routes are stub-ready: Replace mock with prisma queries + contract calls - Modals handle full error/loading/success state machine (3-step flow) - useCallback + proper deps to satisfy react-hooks/exhaustive-deps ## Revenue potential (from proposal) - Year 1: $45K → Year 3: $1.5M → Year 5: $15M - Moat: 54 months (first-mover, data flywheel, underwriter lock-in)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the full frontend for the Narrative Insurance Protocol (NIP) from Innovation Cycle #47. Readers can buy coverage against feared story outcomes. Underwriters can stake USDC to back characters they believe will survive.
Files Changed
New Files (17)
src/types/insurance.tssrc/lib/insurance-mock-data.tssrc/app/insurance/page.tsxsrc/app/api/insurance/events/route.tssrc/app/api/insurance/events/[id]/route.tssrc/app/api/insurance/policies/route.tssrc/app/api/insurance/underwrite/route.tssrc/app/api/insurance/stats/route.tssrc/app/api/insurance/user-positions/route.tssrc/components/insurance/InsuranceStats.tsxsrc/components/insurance/InsuranceEventCard.tsxsrc/components/insurance/BuyCoverageModal.tsxsrc/components/insurance/UnderwriteModal.tsxsrc/components/insurance/SurvivalMeter.tsxsrc/components/insurance/RiskBadge.tsxsrc/components/insurance/UserPositions.tsxModified Files (1)
src/components/landing/Navbar.tsxKey Features
For Readers (Policyholders)
For Underwriters
Platform-Wide
Testing
Architecture
Mock-first approach: API routes return mock data. To go live:
InsuranceEvent,InsurancePolicy,UnderwriterStakeprisma migrate devNarrativeInsuranceClient.tsPOC Smart Contract:
poc/narrative-insurance/NarrativeInsurance.solis ready for deployment.Deployment
No environment variables needed (mock data). For real contract:
Page is statically renderable — no server-side DB dependency.