| name | salesforce-reference-architecture |
| description | Implement Salesforce integration reference architecture with jsforce, SFDX, and event-driven patterns.
Use when designing new Salesforce integrations, reviewing project structure,
or establishing architecture standards for Salesforce-connected applications.
Trigger with phrases like "salesforce architecture", "salesforce project structure",
"salesforce integration design", "how to organize salesforce code", "salesforce layout".
|
| allowed-tools | Read, Grep |
| version | 1.7.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","crm","salesforce"] |
| compatibility | Designed for Claude Code |
Salesforce Reference Architecture
Overview
Production-ready architecture patterns for Salesforce integrations, covering Node.js integration apps, SFDX metadata projects, and event-driven sync architectures.
Prerequisites
- Understanding of layered architecture
- jsforce and Salesforce CLI experience
- TypeScript project setup
- Decision on sync model (polling vs event-driven)
Project Structure
Node.js Integration App
my-sf-integration/
├── src/
│ ├── salesforce/
│ │ ├── connection.ts # Singleton jsforce connection with auto-refresh
│ │ ├── types.ts # Typed sObject interfaces (Account, Contact, etc.)
│ │ ├── queries.ts # SOQL query builders
│ │ ├── mutations.ts # Create/update/delete operations
│ │ └── events.ts # CDC and Platform Event subscribers
│ ├── services/
│ │ ├── account-sync.ts # Business logic for Account sync
│ │ ├── contact-sync.ts # Business logic for Contact sync
│ │ └── opportunity-sync.ts # Pipeline/forecast sync
│ ├── api/
│ │ ├── routes.ts # Express/Fastify routes
│ │ └── health.ts # Health check with SF connectivity
│ ├── jobs/
│ │ ├── full-sync.ts # Scheduled full data sync
│ │ └── incremental-sync.ts # CDC-based incremental sync
│ └── index.ts
├── tests/
│ ├── unit/ # Mocked jsforce tests
│ └── integration/ # Live sandbox tests
├── config/
│ ├── default.json # Shared config
│ └── production.json # Production overrides
└── package.json
SFDX Metadata Project (Apex, LWC, Triggers)
my-sf-app/
├── force-app/main/default/
│ ├── classes/ # Apex classes
│ │ ├── AccountTriggerHandler.cls
│ │ ├── ContactService.cls
│ │ └── IntegrationService.cls
│ ├── triggers/ # Apex triggers
│ │ └── AccountTrigger.trigger
│ ├── lwc/ # Lightning Web Components
│ │ └── accountList/
│ ├── objects/ # Custom object metadata
│ │ └── Integration_Log__c/
│ ├── permissionsets/
│ │ └── Integration_API_Access.permissionset-meta.xml
│ └── flows/ # Screen/record-triggered flows
├── scripts/apex/ # Anonymous Apex scripts
├── config/
│ └── project-scratch-def.json
└── sfdx-project.json
Integration Patterns
Pattern A: Polling-Based Sync
┌─────────────┐ SOQL Query ┌─────────────┐
│ Your App │ ──────────────────▶ │ Salesforce │
│ (cron job) │ SELECT ... WHERE │ Org │
│ │ ◀────────────────── │ │
│ │ JSON Records │ │
└─────────────┘ └─────────────┘
Pros: Simple, works with any edition
Cons: Latency (polling interval), wastes API calls on empty polls
Use: Small data volumes, non-real-time requirements