File size: 5,390 Bytes
2211d3a
4d26b95
 
 
2211d3a
4d26b95
 
 
 
 
 
 
2211d3a
4d26b95
 
2211d3a
4d26b95
 
 
 
 
 
 
 
 
 
 
 
ad3cafa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2211d3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Guardian Agent

## Overview

Guardian Agent is a manipulation blocker for the modern web β€” a Chrome extension companion web app that detects and visualizes dark patterns used by e-commerce sites to extract money from shoppers.

## Stack

- **Monorepo tool**: pnpm workspaces
- **Node.js version**: 24
- **Package manager**: pnpm
- **TypeScript version**: 5.9
- **Frontend**: React + Vite + Tailwind CSS (artifacts/guardian-agent)
- **API framework**: Express 5
- **Database**: PostgreSQL + Drizzle ORM
- **AI**: Anthropic Claude (claude-haiku-4-5) via Replit AI Integrations
- **Validation**: Zod (`zod/v4`), `drizzle-zod`
- **API codegen**: Orval (from OpenAPI spec)
- **Build**: esbuild (CJS bundle)

## Key Commands

- `pnpm run typecheck` β€” full typecheck across all packages
- `pnpm run build` β€” typecheck + build all packages
- `pnpm --filter @workspace/api-spec run codegen` β€” regenerate API hooks and Zod schemas from OpenAPI spec
- `pnpm --filter @workspace/db run push` β€” push DB schema changes (dev only)
- `pnpm --filter @workspace/api-server run dev` β€” run API server locally

## Pages & Features

### Landing Page (`/`)
Full marketing page: hero, stats bar, interactive browser mock demo, "How It Works", dark patterns catalog, trust leaderboard, testimonials, dual CTA

### Live Scanner (`/demo`) β€” Hackathon Demo Key Page
- 4 preset scenarios (Booking.com, United Airlines, Amazon, Etsy clean) β€” one click runs real Claude AI analysis
- Custom input mode β€” paste any checkout text
- Real-time animated results: all 6 dark pattern categories with evidence
- Auto-saves to DB and updates domain trust rating after each scan

### Extension Preview (`/extension`)
- Interactive browser chrome mockup showing Guardian overlay UI
- 3 switchable demo states: Booking.com (5 patterns), Etsy (clean), United Airlines (upsell gauntlet)
- Shows every Guardian action: timer warnings, auto-unchecked add-ons, rewritten buttons

### Fee Calculator (`/fee-calculator`)
- 4 quick presets (booking.com, spirit.com, airbnb.com, enterprise.com)
- Custom domain + merchant type + listed price β†’ Claude estimates true total
- Shows itemized fee breakdown, savings opportunity, confidence level

### Command Center (`/dashboard`)
- KPI cards with 30s auto-refresh
- Live detection feed with hidden fee amounts
- Pattern distribution pie chart
- Top offenders leaderboard
- Quick action shortcuts

### Intelligence Pages
- `/trust` β€” Domain trust ratings with filtering
- `/trust/:domain` β€” Per-domain detail with scan history
- `/reports` β€” Detection report feed
- `/reports/:id` β€” Full report detail with all 6 pattern breakdowns
- `/patterns` β€” Dark patterns encyclopedia
- `/stats` β€” Analytics with bar charts and offenders table

## API Endpoints

- `POST /api/analysis/detect` β€” Raw Claude dark pattern analysis
- `POST /api/analysis/classify-upsell` β€” Classify upsell pages
- `POST /api/demo/scan` β€” All-in-one: detect + save report + update trust rating
- `POST /api/demo/fee-estimate` β€” Claude estimates true price with fee breakdown
- `GET /api/trust` β€” List trust ratings
- `PATCH /api/trust/:domain` β€” Upsert trust rating
- `GET /api/trust/:domain` β€” Domain detail
- `GET /api/reports` β€” List detection reports
- `POST /api/reports` β€” Create report
- `GET /api/reports/:id` β€” Report detail
- `GET /api/stats/summary` β€” Total stats
- `GET /api/stats/pattern-breakdown` β€” Per-type counts
- `GET /api/stats/top-offenders` β€” Worst domains

## Features

### Dark Patterns Detected
1. **False Urgency** β€” Fake countdown timers and "deal expires soon" banners
2. **False Scarcity** β€” Fabricated "only 1 left" and "42 people viewing" claims
3. **Confirm Shaming** β€” Guilt-tripping decline button text
4. **Hidden Fees** β€” Resort fees, service fees, and surcharges hidden until checkout
5. **Pre-Checked Add-Ons** β€” Travel insurance, newsletters pre-selected by default
6. **Misdirection** β€” Visually hidden decline options and exit paths

### App Pages
- `/` β€” Marketing landing page
- `/dashboard` β€” Command center with live stats and recent detections
- `/trust` β€” Domain trust ratings table
- `/trust/:domain` β€” Domain-specific trust profile
- `/reports` β€” Detection reports feed with filtering
- `/reports/:id` β€” Individual report detail view
- `/patterns` β€” Dark patterns encyclopedia (educational)
- `/stats` β€” Analytics with charts and top offenders

### API Endpoints
- `POST /api/analysis/detect` β€” AI-powered dark pattern detection (Claude)
- `POST /api/analysis/classify-upsell` β€” Upsell page type classification (Claude)
- `GET/PUT /api/trust/:domain` β€” Domain trust ratings
- `GET/POST /api/reports` β€” Detection reports
- `GET /api/stats/summary` β€” Overall statistics
- `GET /api/stats/pattern-breakdown` β€” Pattern type counts
- `GET /api/stats/top-offenders` β€” Most manipulative domains

## DB Schema

- `trust_ratings` β€” Per-domain trust scores and manipulation history
- `detection_reports` β€” Individual dark pattern scan results

## Architecture Notes

- AI integration uses Replit AI Integrations proxy for Anthropic β€” no API key needed
- No PII sent to AI: only anonymized page text for classification
- Frontend imports hooks from `@workspace/api-client-react` (generated via Orval)
- Backend imports Zod validators from `@workspace/api-zod` (generated via Orval)