How haochibao/hackharvard2025 works
This repository combines a browser extension that collects checkout-session, interaction, and location signals with a merchant-facing fraud-analysis API. The API workflow is merchant request → authentication and fraud analysis → in-memory transaction storage, with high-risk analyses optionally sent to a merchant webhook. Merchant registration, email verification, dashboard reporting, and SDK access are separate capabilities. The extension excerpts show tracking and browser-storage behavior, but not its wiring to the API; that connection is therefore omitted. Several API routes and extension modules were not sampled in full.
Main entry points: server.js HTTP Server · localStorage.js In-Memory Store · fraud.js Fraud Routes · auth.js Merchant Authentication
Components 20
Browser Extension
- Checkout Tracking
extension/app/content/app.js - Content Script
extension/app/content/content.js - Session Modal
extension/app/content/modal.js - Extension Popup
extension/app/popup/popup.js - Background Worker
extension/background/background.js - Background Functions
extension/background/functions.js
Fraud API
- HTTP Server
api/server.js - Fraud Routes
api/routes/fraud.js - Risk Analysis
api/services/fraudDetector.js - Merchant Authentication
api/middleware/auth.js
Merchant Services
- Merchant Accounts
api/routes/merchants.js - Email Verification
api/routes/email-verification.js - Dashboard Reporting
api/routes/dashboard.js - Webhook Management
api/routes/webhooks.js - Fraud SDK
api/sdk/fraud-detection-sdk.js
Runtime State
- Storage Facade
api/storage/index.js - In-Memory Store
api/storage/localStorage.js
Other components
- Shopper
- Merchant Client
- Merchant Webhook
Connections 18
- Shopper → Checkout Tracking: interacts with
- Checkout Tracking → Background Worker: requests location
- Merchant Client → HTTP Server: sends requests
- HTTP Server → Fraud Routes: mounts routes
api/server.js - HTTP Server → Merchant Accounts: mounts routes
api/server.js - HTTP Server → Email Verification: mounts routes
api/server.js - HTTP Server → Dashboard Reporting: mounts routes
api/server.js - HTTP Server → Webhook Management: mounts routes
api/server.js - Fraud Routes → Merchant Authentication: authenticates with
api/routes/fraud.js - Fraud Routes → Risk Analysis: analyzes transactions
api/routes/fraud.js - Fraud Routes → In-Memory Store: reads and writes
api/routes/fraud.js - Fraud Routes → Merchant Webhook: posts high-risk analysis
api/routes/fraud.js - Merchant Authentication → In-Memory Store: looks up API key
api/middleware/auth.js - Merchant Authentication → Storage Facade: imports shared maps
api/middleware/auth.js - Merchant Accounts → In-Memory Store: manages merchant data
api/routes/merchants.js - Email Verification → In-Memory Store: stores verification codes
api/routes/email-verification.js - Dashboard Reporting → In-Memory Store: reads reporting data
api/routes/dashboard.js - Storage Facade → In-Memory Store: exports shared store
api/storage/index.js