Salesforce Enterprise Masterclass
The definitive knowledge base for senior developers and technical architects. Covering Large Data Volumes (LDV), Apex Enterprise Patterns (fflib), Skinny Tables & Query Optimization, Security Governance, LWC Architecture, Enterprise Integrations, 2GP CI/CD DevOps, and the autonomous Agentforce AI Platform.
Formatted for offline study & printing
Module 1: Enterprise Multitenancy, Under-The-Hood Architecture & Large Data Volumes (LDV)
Foundations for Everyone: The Apartment Complex
Salesforce is a multi-tenant cloud where millions of companies share the same compute hardware and relational database infrastructure securely. Think of it as a luxury skyscraper: every tenant has their own private key, but all tenants share the same water lines and elevators. Governor limits exist so no single tenant starves the others of resources.
10-Year Architect Knowledge: Database Internals (Universal Container Architecture)
Salesforce does not create a new SQL database table when you create a Custom Object. The platform uses a patented metadata-driven relational database architecture with universal tables:
- MT_Data (The Universal Storage Table): All custom data rows across all tenants live in a giant partition table where columns are generically typed (
val0,val1, ...val500). - MT_Metadata (The Dictionary): Maps
Custom_Object__c.Custom_Field__cto the underlying physical column (e.g., maps "Invoice_Amount__c" to columnval14as Decimal). - Custom Index Tables: B-Tree indexes cannot be placed directly on generic varchar columns. Salesforce maintains dedicated indexing tables (
MT_Indexes) that store indexed custom field values for high-speed lookups. - Skinny Tables: For queries on objects with millions of rows, Salesforce Support can create a physical read-only table that combines frequently used standard and custom fields into a flat, indexable table, avoiding expensive multi-table joins.
Large Data Volumes (LDV) & Query Optimizer Mechanics
When tables grow past 5 million to 50 million records, standard SOQL queries will cause table scans and throw timeout exceptions if the Salesforce Query Optimizer cannot find a Selective Filter.
| Index Type | Standard Selectivity Threshold | Examples |
|---|---|---|
| Standard Indexed Fields | Filter must return < 30% of the first 1M records, and < 15% of records over 1M. Max 1M records. | Id, Name, OwnerId, CreatedDate, RecordTypeId, Master-Detail & Lookup relationship fields. |
| Custom Indexed Fields | Filter must return < 10% of the first 1M records, and < 5% of records over 1M. Max 333,333 records. | Fields marked as External ID or Unique (or indexed via Salesforce Support case). |
| Non-Indexable Queries (Table Scans!) | Index Bypassed | Leading wildcards (LIKE '%acme'), negative operators (!=, NOT IN), comparisons to null, and non-deterministic formula fields. |
Data Skew: The #1 Cause of Production Lock Timeouts
1. Account Data Skew
Occurs when a single parent Account has more than 10,000 child records (Contacts, Cases, Opportunities). Updating child records causes database row-level locking on the parent Account table, producing frequent UNABLE_TO_LOCK_ROW exceptions.
2. Ownership Data Skew
Occurs when a single user (e.g. an automated integration user) owns more than 10,000 records of an object. Changing that user's role or role hierarchy triggers full recalculation of sharing tables, freezing user access for hours.
3. Lookup Skew
Occurs when a huge volume of records look up to a single target record. During batch insertions, multiple concurrent threads attempt to acquire a lock on the target lookup record, triggering transaction rollbacks.
Module 2: Advanced Enterprise Security, Sharing Architecture & Execution Order
At a 10-year experience level, Salesforce security is not just about checking boxes in Setup. It involves understanding underlying share tables, implicit sharing, Shield encryption mechanics, and the complete 20-step Order of Execution.
1. Apex Managed Sharing & Custom Row Causes
When declarative sharing rules cannot satisfy complex dynamic security (e.g., project-based security with custom team allocations), architects implement Apex Managed Sharing.
2. Implicit Sharing (The Hidden Architectural Engine)
Parent Implicit Sharing
If a user has access to a child record (e.g. a Contact or Case), Salesforce automatically grants that user read access to the parent Account record, even if the Account OWD is strictly Private!
Child Implicit Sharing
If a user has access to a parent Account, this access can implicitly provide visibility to child records based on role hierarchy settings and account sharing rules.
3. Salesforce Shield Platform Encryption: Deterministic vs. Probabilistic
| Encryption Scheme | Ciphertext Output | Filtering & SOQL Capability | Architectural Trade-Off |
|---|---|---|---|
| Probabilistic Encryption | Randomized ciphertext generated using a unique initialization vector (IV) for every record. | Zero Search / Zero Filtering (Cannot use in WHERE clauses, indexes, or sort orders). |
Maximum cryptographic security. Best for raw SSNs, private medical diagnoses, and credit card pins. |
| Deterministic Encryption (Case-Sensitive / Case-Insensitive) | Consistent static ciphertext output for identical plaintexts using HMAC-SHA-256. | Supports Exact Match Queries (WHERE Email = 'user@company.com'). |
Allows SOQL filtering and indexing, but ciphertext patterns can theoretically be analyzed via frequency attacks. |
4. The Trigraph 20-Step Order of Execution (CTA Must-Know)
- Loads original record from database or initializes for an insert.
- Applies system validation rules (checks required fields, formats, max lengths).
- Executes Before Triggers (Apex).
- Runs system validation rules again (null checks, foreign key existence) and custom Validation Rules.
- Executes duplicate rules.
- Saves record to the database (not committed yet; temporary transaction savepoint).
- Executes After Triggers (Apex).
- Executes assignment rules (Lead / Case assignment).
- Executes auto-response rules.
- Executes workflow rules (if field updates fire, triggers and validations re-fire!).
- Executes escalation rules.
- Executes Salesforce Flows (Record-Triggered Flows).
- Executes Entitlement rules.
- Calculates parent Roll-Up Summary fields (which triggers Order of Execution on parent objects!).
- Calculates cross-object rollups and criteria evaluations.
- Executes criteria-based sharing rule evaluations.
- Commits all DML operations to the database.
- Executes post-commit operations: sending queued outbound emails, asynchronous jobs, and publishing Platform Events.
Module 3: Enterprise Apex Architecture & fflib Design Patterns
Senior Salesforce developers write enterprise-grade software using Separation of Concerns (SoC) based on Martin Fowler's enterprise application patterns, formalized in Salesforce through the open-source fflib framework.
1. The 4 Layers of Apex Enterprise Patterns
1. Domain Layer
Encapsulates object state, default value validation, cross-field integrity, and trigger routing. Extends fflib_SObjectDomain.
2. Selector Layer
Centralizes all SOQL queries into reusable query classes with field-level security checks (WITH USER_MODE) and query caching.
3. Service Layer
Defines transactional business operations and orchestration. Never contains direct inline DML or SOQL.
4. Unit of Work (UoW)
Manages transactions, registers inserts/updates/deletes, resolves parent-child foreign key dependencies, and commits in one atomic step.
2. Unit of Work (UoW) Implementation Pattern
Eliminate ad-hoc scattered DML. Register operations in memory and let the Unit of Work execute optimal, bulkified DML in correct topological dependency order:
3. Advanced Asynchronous Resilience: Queueable Finalizers
Introduced to solve the silent failure problem in asynchronous jobs. A Finalizer executes automatically when a Queueable job completes—whether it succeeds or crashes with an unhandled exception:
Module 4: Enterprise Lightning Web Components (LWC) Architecture
Enterprise frontend architecture on Salesforce requires mastering Light DOM vs. Shadow DOM, Lightning Web Security (LWS), dynamic imports, and complex cross-DOM message distribution.
1. Shadow DOM vs. Light DOM Architecture
Shadow DOM (Default Mode)
Provides strict CSS and DOM boundary encapsulation. External styles cannot bleed in, and document.querySelector cannot peek inside the component. Essential for self-contained UI widgets.
Light DOM (renderMode = 'light')
Renders elements directly into the host document without a shadow root. Allows third-party CSS libraries (Tailwind, Bootstrap) to style components directly and enables seamless DOM traversals for accessibility screen readers.
2. Lightning Locker vs. Lightning Web Security (LWS)
Salesforce migrated from the rigid Lightning Locker architecture to Lightning Web Security (LWS). LWS operates via fine-grained JavaScript sandboxing based on TC39 virtualization standards:
| Feature | Lightning Locker (Legacy) | Lightning Web Security (Modern LWS) |
|---|---|---|
| Cross-Namespace Component Access | Blocked completely. | Allowed via safe virtualized sandboxes. |
| Third-Party JavaScript Libraries | Strict limitations; libraries that mutate globals fail. | Full compatibility with modern npm modules (e.g. Chart.js, D3.js). |
| Execution Performance | Heavier overhead due to secure DOM wrappers. | Near native browser speed. |
3. Lightning Message Service (LMS) Multi-Window Bus
Publishes and subscribes to events across independent DOM hierarchies (Aura components, Visualforce iframes, LWC, and Utility Bar popups):
Module 5: Official Integration Patterns, Pub/Sub API & Zero-Storage Virtualization
Salesforce Integration Architecture follows the official patterns documented in Salesforce's Enterprise Integration Patterns Guide:
1. The 5 Core Integration Patterns
| Pattern | Timing | Best Implementation | Enterprise Use Case |
|---|---|---|---|
| Request and Reply | Synchronous | Apex REST/SOAP Callouts with Named Credentials | Credit card processing, instant address validation. |
| Fire and Forget | Asynchronous | High-Volume Platform Events | Sending closed deal notifications to downstream billing queues. |
| Batch Data Synchronization | Asynchronous | Bulk API 2.0 with PK Chunking | Nightly synchronization of 10M customer ledger rows from SAP. |
| Remote Call-In | Synchronous | OAuth 2.0 JWT Bearer Flow with REST Web Services | External mobile apps querying customer order status directly. |
| Data Virtualization | On-Demand | Salesforce Connect (External Objects / OData 4.0) | Viewing historical customer invoices in ERP with zero data storage in Salesforce! |
2. The Pub/Sub API (Next-Gen gRPC Event Streaming)
Legacy CometD streaming is replaced by the Salesforce Pub/Sub API. Built on HTTP/2 and gRPC with binary Apache Avro encoding, it delivers:
- Bi-directional streaming: Publish and subscribe using a single unified connection.
- Flow control: Clients pull events based on buffer capacity rather than being overwhelmed by event firehoses.
- Arbitrary replay: Replay past events from a specific
ReplayIdwithin a 72-hour retention window.
3. OAuth 2.0 JWT Bearer Token Flow (Headless Server-to-Server)
For enterprise automated batch integrations (ETL tools, MuleSoft, backend daemons), architects use the JWT Bearer Token Flow. It authenticates headless service accounts without human interaction or browser redirects:
Module 6: Second-Generation Packaging (2GP), Trunk DevOps & CI/CD Pipelines
Enterprise scale requires abandoning monolithic org deployments in favor of modular Second-Generation Packages (2GP), automated Scratch Org validation gates, and incremental delta deployments.
1. Second-Generation Packaging (2GP): Unlocked vs. Managed
| Package Type | Source Code Visibility | Versioning & Upgrades | Ideal Architectural Use Case |
|---|---|---|---|
| Unlocked Package (2GP) | Visible in subscriber org. | Modular semantic versioning (1.4.0.LATEST); clean dependency trees. |
Internal enterprise IT applications shared across internal sandboxes and production orgs. |
| Managed Package (2GP) | Obfuscated (Apex code hidden & IP protected). | Strict upgrade rules (cannot delete public fields or modify global methods). | AppExchange ISV Commercial Partners selling software solutions to external customers. |
2. The Enterprise CI/CD Pipeline Architecture
3. Enterprise Sandbox Governance Strategy
Developer Sandbox
200 MB storage. Day-to-day feature development. Refreshed daily.
Developer Pro Sandbox
1 GB storage. Ideal for integration testing, user QA, and packaging builds.
Partial Copy Sandbox
5 GB storage. Uses Sandbox Templates to sample representative business data.
Full Copy Sandbox
100% replica of production data. Refreshed every 29 days. Used for performance & UAT testing.
Module 7: Agentforce Autonomous AI, Atlas Reasoning Engine & Data Cloud
The Shift: From Copilots to Autonomous Enterprise Agents
First-generation enterprise AI (like Einstein Copilot or generic chatbots) required humans to prompt the system at every step. Agentforce is Salesforce's flagship autonomous agent platform. Agents act independently: they analyze intent, retrieve grounded corporate knowledge from Data Cloud, plan sequential actions, and invoke business logic across CRM and ERP systems 24/7 with zero human intervention required unless an escalation boundary is triggered.
1. The Atlas Reasoning Engine: The Cognitive Operating System
Rather than sending a raw prompt directly to an external LLM, Agentforce passes every interaction through the multi-stage Atlas Reasoning Engine:
1. Semantic Parse
Classifies customer intent into predefined business Topics and extracts key entities.
2. Data Cloud Grounding
Performs hybrid keyword + vector semantic search against Data Cloud data graphs and knowledge articles.
3. Dynamic Plan Generation
Atlas formulates a directed acyclic execution plan choosing between Flows, Apex, and API actions.
4. Trust Layer Guardrails
Enforces zero-retention policies, PII data de-identification, and strict toxicity filtering.
2. Architecting Invocable Apex Actions for Agentforce
Developers expose tools to agents using Apex classes annotated with @InvocableMethod.
Crucial Difference for AI: The description attribute on the method and variables is the prompt instructions that Atlas uses to decide when to call the action!
Module 8: Certified Technical Architect (CTA) System Design Scenarios
The Certified Technical Architect (CTA) Review Board is the pinnacle credential in enterprise cloud software. Here are core system design scenarios evaluated at the 10+ year architect level.
1. Single-Org vs. Multi-Org Strategy Evaluation
| Architectural Dimension | Single Global Org Strategy | Multi-Org Strategy (By Geo / Business Unit) |
|---|---|---|
| Global Visibility & Reporting | Unified 360 View (Single source of truth). | Requires Data Cloud or external BI data lakes to aggregate reports. |
| Governor Limits Risk | Shared Limits (Risk of API or batch exhaustion across regions). | Isolated limits per business unit; zero cross-org interference. |
| Regulatory Compliance (Data Residency) | Complex (Must use Salesforce Hyperforce with strict data residency zones). | Natural Compliance (EU Org for GDPR, China Org for CSL). |
| Release Management Complexity | High regression risk across globally shared metadata. | Faster release velocity per team; independent deployment cadences. |
2. Enterprise Single Sign-On (SSO) with SAML 2.0
Architects must know the complete 6-step handshake for Service Provider (SP)-Initiated SAML 2.0 SSO:
- User Navigation: User visits
https://company.my.salesforce.com. - SAML Request: Salesforce detects MyDomain, generates a cryptographically signed SAML Request (XML), and redirects browser to Identity Provider (Okta / Azure AD / PingFederate).
- Authentication: IdP challenges user for MFA credentials.
- SAML Assertion: IdP generates an encrypted SAML Response containing the user's Federation ID.
- Posting Assertion: Browser POSTs SAML Assertion to Salesforce Assertion Consumer Service (ACS) URL.
- Validation & JIT: Salesforce validates the X.509 certificate signature, maps the Federation ID, executes optional Just-In-Time (JIT) User Provisioning via
Auth.SamlJitHandler, and issues a session cookie.
3. Certification Progression Matrix (Associate to CTA)
Application Architect Track
- Platform Developer I (PDI)
- Platform App Builder
- Data Architecture and Management Designer
- Sharing and Visibility Designer
System Architect Track
- Platform Developer I (PDI)
- Development Lifecycle and Deployment Designer
- Integration Architecture Designer
- Identity and Access Management Designer