Getting Started with AT4DX

AT4DX stands for Advanced Techniques for Salesforce DX. It is a framework built on top of fflib (fflib-apex-common and fflib-apex-mocks) and force-di that solves a specific problem: how do you build multiple Salesforce applications as a set of independently deployable packages when those packages need to share objects, queries, and business logic?

The Problem It Solves

When multiple teams work on the same Salesforce org using classic org-based development, they collide constantly. A Marketing team adding a field to Account has to coordinate with whoever owns shared queries. A Service team adding a query modifies the same selector as Sales. These collisions slow teams down and make independent deployment difficult.

Second-Generation Packaging (2GP) and Salesforce DX unlocked packages require explicit dependency direction. Sales can deliberately depend on Org Common, but it should not construct Org Common classes or force Org Common to depend back on Sales schema.

AT4DX solves this with metadata-driven dependency injection. Instead of new AccountsSelector(), application code calls AccountsSelector.newInstance(), a typed wrapper over Application.Selector.newInstance(Account.SObjectType). The framework reads custom metadata to construct the one Account selector. Downstream fields, query methods, and domain behavior are injected without creating app-specific selector or domain subclasses.

Why Dependency Injection Matters

Dependency injection has three concrete benefits in this context:

Controlled package dependencies: Sales depends downward on Org Common and only on the purpose-scoped Business Common packages it participates in, such as sales-marketing-common or sales-service-common. Marketing and Service do not inherit each other's unrelated dependencies.

Testability: When you write new AccountsSelector() inside a method, you cannot swap it in a test. When production code uses AccountsSelector.newInstance(), a test can call Application.Selector.setMock(...) to inject controlled data.

Extensibility without modification: A downstream package declares a fieldset on Account and registers it in SelectorConfig_FieldSetInclusion__mdt. Every existing query that goes through Application.Selector automatically includes those fields — no changes to any existing selector class.

What You Should Already Know

This documentation assumes you are familiar with enterprise application patterns, as implemented by fflib:

If those terms are unfamiliar, work through the Trailhead modules Apex Enterprise Patterns: Domain & Selector Layers and Apex Enterprise Patterns: Service Layer first, or review the fflib-apex-common documentation. AT4DX extends these patterns rather than replacing them.

How This Documentation Flows

The documents are sequential and build on each other:

The Reference page is a quick-lookup companion for all metadata types, key classes, and common errors.

The examples span a single org shared by Sales, Marketing, and Service applications — each adding its own fields, queries, and domain behavior to shared objects like Account and Case without colliding.