Skip to content

feat(backend): Add webhook delivery system for card view events#590

Open
Dipti45sktech wants to merge 7 commits into
Dev-Card:mainfrom
Dipti45sktech:feature
Open

feat(backend): Add webhook delivery system for card view events#590
Dipti45sktech wants to merge 7 commits into
Dev-Card:mainfrom
Dipti45sktech:feature

Conversation

@Dipti45sktech

Copy link
Copy Markdown
Contributor

Summary

Implements the full webhook delivery system for card view and contact-save events as specified in issue #40. This includes endpoint registration, HMAC-SHA256 payload signing, exponential backoff retry logic, delivery logging, and full test coverage. The idea is simple — when someone views a card or saves a contact, any external system that has registered a webhook endpoint should get notified automatically with a signed POST request.

Closes #40


Type of Change

  • New feature
  • Tests only

What Changed

  • Added WebhookEndpoint and WebhookDelivery models to Prisma schema
  • Created apps/backend/src/routes/webhooks.ts with 4 REST endpoints (POST to register, GET to list, DELETE to remove, GET deliveries for logs)
  • Created apps/backend/src/utils/webhookDispatch.ts with HMAC-SHA256 payload signing via x-DevCard-Signature header and retry logic with exponential backoff (30s - 5min - 30min)
  • Hooked dispatchWebhook into card view and contact-save events in app.ts
  • Added 17 tests in webhooks.test.ts covering endpoint registration, signature generation, and delivery retry logic.

How to Test

  1. Run pnpm -r run test - all 17 webhook tests should pass
  2. Register a webhook endpoint via POST /api/webhooks
  3. Trigger a card view event and verify the external endpoint receives a signed POST request with x-DevCard-Signature header

Checklist

  • I have added or updated tests for the changes I made.
  • All tests pass locally (pnpm -r run test).
  • No new console.log or debug statements left in the code.
image

@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

@Dipti45sktech is attempting to deploy a commit to the Prashantkumar Khatri's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added backend gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking. labels Jun 17, 2026
@github-actions

Copy link
Copy Markdown

Hi @Dipti45sktech,

Thanks for opening this pull request.

This PR has been automatically classified based on the files modified.

Applied Labels

  • gssoc:approved
  • backend

Primary Review Area

  • backend

Reviewer

@Harxhit has been identified as the primary reviewer for this pull request.

If you have any questions regarding the affected area or implementation details, feel free to reach out to the assigned reviewer.

Thank you for your contribution!

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown

CI — All Checks Passed

Backend — PASS

Check Result
Lint PASS
Test PASS
Typecheck PASS

Mobile — SKIP

Check Result
Lint -
Test -

Web — SKIP

Check Result
Build -

Last updated: Tue, 23 Jun 2026 06:11:23 GMT

@Dipti45sktech

Copy link
Copy Markdown
Contributor Author

Hi @ShantKhatri please reassign me on issue #40 - I had completed this implementation earlier but the PR had to be closed due to branch conflicts. This is a clean resubmission of the same work. Kindly take a look.

@Harxhit Harxhit left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of the webhook delivery system. The route/dispatch design is solid (HMAC signing, encrypted secret at rest, ownership checks, endpoint cap), but there are blocking issues: the Prisma schema is corrupted, the core WebhookEndpoint model is missing, and dispatchWebhook is never called from any event handler — so card-view/contact-save events don't actually trigger anything as shipped. Inline comments below. Note: this PR also carries unrelated changes (CI lint removal, app.ts/auth/seed rewrites) that I'd recommend splitting out.

Comment thread apps/backend/prisma/schema.prisma
Comment thread apps/backend/prisma/schema.prisma
Comment thread apps/backend/prisma/schema.prisma
Comment thread apps/backend/prisma/schema.prisma
Comment thread apps/backend/src/app.ts Outdated
Comment thread apps/backend/src/app.ts Outdated
Comment thread apps/backend/src/app.ts Outdated
Comment thread apps/backend/src/routes/webhooks.ts Outdated
Comment thread apps/backend/src/utils/webhookDispatch.ts
@Dipti45sktech Dipti45sktech requested a review from Harxhit June 23, 2026 06:34
@Dipti45sktech

Dipti45sktech commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Hi @ShantKhatri and @Harxhit, thank you for the thorough review - I've addressed all the comments. Please let me know if anything else needs attention!

Please also make changes in DB seed too.

@Harxhit Harxhit added feature critical Includes schema, architecture, or other critical core functionality changes. labels Jun 23, 2026
@Harxhit Harxhit added this to DevCard Jun 23, 2026
@github-project-automation github-project-automation Bot moved this to Todo in DevCard Jun 23, 2026
@Harxhit Harxhit moved this from Todo to In progress in DevCard Jun 23, 2026
@Harxhit

Harxhit commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

@Dipti45sktech Could please also add DB seed and DB migrations proofs in PR description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend critical Includes schema, architecture, or other critical core functionality changes. feature gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking.

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

backend: implement webhook delivery system for card view and contact-save events

2 participants