10+ Year Principal Architect & Developer Edition

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.

Author: Dhwani Akhilesh • Architect & CTA Level • Edition: 2026/2027 • 8 Comprehensive Technical Modules

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__c to the underlying physical column (e.g., maps "Invoice_Amount__c" to column val14 as 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.

// Production Example: Granting Read/Write to Project Member via Apex Managed Sharing public with sharing class ProjectSharingService { public static void grantProjectAccess(Id projectId, Id userId) { // Target the underlying Custom Object Share Table: ObjectName__Share Project__Share projShare = new Project__Share(); projShare.ParentId = projectId; // Record to be shared projShare.UserOrGroupId = userId; // User or Public Group receiving access projShare.AccessLevel = 'Edit'; // Read, Edit, or All // Custom Row Cause ensures record is NOT deleted when record owner changes! projShare.RowCause = Schema.Project__Share.RowCause.Project_Team_Member__c; Database.SaveResult sr = Database.insert(projShare, false); if (!sr.isSuccess()) { for (Database.Error err : sr.getErrors()) { System.debug(LoggingLevel.ERROR, 'Sharing error: ' + err.getMessage()); } } } }

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)

  1. Loads original record from database or initializes for an insert.
  2. Applies system validation rules (checks required fields, formats, max lengths).
  3. Executes Before Triggers (Apex).
  4. Runs system validation rules again (null checks, foreign key existence) and custom Validation Rules.
  5. Executes duplicate rules.
  6. Saves record to the database (not committed yet; temporary transaction savepoint).
  7. Executes After Triggers (Apex).
  8. Executes assignment rules (Lead / Case assignment).
  9. Executes auto-response rules.
  10. Executes workflow rules (if field updates fire, triggers and validations re-fire!).
  11. Executes escalation rules.
  12. Executes Salesforce Flows (Record-Triggered Flows).
  13. Executes Entitlement rules.
  14. Calculates parent Roll-Up Summary fields (which triggers Order of Execution on parent objects!).
  15. Calculates cross-object rollups and criteria evaluations.
  16. Executes criteria-based sharing rule evaluations.
  17. Commits all DML operations to the database.
  18. 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:

public class InvoiceServiceImpl { public static void generateInvoices(Set<Id> accountIds) { // 1. Initialize Unit of Work with topological dependency order fflib_SObjectUnitOfWork uow = new fflib_SObjectUnitOfWork( new List<SObjectType>{ Invoice__c.SObjectType, Invoice_Line_Item__c.SObjectType } ); // 2. Query data using the Selector Layer List<Account> accounts = AccountsSelector.newInstance().selectByIdWithActiveOrders(accountIds); for (Account acc : accounts) { Invoice__c inv = new Invoice__c(AccountId__c = acc.Id, Status__c = 'Draft'); // Register new parent record uow.registerNew(inv); for (Order ord : acc.Orders) { Invoice_Line_Item__c item = new Invoice_Line_Item__c(Amount__c = ord.TotalAmount); // Link child to parent record even before the parent has an Id! uow.registerNew(item, Invoice_Line_Item__c.Invoice__c, inv); } } // 3. Commit the entire transaction atomically with zero scattered DML statements uow.commitWork(); } }

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:

public class ResilientSyncQueueable implements Queueable, Database.AllowsCallouts { public void execute(QueueableContext ctx) { // Attach recovery handler System.attachFinalizer(new SyncQueueableFinalizer()); // External API sync logic that might timeout HttpCalloutService.syncLargeDataPayload(); } } public class SyncQueueableFinalizer implements Finalizer { public void execute(FinalizerContext ctx) { if (ctx.getResult() == ParentJobResult.UNHANDLED_EXCEPTION) { System.debug(LoggingLevel.ERROR, 'Queueable failed: ' + ctx.getException().getMessage()); // Automatically log error to custom Error_Log__c and notify on-call architect ErrorLogger.logException(ctx.getException(), ctx.getAsyncApexJobId()); } } }

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):

import { LightningElement, wire } from 'lwc'; import { publish, subscribe, MessageContext } from 'lightning/messageService'; import RECORD_CHANNEL from '@salesforce/messageChannel/RecordEventChannel__c'; export default class EnterpriseEventDispatcher extends LightningElement { @wire(MessageContext) messageContext; handleAccountSelection(accountId) { const payload = { recordId: accountId, timestamp: Date.now() }; // Broadcast message across the enterprise UI bus publish(this.messageContext, RECORD_CHANNEL, payload); } }

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 ReplayId within 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:

// JWT Header & Claim Set Structure { "iss": "3MVG9lAmndLNRm5Ek...", // Connected App Consumer Key "sub": "integration.user@company.com", // Salesforce Service Username "aud": "https://login.salesforce.com", "exp": 1716940800 // Unix timestamp validity (max 3 minutes) } // Sign with RSA Private Key (SHA256withRSA) and POST to /services/oauth2/token

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

# GitHub Actions Workflow: Pull Request Quality Gate name: Salesforce PR Validation on: pull_request: branches: [ main, develop ] jobs: validate-code: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # Required for sfdx-git-delta - name: Install Salesforce CLI & Delta Plugin run: | npm install --global @salesforce/cli echo y | sf plugins install sfdx-git-delta - name: Generate Incremental Metadata Delta run: sf sgd source delta --to "HEAD" --from "HEAD~1" --output "changed-sources" - name: Static Code Analysis (PMD) run: sf scanner run --target "changed-sources" --engine pmd --severity-threshold 2 - name: Check-Only Dry-Run Deployment with Full Test Execution run: | sf project deploy validate \ --manifest "changed-sources/package/package.xml" \ --test-level RunLocalTests \ --target-org CI_Sandbox

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!

public with sharing class InventoryAgentService { @InvocableMethod( label='Check Warehouse Stock and Reserve Items' description='Queries real-time ERP warehouse inventory for a given SKU. If stock is available, reserves the quantity for 30 minutes.' category='Supply Chain' ) public static List<ReservationResult> reserveInventory(List<ReservationRequest> requests) { List<ReservationResult> results = new List<ReservationResult>(); for (ReservationRequest req : requests) { ReservationResult res = new ReservationResult(); // Invocable logic interacting with inventory records or SAP microservices res.isReserved = true; res.confirmationCode = 'RES-' + Crypto.getRandomInteger(); results.add(res); } return results; } public class ReservationRequest { @InvocableVariable(required=true description='The unique product SKU code e.g. PROD-9982') public String productSku; @InvocableVariable(required=true description='Number of units to reserve') public Integer quantity; } public class ReservationResult { @InvocableVariable public Boolean isReserved; @InvocableVariable public String confirmationCode; } }

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:

  1. User Navigation: User visits https://company.my.salesforce.com.
  2. SAML Request: Salesforce detects MyDomain, generates a cryptographically signed SAML Request (XML), and redirects browser to Identity Provider (Okta / Azure AD / PingFederate).
  3. Authentication: IdP challenges user for MFA credentials.
  4. SAML Assertion: IdP generates an encrypted SAML Response containing the user's Federation ID.
  5. Posting Assertion: Browser POSTs SAML Assertion to Salesforce Assertion Consumer Service (ACS) URL.
  6. 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
Explore All Learning Paths