Skip to content

ibrahimmahafza/PushBack

Repository files navigation

PushBack πŸ›‘οΈ

AI-powered contract analysis and negotiation coaching for workers who've never been taught to push back.

Next.js TypeScript AI Tailwind License


🎯 The Problem

Every year, millions of people sign contracts they don't understand. In Quebec, 80% of people don't fully read their insurance contracts, and 50% don't understand the exclusions. Immigrants, gig workers, freelancers, first-time employees, and renters are especially vulnerable β€” they don't know what's normal, what's exploitative, or that they can negotiate. Legal consultations cost $300+/hour.

The problem isn't that people don't care β€” it's that they don't have the tools.

πŸ’‘ What It Does

PushBack is a 3-step AI-powered contract coach:

1. πŸ“„ Upload

Drop a PDF or paste contract text.

2. πŸ” Analyze

In under 30 seconds, get:

  • Severity-coded clauses β€” every clause rated πŸ”΄ Dangerous, 🟑 Concerning, or 🟒 Fair
  • Plain-language explanations in bullet-point format β€” no legal jargon
  • Leverage points β€” specific things you can say or do to push back
  • Top 3 to Fight β€” the three most important clauses to negotiate
  • Real Cost to You β€” estimated financial impact of problematic clauses
  • Visual analytics β€” donut charts, risk gauges, animated stat counters

3. 🀺 Practice Pushing Back

Select any risky clause and enter a negotiation sparring session:

  • AI plays your counterparty (HR manager, landlord, client)
  • Real-time coaching after each exchange
  • Generates a personalized negotiation script β€” exact phrases to say
  • Voice sparring via ElevenLabs TTS for realistic practice

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Frontend                        β”‚
β”‚  Next.js 16 Β· React 19 Β· Tailwind v4 Β· Motion   β”‚
β”‚  Warm light theme Β· Animated gradient background  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              API Routes (Node.js)                 β”‚
β”‚                                                   β”‚
β”‚  POST /api/analyze  β†’ generateObject (structured) β”‚
β”‚  POST /api/spar     β†’ streamText (streaming chat) β”‚
β”‚  POST /api/script   β†’ generateObject (structured) β”‚
β”‚  POST /api/tts      β†’ ElevenLabs voice synthesis  β”‚
β”‚  POST /api/upload   β†’ PDF text extraction         β”‚
β”‚                                                   β”‚
β”‚  Zod validation on every route                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              AI Layer                             β”‚
β”‚  AI model via Vercel AI SDK v6                    β”‚
β”‚  generateObject() β†’ typed structured output       β”‚
β”‚  streamText() β†’ real-time streaming chat          β”‚
β”‚  convertToModelMessages() β†’ UIMessage conversion  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚            Auth & Infrastructure                  β”‚
β”‚  Supabase Auth Β· Google OAuth                     β”‚
β”‚  SSR cookie-based sessions (no client tokens)     β”‚
β”‚  Middleware route protection                      β”‚
β”‚  Zero data storage β€” contracts never saved        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Tech Stack

Layer Technology Purpose
Framework Next.js 16 (App Router) Server components, API routes, SSR
Language TypeScript 5 Full-stack type safety
AI Model Anthropic Claude Contract analysis, sparring, script generation
AI SDK Vercel AI SDK v6 generateObject() for typed responses, streamText() for chat, DefaultChatTransport for streaming UI
Validation Zod v4 Runtime schema validation for all AI outputs and API inputs
Auth Supabase SSR + Google OAuth Cookie-based auth with createServerClient / createBrowserClient
Styling Tailwind CSS v4 @theme CSS tokens, no tailwind.config.ts
Animations Motion (Framer Motion v12) Staggered entrances, spring physics, layout transitions
Voice ElevenLabs TTS API Text-to-speech for voice sparring mode
PDF pdf-parse Server-side PDF text extraction
Icons Lucide React Tree-shakeable icon set

Key Technical Patterns

  • Phase-based state machine β€” contract-section.tsx manages 7 phases (upload | preview | analyzing | results | sparring | script | voiceSparring) via a string union type
  • useChat + DefaultChatTransport β€” DefaultChatTransport wrapped in useMemo for stable identity; extra body data (clause context) passed via transport config
  • convertToModelMessages() β€” async in AI SDK v6, converts UIMessage[] to ModelMessage[] server-side
  • Delimiter-based streaming β€” ---COACHING--- delimiter separates counterparty dialog from coaching notes in sparring responses
  • Zod .describe() on schema fields β€” guides Claude's structured output with field-level instructions
  • maxDuration = 60 + runtime = 'nodejs' β€” exported from route files for Vercel serverless compatibility

πŸ”’ Safety & Security

  • Zero data storage β€” contracts processed in memory, never saved to any database
  • Anti-hallucination β€” AI forced to quote exact contract text for every clause via Zod schema constraints
  • Input validation β€” Zod schemas on every API route; contract text validated (50–100k chars)
  • Prompt injection detection β€” all contract uploads scanned before processing
  • Rate limiting β€” 10 analyses, 50 sparring messages, 20 scripts per hour
  • Auth-gated β€” Google OAuth required, middleware protects all dashboard routes
  • Legal disclaimer β€” displayed on every analysis screen; PushBack is a coaching tool, not legal counsel
  • Human handoff β€” critical risks surface links to local legal aid resources

✨ Features

  • Severity-coded analysis β€” visual red/amber/green system
  • Bullet-point formatting β€” explanations and leverage broken into scannable points
  • Interactive analytics β€” animated donut charts, risk gauges, count-up stat cards
  • Top 3 to Fight β€” draggable card stack showing priority clauses
  • Real Cost panel β€” estimated financial impact with gradient border
  • AI sparring β€” realistic negotiation practice with coaching
  • Voice sparring β€” speak and hear responses via ElevenLabs TTS
  • Negotiation scripts β€” exact phrases to say, ask, and insist on
  • Animated background β€” warm gradient blobs on landing page (21st.dev-inspired)
  • Mobile responsive β€” hamburger menu, stacking grids, touch-friendly
  • Reduced motion support β€” respects prefers-reduced-motion

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • Supabase project with Google OAuth configured
  • Anthropic API key (Claude)
  • ElevenLabs API key (optional, for voice sparring)

Installation

git clone https://github.com/ibrahimmahafza/PushBack.git
cd PushBack
npm install

Environment Variables

Create .env.local:

# Supabase
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key

# Anthropic (Claude)
ANTHROPIC_API_KEY=your_anthropic_key

# ElevenLabs (optional β€” voice sparring)
ELEVENLABS_API_KEY=your_elevenlabs_key

Run

npm run dev
# Open http://localhost:3000

Build

npm run build && npm start

πŸ“ Project Structure

src/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ analyze/route.ts     # Contract analysis (generateObject)
β”‚   β”‚   β”œβ”€β”€ spar/route.ts        # Sparring chat (streamText)
β”‚   β”‚   β”œβ”€β”€ script/route.ts      # Script generation (generateObject)
β”‚   β”‚   β”œβ”€β”€ tts/route.ts         # ElevenLabs text-to-speech
β”‚   β”‚   └── upload/route.ts      # PDF text extraction
β”‚   β”œβ”€β”€ auth/callback/route.ts   # OAuth callback
β”‚   β”œβ”€β”€ dashboard/
β”‚   β”‚   β”œβ”€β”€ page.tsx             # Main dashboard (server component)
β”‚   β”‚   β”œβ”€β”€ contract-section.tsx  # Phase state machine (7 phases)
β”‚   β”‚   β”œβ”€β”€ layout.tsx           # Dashboard shell + nav
β”‚   β”‚   └── settings/            # User settings
β”‚   β”œβ”€β”€ login/page.tsx           # Google OAuth login
β”‚   β”œβ”€β”€ pricing/page.tsx         # Pricing page
β”‚   └── page.tsx                 # Landing page
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ AnalysisDashboard.tsx    # Results: charts, stats, clause list
β”‚   β”œβ”€β”€ AnalysisLoading.tsx      # Animated loading with progress
β”‚   β”œβ”€β”€ ClauseCard.tsx           # Clause display with severity + leverage
β”‚   β”œβ”€β”€ ContractUpload.tsx       # PDF upload + paste interface
β”‚   β”œβ”€β”€ SparringSession.tsx      # Text-based negotiation chat
β”‚   β”œβ”€β”€ VoiceSparring.tsx        # Voice-based sparring with TTS
β”‚   β”œβ”€β”€ ScriptCard.tsx           # Generated negotiation script
β”‚   β”œβ”€β”€ TopThreeFight.tsx        # Draggable priority clause cards
β”‚   β”œβ”€β”€ RealCostPanel.tsx        # Financial impact display
β”‚   └── ui/
β”‚       β”œβ”€β”€ BackgroundGradient.tsx  # Animated warm gradient blobs
β”‚       β”œβ”€β”€ CpuArchitecture.tsx    # SVG chip animation (loading)
β”‚       └── RadialOrbitalTimeline.tsx  # Orbital clause map
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ types.ts                 # Zod schemas + TypeScript types
β”‚   β”œβ”€β”€ markdown.tsx             # Inline markdown + bullet list renderer
β”‚   β”œβ”€β”€ prompts/
β”‚   β”‚   β”œβ”€β”€ analysis.ts          # Contract analysis system prompt
β”‚   β”‚   β”œβ”€β”€ sparring.ts          # Sparring system prompt
β”‚   β”‚   └── script.ts            # Script generation prompt
β”‚   └── supabase/
β”‚       β”œβ”€β”€ client.ts            # Browser client (createBrowserClient)
β”‚       β”œβ”€β”€ server.ts            # Server client (createServerClient + cookies)
β”‚       └── middleware.ts        # Middleware client (request/response cookies)
└── middleware.ts                # Route protection (getUser check)

🎬 Pitch Deck

A self-contained pitch deck is included at presentation.html. Open in any browser.

  • 8 slides β€” Hook, Problem, Solution, How It Works, Sparring Demo, Audience, Responsible AI, Closing
  • Arrow keys / swipe to navigate
  • Animated count-up numbers, blur-up entrances, warm gradient background
  • Light theme matching the app UI
  • No dependencies, no internet required

πŸ‘₯ Team

  • Ibrahim Mahafza
  • Levon Gyumishyan
  • Chloe Lai

πŸ“œ License

MIT β€” see LICENSE.

⚠️ Disclaimer

PushBack is not a substitute for legal advice. It's an AI coaching tool that helps you understand your contract and practice negotiating. Always consult a qualified attorney for legal decisions.


Understanding what you sign shouldn't be a privilege.
This is PushBack.

About

Claude Hackathon Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors