Skip to content
sc-likes-to-codePublic

Repository files navigation

WhatNow?

Something happened? Know what to do next.

Next.js TypeScript Tailwind CSS Google Gemini

WhatNow? is a practical, digital first-response platform designed to help people navigate unexpected real-life situations. When something goes wrong — a lost passport, a stolen credit card, a hacked account, or a car breakdown — WhatNow? turns scattered panic into prioritized, verified, step-by-step action plans.

Combining a deterministic, human-audited emergency scenario database with Google Gemini 3.1 Flash-Lite AI interpretation and country-specific localization, WhatNow? provides immediate clarity, statutory deadline protection, preparation templates, and empathetic conversational guidance without requiring user accounts or GPS tracking.


Table of Contents


Overview

When an unexpected event occurs, people rarely suffer from a lack of information on the internet — they suffer from information overload, ambiguity, and high stress. Official helpline numbers, emergency filing steps, embassy procedures, and bank chargeback rules are often buried across dozens of disparate government portals, financial network FAQs, and carrier websites.

WhatNow? serves as a centralized, privacy-first emergency action manual. It eliminates guessing by analyzing what happened in plain English, pulling up structured, government-verified emergency action plans, tailoring guidance to the user's location, and helping them take control step-by-step.


Why WhatNow?

In an emergency, people ask critical questions in rapid succession:

  • What should I do first right now?
  • What critical mistake must I avoid doing?
  • Who do I call, and which official portal do I use?
  • What documents will I need to replace or file a claim?
  • Is there a statutory deadline (e.g. 3-day bank fraud zero-liability window)?
  • How do I notify police, my bank, or my embassy?

WhatNow? addresses this scattered uncertainty by organizing information into structured, bite-sized components:

[Unexpected Incident] ➔ [AI & Deterministic Classification] ➔ [Verified Action Plan + Country Context + Deadlines]

Product Philosophy

The core user experience moves through four distinct emotional and operational phases:

$$\text{PANIC} \longrightarrow \text{CLARITY} \longrightarrow \text{ACTION} \longrightarrow \text{CONTROL}$$

  1. PANIC: Something unexpected has happened (lost identity, stolen device, financial breach).
  2. CLARITY: Understand what matters right now. Filter out noise and focus on immediate priorities.
  3. ACTION: Execute step 1 ("Do This Now") and avoid common mistakes ("Do Not Do This").
  4. CONTROL: Track document requirements, add statutory deadlines to Google Calendar, and monitor recovery follow-ups.

Key Design Principles:

  • Action Before Information Overload: Display the single most critical action first.
  • Verified Sources Over Guesswork: Official helpline numbers and portals originate strictly from human-audited datasets, never LLM hallucinations.
  • Privacy By Default: 100% accountless; zero GPS tracking; all user progress stays in local browser storage.
  • AI Assists, Not Invents: AI interprets intent and personalizes advice, but operates within deterministic data guardrails.

Who Is WhatNow? For?

WhatNow? provides tailored action guides across 5 primary incident categories:

  • Travel & Identity: Lost passport abroad, stolen national ID, driver's licence loss, flight cancellations, stranded at airport, lost luggage.
  • Money & Cards: Stolen debit/credit card, ATM card retained, card cloning, unauthorized UPI/bank transfers, investment scams, online shopping fraud.
  • Digital & Accounts: Hacked social media account, compromised email, SIM swap attacks, data breaches, phishing link clicked, cloud storage leak.
  • Home & Vehicle: Car accident, vehicle theft, flat tyre, dead car battery, home burglary, house keys lost, locked keys inside.
  • Personal & Property: Stolen laptop/phone, lost device while traveling, identity theft, impersonation scams.

Features

1. Emergency Action Plans & Guidance

  • Do This Now: Top-priority immediate action steps (e.g. block SIM card, freeze bank account).
  • Do Not Do This: Critical warnings to prevent compounding damage (e.g. do not pay ransom to scammers, do not touch burglary crime scene).
  • Interactive Checklists: Checkable progress steps persisted locally in browser localStorage.
  • Decision Trees: Interactive diagnostic trees for complex choices (e.g., Tatkaal vs Normal passport reissue path).

2. Situation Discovery & Multi-Incident Bundling

  • Natural Language Search: Type descriptions like "someone took my backpack with my phone and wallet inside".
  • Incident Bundling: Combines multiple overlapping emergency guides into a single unified recovery plan (e.g. phone-stolen + card-stolen + passport-lost).
  • Guided Diagnosis: Interactive step-by-step questionnaire for users who are unsure what type of incident occurred (/emergencies/discover).

3. Panic Mode

  • A high-contrast, distraction-free emergency mode that strips away secondary navigation and presents only essential contact numbers and immediate step-1 instructions.

4. Emergency Kit & Printable Statement Templates

  • Document & Info Checklist: Lists essential items to gather (police FIR, bank statements, transaction IDs).
  • Interactive Template Generator: Generates formatted, printable statement templates (e.g. Police Lost Document FIR Statement, Bank Card Fraud Chargeback Notice) rendered strictly in local memory.

5. Deadline Protection & Google Calendar Integration

  • Tracks statutory filing deadlines (e.g. 3-day zero-liability fraud reporting window).
  • Direct Google Calendar Action: One-click + Add to Google Calendar pre-populates UTC calendar events without requiring OAuth login or account connections.

6. Privacy-First Country Localization & Travel Mode

  • Tailors helplines, official portals, and filing procedures to selected country context (India, Singapore, US, UK, Canada, Australia, Global).
  • Travel Mode Toggle: Activates consular embassy guidance and foreign police FIR procedures when traveling abroad.

7. Verified Authority Source Registry & Trust Badges

  • Direct links to official government and financial authority portals (CEIR, Cyber Crime Portal 1930, Passport Seva, FTC, State Dept).
  • Every external link displays an audited Verified Source badge with transparent verification timestamps.

Scenario Engine

The scenario engine is powered by structured JSON data models located in src/data/emergencies/.

User Description ("my wallet and phone were taken")
   │
   ▼
[NLP Classifier / Gemini 3.1]
   │
   ▼
Matched Scenario Slugs: ["phone-stolen", "card-stolen"]
   │
   ▼
[Structured Scenario Engine]
 ├── Immediate Action Checklist
 ├── Critical Warnings (Do Not Do)
 ├── Required Documents & Deadlines
 ├── Verified Authority Links (CEIR, Bank Helpline)
 └── Location-Specific Rules (India / Travel Context)

By decoupling interpretation from authoritative procedure data, WhatNow? guarantees that official phone numbers and government links are 100% deterministic and hallucin-free.


AI & Safety

Google Gemini 3.1 Flash-Lite (@google/genai) is integrated as an intent interpretation, conversational personalization, and explanation layer.

What AI Does:

  • Interprets ambiguous, emotional, or conversational user descriptions.
  • Maps natural language prompts to verified scenario IDs.
  • Personalizes follow-up responses and empathetic chat conversation.
  • Explains complex legal or administrative terms in simple language.

What AI Does NOT Do:

  • AI does NOT generate official helpline numbers.
  • AI does NOT invent government links or domain names.
  • AI does NOT dictate bank dispute deadlines or statutory rules.
  • AI does NOT hallucinate emergency procedures.

AI Resilience & Deterministic Fallbacks

WhatNow? does not break if the AI API is offline or unconfigured:

  • Offline Keyword & Fuzzy Matcher (src/lib/ai/nlp-matcher.ts): If the GEMINI_API_KEY is missing or API limits are reached, the application seamlessly falls back to a deterministic keyword ranking algorithm that scores scenario titles, tags, and synonyms locally.
  • Core scenario pages (/emergencies/[slug]), checklists, emergency kits, and source registries remain 100% usable without active AI connections.

Global Conversational Assistant

The global floating assistant (GlobalChatbot.tsx) provides continuous conversational support across the platform.

  • Floating Interface: Accessible from any page via the bottom-right action trigger.
  • Local Persistence: Chat history is saved locally in browser localStorage (whatnow_chat).
  • Grounded Responses: Powered by /api/ai/chat using Gemini 3.1 Flash-Lite, grounded in WhatNow scenario datasets.
  • Empathetic & Concise: Tailored prompt engineering ensures calm, concise, bulleted responses under 3-4 sentences.
  • Casual Conversation Handling: Generic greetings (e.g. "hi", "hello") trigger friendly conversational openings rather than incorrectly forcing an emergency classification.
  • One-Click Reset: Permanent local chat deletion via the header trash icon (🗑).

Trust & Sources

WhatNow? operates an audited Trust Registry (src/data/sources/index.ts).

  • Official Authority Criteria: External links point strictly to top-level government domains (.gov, .gov.in, .gov.sg), official telecom registries (CEIR), or bank fraud divisions.
  • Community Reporting: Users can report outdated links, changed helpline numbers, or regional inaccuracies via the /report page or ReportOutdatedModal.
  • Admin Audit Dashboard: Internal audit dashboard (/admin) allows inspection of active scenarios, stale sources (>180 days since verification), community issue reports, and contact submissions.

Location & Localization

WhatNow? uses a privacy-first localization model (LocationContext.tsx & localization.ts):

  • No GPS Tracking: WhatNow? never requests browser geolocation permissions or IP tracking.
  • User-Selected Context: Users choose their current country and home issuing country via the Location Selector.
  • Supported Regions: India (IN), Singapore (SG), United States (US), United Kingdom (UK), Canada (CA), Australia (AU), and Global / International (GLOBAL).
  • Travel Context: Toggling "Currently Travelling Abroad" prioritizes embassy consular desks, passport lost abroad protocols, and foreign police lost reports.

Emergency Kit & Document Templates

The Emergency Kit section (src/components/emergency/EmergencyKitSection.tsx) helps users organize necessary documentation and generate formal statements:

  • Police Lost Document FIR Statement: Pre-formatted text template for reporting lost passports, IDs, or stolen phones to police.
  • Bank Fraud Chargeback Notice: Formal written notice to bank branch managers detailing unauthorized transaction timestamps and helpline acknowledgment numbers.
  • Local Memory Processing: Text typed into statement templates remains strictly in temporary component state and is never transmitted to external servers.

Deadline Protection & Google Calendar

To prevent missed statutory deadlines:

[Statutory Deadline: Report Bank Fraud within 3 Days]
   │
   ▼
[Click: + Add to Google Calendar]
   │
   ▼
Generates Direct URL: https://calendar.google.com/calendar/render?action=TEMPLATE&text=...
   │
   ▼
Opens Google Calendar in new tab (Zero OAuth / Zero Login Required)

Privacy Architecture

WhatNow? is designed to be privacy-safe by default.

Data Type Behavior Storage Location
User Account None required (100% accountless) N/A
Chat History Persisted locally on client device Browser localStorage (whatnow_chat)
Location Selection Country code only (e.g., IN, US) Browser localStorage (whatnow_user_location)
Checklist State Progress checkmarks Browser localStorage (whatnow_checklist_<slug>)
GPS / Coordinates Zero collection / Zero tracking N/A
Gemini Prompts Natural language text sent to API for classification Server-side API processing (/api/ai/*)
Cloud Database None (No cloud conversation database) N/A
Gemini API Key Stored in server environment variables Server environment only (process.env.GEMINI_API_KEY)

Security

  • Server-Side API Key Protection: GEMINI_API_KEY is consumed exclusively inside Next.js API routes (src/app/api/ai/*). No client-side NEXT_PUBLIC_ key exposure.
  • Input Sanitization: User situation prompts are validated and sanitized before forwarding to AI services.
  • Structured Output Validation: Gemini responses are validated against JSON Schemas (schemas.ts) to prevent unexpected response formats.

Architecture

┌────────────────────────────────────────────────────────────────────────┐
│                              WhatNow? UI                               │
├───────────────┬────────────────┬───────────────┬───────────────────────┤
│ Hero Search   │ Emergency View │ Panic Mode    │ Global Chatbot Widget │
│ Category Grid │ Checklist/Tree │ Emergency Kit │ Location Selector     │
└───────┬───────┴───────┬────────┴───────┬───────┴───────────┬───────────┘
        │               │                │                   │
        ▼               ▼                ▼                   ▼
┌────────────────────────────────────────────────────────────────────────┐
│                        Next.js Application Layer                       │
├───────────────────────┬────────────────────────┬───────────────────────┤
│ Scenario Engine       │ Location Context       │ LocalStorage Handler  │
│ Verified Sources Data │ Recovery Timeline      │ Calendar URL Gen      │
└───────┬───────────────┴────────┬───────────────┴───────────┬───────────┘
        │                        │                           │
        ▼                        ▼                           ▼
┌───────────────────┐    ┌───────────────────┐     ┌─────────────────────┐
│  AI Classifier    │    │  Offline Matcher  │     │ Server API Routes   │
│  Gemini 3.1 Flash │    │  (NLP Fallback)   │     │ /api/ai/classify    │
└───────────────────┘    └───────────────────┘     │ /api/ai/chat        │
                                                   └─────────────────────┘

Data Flow

Emergency Plan Discovery Flow

User Prompt ("stolen wallet") ➔ /api/ai/classify ➔ Gemini / NLP Fallback ➔ Scenario Slug ("card-stolen") ➔ Scenario Engine ➔ EmergencyView Page

Chatbot Conversation Flow

User Message ➔ GlobalChatbot UI ➔ /api/ai/chat ➔ Gemini 3.1 Flash-Lite (Grounded Prompt) ➔ Streamed Response ➔ Local Storage (whatnow_chat)

Project Structure

WhatNow/
├── public/                     # Static assets (logo.png, favicon.png)
├── src/
│   ├── app/                    # Next.js App Router pages & API routes
│   │   ├── about/              # About WhatNow & Creator pages
│   │   ├── accessibility/      # Accessibility Statement
│   │   ├── admin/              # Admin Data & Audit Dashboard
│   │   ├── ai-safety/          # AI Safety Policy page
│   │   ├── api/                # Server API endpoints (AI, Reports, Contact)
│   │   │   ├── ai/             # Gemini classification, chat & health routes
│   │   │   ├── contact/        # Contact form submission API
│   │   │   └── reports/        # Community report submission API
│   │   ├── contact/            # Contact Us page
│   │   ├── disclaimer/         # Legal Disclaimer page
│   │   ├── emergencies/        # Scenario directory, dynamic [slug], & bundle pages
│   │   ├── faq/                # Interactive Accordion FAQ page
│   │   ├── how-it-works/       # Process architecture page
│   │   ├── privacy/            # Privacy Policy page
│   │   ├── report/             # Report an Issue page
│   │   ├── terms/              # Terms of Use page
│   │   ├── trust/              # Trust Center & Source Registry page
│   │   ├── globals.css         # Tailwind global styles
│   │   ├── layout.tsx          # Root Layout (Header, Footer, GlobalChatbot)
│   │   └── page.tsx            # Home Landing page
│   ├── components/             # React UI Components
│   │   ├── chat/               # GlobalChatbot widget
│   │   ├── common/             # IconRenderer, SeverityBadge
│   │   ├── discovery/          # GuidedUncertaintyFlow
│   │   ├── emergency/          # EmergencyView, Checklist, PanicMode, EmergencyKit
│   │   ├── home/               # HeroSearch, CategoryGrid
│   │   ├── layout/             # Header, Footer
│   │   └── location/           # LocationBadge, LocationSelectorModal
│   ├── context/                # LocationContext provider
│   ├── data/                   # Structured emergency & source databases
│   │   ├── emergencies/        # 52 individual scenario definition files
│   │   ├── kits/               # Emergency kit definitions
│   │   ├── recovery/           # Statutory document & deadline datasets
│   │   ├── sources/            # Verified authority source registry
│   │   └── categories.ts       # Category metadata
│   ├── lib/                    # Core utilities & engines
│   │   ├── ai/                 # Gemini client, classifier, schemas & NLP fallback
│   │   ├── analytics.ts        # Usage event tracking
│   │   ├── bundler.ts          # Incident scenario bundling engine
│   │   ├── chat-storage.ts     # Chat history localStorage utilities
│   │   ├── google-calendar.ts  # Google Calendar URL generator
│   │   ├── storage.ts          # Checklist localStorage handler
│   │   └── utils.ts            # Tailwind classnames merger
│   └── types/                  # TypeScript interface definitions
├── .env.example                # Environment variable template
├── .gitignore                  # Git untracked path rules
├── next.config.js              # Next.js configuration
├── package.json                # Project dependencies & scripts
├── postcss.config.js           # PostCSS Tailwind config
├── tailwind.config.js          # Tailwind design theme config
└── tsconfig.json               # TypeScript compiler config

Tech Stack


Application Routes

Category Route Purpose
Core Product / Home Landing Page with Hero Search & Categories
/emergencies Scenario Directory with Search & Category Filters
/emergencies/[slug] Dynamic Emergency Action Plan & Emergency Kit
/emergencies/discover Guided Diagnostic Questionnaire
/emergencies/bundle Multi-Incident Bundled Action Plan
Trust & Audit /trust Trust Center & Verified Authority Source Registry
/admin Admin Data Audit Dashboard (Scenarios, Sources, Reports)
Informational /about Product Mission & 7-Step Process
/about/creator Independent Creator Story & Vision
/how-it-works Platform System Architecture Explanation
Legal & Privacy /ai-safety AI Safety & Guardrails Policy
/privacy Privacy Policy (LocalStorage documentation)
/terms Terms of Use & Local Storage Rights
/disclaimer Legal Non-Dispatch Notice & Emergency Numbers
/accessibility WCAG 2.1 AA Accessibility Statement
Support /faq Interactive FAQ Accordion
/contact Contact Us Submission Form
/report Community Issue & Outdated Info Reporting
API Endpoints /api/ai/classify AI Situation Classifier API
/api/ai/explain AI Action Step Explanation API
/api/ai/chat Global Chatbot Conversational API
/api/ai/health AI Engine Health Status API
/api/reports/submit Community Report Submission & Admin API
/api/contact/submit Contact Submission & Admin API

Getting Started

Prerequisites

  • Node.js: v18.17.0 or higher
  • Package Manager: npm (v9+)
  • Google Gemini API Key: Obtain a key from Google AI Studio

Installation

  1. Clone the repository:

    git clone https://github.com/sc-likes-to-code/WhatNow.git
    cd WhatNow
  2. Install dependencies:

    npm install
  3. Configure Environment Variables: Copy .env.example to create a local .env file:

    cp .env.example .env

    Open .env and insert your Gemini API key:

    GEMINI_API_KEY=your_actual_gemini_api_key_here
    GEMINI_MODEL=gemini-3.1-flash-lite
  4. Run the Development Server:

    npm run dev

    Open http://localhost:3000 in your browser.


Production Build

To test or build the optimized production output:

# Clean previous build artifacts (optional)
npm run build

# Start production server locally
npm run start

Static and dynamic routes will be prerendered cleanly:

 ✓ Compiled successfully
 ✓ Prerendered static pages (80/80)

Testing & Quality Assurance

The codebase undergoes comprehensive manual QA across key functional matrices:

  • AI Intent Classification: Tested across ambiguous, multi-incident, and casual input prompts.
  • Offline Fallback: Verified that core scenario browsing and search work when GEMINI_API_KEY is omitted.
  • Localization Routing: Tested country switches (India, US, UK, SG, CA, AU) and travel mode toggles.
  • Calendar Action: Verified + Add to Google Calendar direct URL links generate correct UTC parameters.
  • Report & Contact Submissions: Verified submission handling and real-time deletion on the /admin dashboard.
  • Mobile Responsiveness: Tested across responsive breakpoints (320px to 1440px+).

Accessibility

WhatNow? adheres to WCAG 2.1 AA guidelines:

  • High Contrast Typography: Tested text contrast against warm background palettes.
  • Keyboard Navigation: Interactive controls, buttons, modals, and accordions are fully keyboard accessible (Tab, Enter, Space, Esc).
  • Screen Reader Support: ARIA attributes (aria-label, aria-expanded, aria-hidden) on modals, buttons, and badges.
  • Reduced Motion: Respects prefers-reduced-motion settings.

Reliability & Fallbacks

  • No Single Point of Failure: If Gemini API requests timeout or fail, the offline NLP keyword matcher takes over automatically.
  • Zero Lock-In: Users can export or print action plans and Emergency Kit templates as physical documents.
  • Local Control: Chat history and location choices can be cleared instantly by the user at any time.

Limitations & Safety Notice

Important

WhatNow? is an informational first-response guide platform. It is NOT an emergency dispatch service, government agency, law enforcement body, bank, insurer, or medical provider.

  • Life-Threatening Emergencies: For immediate physical danger, medical trauma, active fires, or violent crimes, users must immediately call national emergency dispatch: 112 (India / EU), 911 (US / Canada), or 999 (UK).
  • Official Verification: Users should verify high-stakes procedures (e.g. passport replacement appointments or police FIR filings) directly on the linked official government portals.

Contributing & Reporting Issues

Reporting Inaccuracies or Broken Links

If you find an outdated helpline number, changed government URL, or incorrect regional step, submit a report via /report or click Report an Issue on any emergency guide page.

Code Contributions

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature/new-scenario).
  3. Commit your changes adhering to conventional commit messages.
  4. Verify build success (npm run build).
  5. Open a Pull Request.

Development Journey

WhatNow? was developed through a structured, modular engineering trajectory:

  • Phase 1 — Core Emergency Engine: 52 scenario definitions, action steps, checklists, Panic Mode.
  • Phase 2 — Discovery & AI Intelligence: Hero search, guided diagnosis, scenario bundling, Gemini 3.1 classification engine.
  • Phase 3 — Trust, Sources & Localization: Privacy-first country selection, travel mode, verified source registry, Trust Center, Admin audit dashboard.
  • Phase 4 — Emergency Kit: Preparation checklists, police FIR & bank fraud statement template generator.
  • Phase 5 — Documents & Deadline Protection: Document requirement cards, statutory deadline timelines, Google Calendar URL integration.
  • Phase 6 — Intentionally Skipped: Incident management accounts were intentionally omitted to maintain a 100% accountless, zero-login privacy architecture.
  • Phase 7 — Global Conversational Assistant: Grounded Gemini 3.1 assistant, local storage chat persistence, floating widget.
  • Phase 8 — Professional Footer, Trust & Support Architecture: Footer redesign, About, Creator, How It Works, Trust, AI Safety, Privacy, Terms, Disclaimer, Accessibility, FAQ, Contact & Report pages.

About the Creator

WhatNow? was built as an independent software project to prove that emergency response tools can be calm, practical, authoritative, and privacy-respecting without sacrificing modern user experience or leveraging invasive tracking.

Learn more on the About Creator page.


License

This project is licensed under the MIT License. See the LICENSE file for details.


WhatNow? — Something happened? Know what to do next.