INSPIRATION

Webhooks are the nervous system of e-commerce. When a payment is captured, a webhook tells your backend to fulfill the order, grant access, or update inventory. But webhooks fail silently. A single stray whitespace character breaks a cryptographic signature. A network hiccup makes PayPal retry delivery, and a customer gets fulfilled twice. Events arrive out of order, or never arrive at all, and an order sits in "Approved" forever.

I wanted a tool that works like a doctor for webhooks: it catches the problem as it arrives, tells you what is wrong in plain language, and hands you the fix.

WHAT IT DOES

HookDoctor is an in-flight debugging agent for PayPal webhooks, built on the PayPal Sandbox.

Receives webhooks with full fidelity. It preserves the raw body byte for byte, captures all five PayPal signature headers, and measures handler latency.

Verifies signatures properly. It calls PayPal's official verify-webhook-signature API and checks that the certificate URL comes from a trusted PayPal domain, which prevents SSRF.

Detects problems with six deterministic rules: failed signature verification, duplicate event delivery, out-of-order lifecycle events, missing capture after approval, declined or reversed payments, and slow handlers (over 3 seconds).

Explains and fixes with Google Gemini. Every flagged event gets a severity, what happened, likely cause, a suggested fix, a copy-paste TypeScript snippet, and a confidence score. Results under 85% confidence get a visible warning badge.

Answers follow-up questions through an Ask HookDoctor chat on each event.

Shows the order lifecycle live on a real-time dashboard powered by Server-Sent Events.

Generates its own test traffic. Buttons create and capture real sandbox orders and trigger PayPal's webhook simulator. A Break It toggle injects faults: bad signature, dropped event, delayed handler, and duplicate delivery.

HOW WE BUILT IT

Backend: Node.js and Express in TypeScript, with raw body capture before JSON parsing so signatures verify correctly.

PayPal integration: OAuth2 client credentials, Orders v2 (create and capture), the signature verification API, and the webhook event simulator.

Detection engine: six local rules run on every event first. The rules decide what is wrong, and the AI only explains it.

AI layer: Google Gemini (gemini-2.5-flash) through the official @google/genai SDK, with a strict JSON schema that is validated before display and a local fallback engine if the API is unavailable.

Frontend: React 19, Vite, and Tailwind CSS with dark and light modes.

Storage and deployment: Postgres in production and SQLite locally, deployed on Render from a blueprint file so the webhook URL stays permanent.

CHALLENGES WE RAN INTO

Raw body preservation. Signature checks fail if the body is re-serialized, so the raw bytes must be captured first.

Keeping the AI trustworthy. I used strict schemas, validation, and confidence scores, and made the rules the source of truth.

Graceful failure. A debugging tool can't break when an API quota runs out, so a fallback engine produces safe fixes locally.

Faking failures safely. Break It simulates faults entirely inside the app, with no probing of PayPal or third-party systems.

Public URL for webhooks. Moving from a tunnel to Render meant handling proxy settings, automatic migrations, and routing so the frontend never shadows API and webhook paths.

ACCOMPLISHMENTS THAT WE'RE PROUD OF

A full end-to-end loop in the PayPal Sandbox: real order, real webhook, verified signature, detected problem, suggested fix.

A design where rules decide and AI explains, which keeps the tool reliable.

A demo that is easy to follow: one healthy flow, then four injected failures, each diagnosed in seconds.

Built solo and deployed as a working product.

WHAT WE LEARNED

Most webhook bugs come from a small set of causes: body handling, idempotency, ordering, and timing.

Combining deterministic checks with LLM explanations gives developers both certainty and understanding.

Strict schemas, confidence signals, and fallbacks are what make an AI feature safe to rely on.

WHAT'S NEXT FOR HOOKDOCTOR

Wider event coverage: subscriptions, disputes, refunds, and payouts.

Auto-reconciliation: query the Orders API when an event is missing and offer a one-click state repair.

Idempotency helper: generate drop-in middleware for Express and Next.js.

Replay and regression tests: save failing events and replay them against your own endpoint.

Team features: Slack and email alerts, and shareable incident reports.

Other providers: the same approach for Stripe, Razorpay, and more.

RESPONSIBLE USE

HookDoctor runs only in the PayPal Sandbox and never touches live payments. Only sanitized payload structures, headers, and error codes are sent to Gemini. All stored data can be wiped with the Clear Data button. Break It simulates faults only inside the app, with no attacks on any external service.

Built With

Share this project:

Updates

Submission history