Skip to content

Latest commit

 

History

History
153 lines (105 loc) · 11 KB

File metadata and controls

153 lines (105 loc) · 11 KB

Salesforce × Booking System External Integration

A repository themed on Salesforce and external system integration: a booking system (NestJS / Next.js) integrated with Salesforce in both directions, carried through requirements → design → implementation → testing → live verification.

Screen Gallery

Experience Cloud site (booking projection list)

The booking projection list on the Experience Site. Bookings eligible for cancellation are highlighted.

Booking projection list

Cancel command flow

When a cancellation is accepted from the site, the processing status transitions from QUEUED to SUCCEEDED, and the booking status is updated to CANCELLED.

Cancellation accepted (processing status: QUEUED)

Cancellation accepted (QUEUED)

Processing complete (processing status: SUCCEEDED, booking status updated)

Processing complete (SUCCEEDED)

booking-side admin console (booking state after sync)

The admin console on the booking system side, reflecting the cancellation result.

Booking list in the admin console

Cancellation notification email (inbox example)

Example cancellation email in the inbox

1. What this repository demonstrates

  • ✅ Two-way integration — booking projection (booking → SF) and cancel commands (SF → booking)
  • ✅ Live verification — 5 browser test items + 8 automated verification items, all passed (including fault induction → manual recovery)
  • ✅ Security — JWT Bearer authentication, idempotent commands, row-level sharing (Sharing Set), CRUD/FLS
  • ✅ Documentation-driven — 24 documents across three stages (requirements, basic design, detailed design) + a verification coverage ledger

2. Architecture

flowchart LR
  subgraph BS["booking-system (separate repo)"]
    FE["Next.js UI"] --> BE["NestJS API"] --> DB[("PostgreSQL")]
  end
  subgraph SF["Salesforce"]
    SITE["Experience Site (LWC)"]
    APEX["Apex REST / Queueable"]
    OBJ[("Booking__c / Booking_Command__c")]
  end
  BE -- "① Booking projection (ECA, JWT Bearer)" --> APEX
  APEX --> OBJ
  SITE --> OBJ
  SITE -- "② Cancel command (Named Credential)" --> BE
Loading

3. Three demo scenarios

# Scenario Path Verified result
① Booking projection booking → SF NestJS → ECA (JWT Bearer) → Apex REST Canonical changes reflected in Booking__c, SYNCED
② Cancel command SF → booking Site LWC → Queueable → NC → Guard auth + 5-step validation → version+1 SUCCEEDED, both sides CANCELLED/v1/SYNCED
③ Failure & recovery Tunnel down → HTTP 530×3 → FAILED → RESET DML + re-enqueue (same commandId) SUCCEEDED, idempotency proven (side effect exactly once)

4. Verification record

Category Result
Automated verification 8 items, all passed (equivalent to MV-04–06, 08–11)
Browser live tests 5 items, all passed (MV-01/02/03, 07, 08)
Unit tests Apex 36/36 (4 booking classes, aggregate coverage 88.55%) / Backend Jest 273/273 / Frontend Jest 94/94
Failure recovery Command induced to FAILED → manual retry → SUCCEEDED (idempotency proven)

5. Key resources

5.1 Integration core (primary showcase)

Type File Role
Apex BookingProjectionRest.cls IF-01 receiver (idempotency, version gate, upsert)
Apex BookingProjectionDmlHelper.cls Projection DML (explicit system context)
Apex BookingCommandQueueable.cls IF-02 command execution + result write-back
Apex BookingSiteController.cls Site LWC backend (list / cancel / polling)
Test BookingProjectionRestTest / BookingSiteControllerTest / BookingCommandQueueableTest Unit tests for the 4 classes above
LWC bookingProjectionList Booking projection list (3-second polling, terminal-state display)
Objects Booking__c / Booking_Command__c Canonical snapshot (incl. version-monotonic VR) / command
Security Booking_Projection_Sharing.sharingSet / PermissionSets ×3 Row-level sharing (per Account) / Site & integration user permissions
Integration config Named Credential / External Credential / ECA IF-02 outbound entry / static Bearer / IF-01 JWT Bearer (Api, RefreshToken)

5.2 Contact Showcase (secondary — two component chains)

Chain Resources
LWC showcaseContactList / showcaseContactCreate / ShowcaseContactController.cls (+2 Tests) / ContactCreated channel (LMS same-page refresh)
Aura BulkCreateContactQuickAction → BulkCreateComponent → BulkCreateComponentChild / ContactDataController.cls (+Test, keyset paging / server-side trust boundary) / EventService (unified Apex gateway + in-table event bus) / quickActions ×2

5.3 Companion repositories (public on GitHub)

Repository Key resources
Cho-Geer/booking-backend integrations module (Guard, commands, projection sender) / integration.guard.ts / integration migration p02 (contract) / p03 (mapping)
Cho-Geer/booking-frontend SalesforceWorkbenchEntry.tsx (3-state gate) / AdminPage.tsx

6. Design documents (3 stages, 24 documents + ledger)

Requirements definition (8)
Basic design (12)
Detailed design (4) + ledger

7. Suggested review path (~10 minutes)

  1. 01 Requirements List — business background and scope
  2. interface-design.md — IF-01/02 contracts (auth, timeouts, payloads)
  3. BookingProjectionRest.cls — receiving-side implementation (idempotency, version gate)
  4. integration-commands.service.ts — sending-side Guard auth + 5-step validation and retry
  5. coverage-matrix-summary.xlsx — full deliverable × verification ledger

8. Author

Zixi Tao — Salesforce & external system integration (design, implementation, testing, failure recovery) Deploy this repo: sf project deploy start -o <org-alias> Companion repos: booking-backend / booking-frontend (see each repo's README for setup)


🇯🇵 日本語 | 🇬🇧 English | 🇨🇳 中文