
Sf Diagram Mermaid
- 1.3k installs
- 423 repo stars
- Updated April 27, 2026
- jaganpro/sf-skills
sf-diagram-mermaid is a skill for Salesforce architecture diagrams in Mermaid with ASCII fallback.
About
The sf-diagram-mermaid skill produces Salesforce architecture diagrams using Mermaid syntax with ASCII fallback when rendering is unavailable. It triggers on diagram, visualize, ERD, or sequence requests for Salesforce systems. Use when developers document Salesforce org architecture, integrations, or data models in version-controlled diagram formats.
- Mermaid diagrams for Salesforce architecture with ASCII fallback.
- Triggers on diagram, visualize, ERD, and sequence keywords.
- Salesforce-specific architecture documentation focus.
- Version-control friendly text diagram output.
- Supports ERD and sequence style Salesforce views.
Sf Diagram Mermaid by the numbers
- 1,308 all-time installs (skills.sh)
- +5 installs in the week ending Aug 5, 2026 (Skillselion tracking)
- Ranked #221 of 1,879 Documentation skills by installs in the Skillselion catalog
- Security screen: MEDIUM risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
sf-diagram-mermaid capabilities & compatibility
- Capabilities
- mermaid salesforce architecture diagrams · ascii fallback rendering · erd and sequence diagram triggers · salesforce specific visualization patterns
- Use cases
- documentation · orchestration
What sf-diagram-mermaid says it does
Salesforce architecture diagrams using Mermaid with ASCII fallback.
npx skills add https://github.com/jaganpro/sf-skills --skill sf-diagram-mermaidAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1.3k |
|---|---|
| repo stars | ★ 423 |
| Security audit | 3 / 3 scanners passed |
| Last updated | April 27, 2026 |
| Repository | jaganpro/sf-skills ↗ |
How do I diagram Salesforce architecture, ERDs, or sequences in Mermaid?
Draw Salesforce architecture diagrams with Mermaid and ASCII fallback for ERD and sequence views.
Who is it for?
Developers documenting Salesforce org architecture and integrations.
Skip if: Skip for non-Salesforce system diagrams without sf context.
When should I use this skill?
User asks to diagram or visualize Salesforce architecture, ERD, or sequences.
What you get
Mermaid or ASCII Salesforce architecture diagrams ready for docs or repos.
- mermaid flowchart source
- agent architecture diagram
- conversation flow visualization
By the numbers
- Default Mermaid init sets nodeSpacing 80 and rankSpacing 70
- Template covers agent description, topics subgraph, and action nodes
Files
sf-diagram-mermaid: Salesforce Diagram Generation
Use this skill when the user needs text-based diagrams: Mermaid diagrams for architecture, OAuth, integration flows, ERDs, or Agentforce structure, plus ASCII fallback when plain-text compatibility matters.
When This Skill Owns the Task
Use sf-diagram-mermaid when the user wants:
- Mermaid output
- ASCII fallback diagrams
- architecture, sequence, flowchart, or ERD views in markdown-friendly form
- diagrams that can live directly in docs, READMEs, or issues
Delegate elsewhere when the user wants:
- rendered PNG/SVG images or polished mockups → sf-diagram-nanobananapro
- non-Salesforce systems only → use a more general diagramming skill
- object discovery before an ERD → sf-metadata
---
Supported Diagram Families
| Type | Preferred Mermaid form | Typical use |
|---|---|---|
| OAuth / auth flows | sequenceDiagram | Authorization Code, JWT, PKCE, Device Flow |
| ERD / data model | flowchart LR | object relationships and sharing context |
| integration sequence | sequenceDiagram | request/response or event choreography |
| system landscape | flowchart | high-level architecture |
| role / access hierarchy | flowchart | users, profiles, permissions |
| Agentforce behavior map | flowchart | agent → topic → action relationships |
---
Required Context to Gather First
Ask for or infer:
- diagram type
- scope and entities / systems involved
- output preference: Mermaid only, ASCII only, or both
- whether styling should be minimal, documentation-first, or presentation-friendly
- for ERDs: whether org metadata is available for grounding
---
Recommended Workflow
1. Pick the right diagram structure
- use
sequenceDiagramfor time-ordered interactions - use
flowchart LRfor ERDs and capability maps - keep a single primary story per diagram when possible
2. Gather data
For ERDs and grounded diagrams:
- use sf-metadata when real schema discovery is needed
- optionally use the local metadata helper script for counts / relationship context when appropriate
3. Generate Mermaid first
Apply:
- accurate labels
- simple readable node text
- consistent relationship notation
- restrained styling that renders cleanly in markdown viewers
4. Add ASCII fallback when useful
Provide an ASCII version when the user wants terminal compatibility or plaintext documentation.
5. Explain the diagram briefly
Call out the key relationships, flow direction, and any assumptions.
---
High-Signal Rules
For sequence diagrams
- use
autonumberwhen step order matters - distinguish requests vs responses clearly
- use notes sparingly for protocol detail
For ERDs
- prefer
flowchart LR - keep object cards simple
- use clear relationship arrows
- avoid field overload unless the user explicitly asks for field-level detail
- color-code object types only when it improves readability
For ASCII output
- keep width reasonable
- align arrows and boxes consistently
- optimize for readability over decoration
---
Output Format
````markdown
<Diagram Title>
Mermaid Diagram
<diagram>ASCII Fallback
<ascii>Notes
- <key point>
- <assumption or limitation>
````
---
Cross-Skill Integration
| Need | Delegate to | Reason |
|---|---|---|
| real object / field definitions | sf-metadata | grounded ERD generation |
| rendered diagram / image output | sf-diagram-nanobananapro | visual polish beyond Mermaid |
| connected-app auth setup context | sf-connected-apps | accurate OAuth flows |
| Agentforce logic visualization | sf-ai-agentscript | source-of-truth behavior details |
| Flow behavior diagrams | sf-flow | actual Flow logic grounding |
---
Reference Map
Start here
- references/diagram-conventions.md
- references/mermaid-reference.md
- references/usage-examples.md
Styling / ERD specifics
- references/mermaid-styling.md
- references/color-palette.md
- references/erd-conventions.md
Preview
- references/preview-guide.md
- scripts/mermaid_preview.py
- scripts/query-org-metadata.py
---
Score Guide
| Score | Meaning |
|---|---|
| 72–80 | production-ready diagram |
| 60–71 | clear and useful with minor polish left |
| 48–59 | functional but could be clearer |
| 35–47 | needs structural improvement |
| < 35 | inaccurate or incomplete |
Agentforce Flow Diagram Template
Flowchart template for visualizing Agentforce agent architecture and conversation flows.
When to Use
- Documenting Agentforce agent structure
- Planning agent topics and actions
- Visualizing conversation flows
- Architecture reviews
Mermaid Template - Agent Structure
%%{init: {"flowchart": {"nodeSpacing": 80, "rankSpacing": 70}} }%%
flowchart TB
subgraph agent["🤖 SERVICE AGENT"]
direction TB
DESC[/"Agent Description:<br/>AI-powered customer service<br/>assistant for order management"/]
subgraph topics["📋 TOPICS"]
direction LR
T1[Order Status]
T2[Return Request]
T3[Product Info]
T4[Escalation]
end
subgraph instructions["📝 INSTRUCTIONS"]
I1[Greet professionally]
I2[Verify customer identity]
I3[Use knowledge base first]
I4[Escalate if frustrated]
end
end
subgraph topic_order["📦 TOPIC: ORDER STATUS"]
direction TB
TO_DESC[/"Help customers check<br/>order and shipping status"/]
TO_SCOPE[Scope: Order tracking,<br/>delivery estimates]
subgraph to_actions["ACTIONS"]
TO_A1[Get Order Details<br/>⚡ Apex]
TO_A2[Check Shipping<br/>🔄 Flow]
end
end
subgraph topic_return["🔄 TOPIC: RETURN REQUEST"]
direction TB
TR_DESC[/"Process return and<br/>refund requests"/]
TR_SCOPE[Scope: Returns, refunds,<br/>exchanges]
subgraph tr_actions["ACTIONS"]
TR_A1[Create Case<br/>🔄 Flow]
TR_A2[Generate Label<br/>⚡ Apex]
TR_A3[Process Refund<br/>⚡ Apex]
end
end
%% Connections
T1 --> topic_order
T2 --> topic_return
TO_A1 --> ORDER_SVC[Order Service]
TO_A2 --> SHIP_API[Shipping API]
TR_A1 --> CASE_OBJ[(Case Object)]
TR_A2 --> SHIP_API
TR_A3 --> PAY_API[Payment API]
%% Node Styling - Topics (violet-200)
style T1 fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
style T2 fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
style T3 fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
style T4 fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
%% Node Styling - Actions (emerald-200)
style TO_A1 fill:#a7f3d0,stroke:#047857,color:#1f2937
style TO_A2 fill:#a7f3d0,stroke:#047857,color:#1f2937
style TR_A1 fill:#a7f3d0,stroke:#047857,color:#1f2937
style TR_A2 fill:#a7f3d0,stroke:#047857,color:#1f2937
style TR_A3 fill:#a7f3d0,stroke:#047857,color:#1f2937
%% Node Styling - External (orange-200)
style ORDER_SVC fill:#fed7aa,stroke:#c2410c,color:#1f2937
style SHIP_API fill:#fed7aa,stroke:#c2410c,color:#1f2937
style PAY_API fill:#fed7aa,stroke:#c2410c,color:#1f2937
style CASE_OBJ fill:#fde68a,stroke:#b45309,color:#1f2937
%% Node Styling - Descriptions (slate-200)
style DESC fill:#e2e8f0,stroke:#334155,color:#1f2937
style TO_DESC fill:#e2e8f0,stroke:#334155,color:#1f2937
style TO_SCOPE fill:#e2e8f0,stroke:#334155,color:#1f2937
style TR_DESC fill:#e2e8f0,stroke:#334155,color:#1f2937
style TR_SCOPE fill:#e2e8f0,stroke:#334155,color:#1f2937
style I1 fill:#e2e8f0,stroke:#334155,color:#1f2937
style I2 fill:#e2e8f0,stroke:#334155,color:#1f2937
style I3 fill:#e2e8f0,stroke:#334155,color:#1f2937
style I4 fill:#e2e8f0,stroke:#334155,color:#1f2937
%% Subgraph Styling - 50-level fills with dashed borders
style agent fill:#fdf2f8,stroke:#be185d,stroke-dasharray:5
style topics fill:#f5f3ff,stroke:#6d28d9,stroke-dasharray:5
style instructions fill:#f8fafc,stroke:#334155,stroke-dasharray:5
style topic_order fill:#f5f3ff,stroke:#6d28d9,stroke-dasharray:5
style to_actions fill:#ecfdf5,stroke:#047857,stroke-dasharray:5
style topic_return fill:#f5f3ff,stroke:#6d28d9,stroke-dasharray:5
style tr_actions fill:#ecfdf5,stroke:#047857,stroke-dasharray:5Mermaid Template - Conversation Flow
%%{init: {"flowchart": {"nodeSpacing": 80, "rankSpacing": 70}} }%%
flowchart TD
START([🟢 Conversation Start])
START --> GREET[Greet Customer]
GREET --> CLASSIFY{Classify Intent}
CLASSIFY -->|Order Related| ORDER_TOPIC
CLASSIFY -->|Return Related| RETURN_TOPIC
CLASSIFY -->|General Question| KB_SEARCH
CLASSIFY -->|Unknown| CLARIFY
subgraph ORDER_TOPIC["📦 ORDER STATUS TOPIC"]
ORD_1[Ask for Order Number]
ORD_2[Retrieve Order Details<br/>⚡ GetOrderDetails Action]
ORD_3{Order Found?}
ORD_4[Display Status]
ORD_5[Offer Additional Help]
ORD_1 --> ORD_2 --> ORD_3
ORD_3 -->|Yes| ORD_4 --> ORD_5
ORD_3 -->|No| ORD_1
end
subgraph RETURN_TOPIC["🔄 RETURN REQUEST TOPIC"]
RET_1[Verify Order Eligible]
RET_2{Eligible for Return?}
RET_3[Create Return Case<br/>🔄 CreateReturnCase Action]
RET_4[Generate Return Label<br/>⚡ GenerateLabel Action]
RET_5[Provide Instructions]
RET_6[Explain Policy]
RET_1 --> RET_2
RET_2 -->|Yes| RET_3 --> RET_4 --> RET_5
RET_2 -->|No| RET_6
end
KB_SEARCH[Search Knowledge Base<br/>📚 Knowledge Action]
KB_SEARCH --> KB_RESULT{Found Answer?}
KB_RESULT -->|Yes| PROVIDE_ANSWER[Provide Answer]
KB_RESULT -->|No| ESCALATE
CLARIFY[Ask Clarifying Question]
CLARIFY --> CLASSIFY
ESCALATE[Escalate to Human<br/>👤 Transfer Action]
ORD_5 --> SATISFIED{Customer Satisfied?}
RET_5 --> SATISFIED
PROVIDE_ANSWER --> SATISFIED
SATISFIED -->|Yes| END_SUCCESS([🟢 End - Resolved])
SATISFIED -->|No| ESCALATE
ESCALATE --> END_TRANSFER([🟡 End - Transferred])
%% Node Styling - Start/End (emerald-200)
style START fill:#a7f3d0,stroke:#047857,color:#1f2937
style END_SUCCESS fill:#a7f3d0,stroke:#047857,color:#1f2937
style END_TRANSFER fill:#fde68a,stroke:#b45309,color:#1f2937
%% Node Styling - Decisions (violet-200)
style CLASSIFY fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
style ORD_3 fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
style RET_2 fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
style KB_RESULT fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
style SATISFIED fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
%% Node Styling - Actions (cyan-200)
style GREET fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style ORD_1 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style ORD_2 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style ORD_4 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style ORD_5 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style RET_1 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style RET_3 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style RET_4 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style RET_5 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style RET_6 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style KB_SEARCH fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style PROVIDE_ANSWER fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style CLARIFY fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style ESCALATE fill:#fed7aa,stroke:#c2410c,color:#1f2937
%% Subgraph Styling - 50-level fills with dashed borders
style ORDER_TOPIC fill:#f5f3ff,stroke:#6d28d9,stroke-dasharray:5
style RETURN_TOPIC fill:#f5f3ff,stroke:#6d28d9,stroke-dasharray:5ASCII Fallback Template
┌─────────────────────────────────────────────────────────────────────────────┐
│ 🤖 SERVICE AGENT STRUCTURE │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────┐
│ AGENT: Customer Service Bot │
│ ───────────────────────────── │
│ Description: AI-powered assistant for order and return inquiries │
│ │
│ Instructions: │
│ • Greet customers professionally │
│ • Verify identity before sharing order details │
│ • Search knowledge base before escalating │
│ • Escalate if customer expresses frustration │
└─────────────────────────────────────────────────────────────────────────────┘
│
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ 📋 TOPICS │
│ ┌───────────────────┐ ┌───────────────────┐ ┌───────────────────┐ │
│ │ 📦 Order Status │ │ 🔄 Return Request │ │ ❓ General Help │ │
│ │ │ │ │ │ │ │
│ │ Scope: │ │ Scope: │ │ Scope: │ │
│ │ - Track orders │ │ - Process return │ │ - FAQ answers │ │
│ │ - Delivery ETA │ │ - Generate label │ │ - Knowledge base │ │
│ │ - Order history │ │ - Refund status │ │ - Escalation │ │
│ └─────────┬─────────┘ └─────────┬─────────┘ └─────────┬─────────┘ │
└────────────│──────────────────────│──────────────────────│──────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ ⚡ ACTIONS │
│ ┌───────────────────┐ ┌───────────────────┐ ┌───────────────────┐ │
│ │ GetOrderDetails │ │ CreateReturnCase │ │ SearchKnowledge │ │
│ │ [Apex Invocable] │ │ [Flow] │ │ [Standard Action] │ │
│ ├───────────────────┤ ├───────────────────┤ ├───────────────────┤ │
│ │ Input: │ │ Input: │ │ Input: │ │
│ │ - orderNumber │ │ - orderId │ │ - query │ │
│ │ - customerId │ │ - reason │ │ - language │ │
│ │ │ │ - quantity │ │ │ │
│ │ Output: │ │ Output: │ │ Output: │ │
│ │ - status │ │ - caseId │ │ - articles[] │ │
│ │ - items[] │ │ - returnLabel │ │ - confidence │ │
│ │ - trackingUrl │ │ - instructions │ │ │ │
│ └───────────────────┘ └───────────────────┘ └───────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ 🔗 INTEGRATIONS │
│ ┌───────────────────┐ ┌───────────────────┐ ┌───────────────────┐ │
│ │ Order Service │ │ Shipping API │ │ Knowledge Base │ │
│ │ (Salesforce) │ │ (FedEx/UPS) │ │ (Salesforce) │ │
│ └───────────────────┘ └───────────────────┘ └───────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘Agent Components
| Component | Description | Example |
|---|---|---|
| Agent | The AI assistant container | Service Agent, SDR Agent |
| Topic | Conversation category | Order Status, Returns |
| Action | Executable capability | Apex method, Flow |
| Instruction | Behavioral guideline | "Always verify identity" |
| Scope | Topic boundaries | What's in/out of scope |
Action Types
| Type | Icon | Use Case |
|---|---|---|
| Apex Invocable | ⚡ | Complex logic, callouts |
| Flow | 🔄 | Record creation, updates |
| Standard | 📚 | Knowledge search, case creation |
| Prompt Template | 💬 | Dynamic response generation |
Conversation Flow Patterns
1. Linear Flow
Start → Topic → Action → Response → End2. Branching Flow
Start → Classify → [Topic A | Topic B | Escalate]3. Loop Back
Start → Topic → Action → Validate → [Success | Retry]Best Practices
1. Clear topic boundaries - Don't overlap scope 2. Minimal actions per topic - 3-5 max 3. Always have escalation path - Human handoff 4. Use knowledge base first - Before custom actions 5. Verify before acting - Confirm understanding
Customization Points
- Replace example topics with actual use cases
- Add specific action inputs/outputs
- Include actual integration endpoints
- Show conversation sample flows
System Landscape Diagram Template
Flowchart template for visualizing high-level Salesforce system architecture using the sf-skills standard styling.
When to Use
- Architecture overview presentations
- Integration landscape documentation
- System inventory
- Stakeholder communication
Mermaid Template - Sales Cloud Integration Landscape
%%{init: {"flowchart": {"nodeSpacing": 80, "rankSpacing": 70}} }%%
flowchart TB
subgraph users["👥 USERS"]
direction LR
U1["📱 Sales Reps<br/><small>Mobile App</small>"]
U2["💻 Managers<br/><small>Desktop</small>"]
U3["🌐 Partners<br/><small>Portal</small>"]
end
subgraph salesforce["☁️ SALESFORCE PLATFORM"]
direction TB
subgraph core["CORE CRM"]
SF1["💼 Sales Cloud<br/><small>Leads, Opps</small>"]
SF2["🎧 Service Cloud<br/><small>Cases, Knowledge</small>"]
SF3["🌐 Experience Cloud<br/><small>Portals</small>"]
end
subgraph automation["⚡ AUTOMATION"]
FL["🔄 Flows<br/><small>Process Builder</small>"]
AP["⚡ Apex<br/><small>Triggers, Services</small>"]
PE["📢 Platform Events<br/><small>CDC, Streaming</small>"]
end
subgraph ai["🤖 AI & ANALYTICS"]
EIN["🧠 Einstein<br/><small>Predictions</small>"]
TB["📊 Tableau<br/><small>Dashboards</small>"]
CRM["📈 CRM Analytics<br/><small>Reports</small>"]
end
end
subgraph integration["🔄 INTEGRATION LAYER"]
direction LR
MW["🔗 MuleSoft<br/><small>Anypoint Platform</small>"]
API["🔐 API Gateway<br/><small>Named Credentials</small>"]
end
subgraph external["🏢 EXTERNAL SYSTEMS"]
direction TB
subgraph erp["ERP SYSTEMS"]
SAP["🏭 SAP S/4HANA<br/><small>Finance, Inventory</small>"]
NET["📦 NetSuite<br/><small>Orders</small>"]
end
subgraph marketing["MARKETING"]
MC["📧 Marketing Cloud<br/><small>Campaigns</small>"]
PAR["🎯 Account Engagement<br/><small>Pardot</small>"]
end
subgraph data["DATA & STORAGE"]
DW["❄️ Snowflake<br/><small>Data Warehouse</small>"]
S3["☁️ AWS S3<br/><small>Files</small>"]
end
end
%% User connections
U1 -->|"Salesforce Mobile"| SF1
U2 -->|"Lightning"| SF1
U2 -->|"Lightning"| SF2
U3 -->|"Portal"| SF3
%% Internal SF connections
SF1 <--> FL
SF2 <--> FL
FL <--> AP
AP <--> PE
SF1 --> EIN
SF1 --> TB
SF2 --> CRM
%% Integration connections
PE --> MW
AP <--> API
MW <--> API
%% External connections
API <-->|"REST/SOAP"| SAP
API <-->|"REST"| NET
MW <-->|"CDC"| MC
MW --> PAR
MW -->|"ETL"| DW
API -->|"Files"| S3
%% Node Styling - Users (violet-200)
style U1 fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
style U2 fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
style U3 fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
%% Node Styling - Salesforce Core (cyan-200)
style SF1 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style SF2 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style SF3 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
%% Node Styling - Automation (indigo-200/violet-200/teal-200)
style FL fill:#c7d2fe,stroke:#4338ca,color:#1f2937
style AP fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
style PE fill:#99f6e4,stroke:#0f766e,color:#1f2937
%% Node Styling - AI (pink-200)
style EIN fill:#fbcfe8,stroke:#be185d,color:#1f2937
style TB fill:#fbcfe8,stroke:#be185d,color:#1f2937
style CRM fill:#fbcfe8,stroke:#be185d,color:#1f2937
%% Node Styling - Integration (orange-200)
style MW fill:#fed7aa,stroke:#c2410c,color:#1f2937
style API fill:#fed7aa,stroke:#c2410c,color:#1f2937
%% Node Styling - External (emerald-200/amber-200)
style SAP fill:#a7f3d0,stroke:#047857,color:#1f2937
style NET fill:#a7f3d0,stroke:#047857,color:#1f2937
style MC fill:#a7f3d0,stroke:#047857,color:#1f2937
style PAR fill:#a7f3d0,stroke:#047857,color:#1f2937
style DW fill:#fde68a,stroke:#b45309,color:#1f2937
style S3 fill:#fde68a,stroke:#b45309,color:#1f2937
%% Subgraph Styling - 50-level fills with dark dashed borders
style users fill:#f5f3ff,stroke:#6d28d9,stroke-dasharray:5
style salesforce fill:#ecfeff,stroke:#0e7490,stroke-dasharray:5
style core fill:#ecfeff,stroke:#0e7490,stroke-dasharray:5
style automation fill:#eef2ff,stroke:#4338ca,stroke-dasharray:5
style ai fill:#fdf2f8,stroke:#be185d,stroke-dasharray:5
style integration fill:#fff7ed,stroke:#c2410c,stroke-dasharray:5
style external fill:#ecfdf5,stroke:#047857,stroke-dasharray:5
style erp fill:#ecfdf5,stroke:#047857,stroke-dasharray:5
style marketing fill:#ecfdf5,stroke:#047857,stroke-dasharray:5
style data fill:#fffbeb,stroke:#b45309,stroke-dasharray:5Mermaid Template - Agentforce Architecture
%%{init: {"flowchart": {"nodeSpacing": 80, "rankSpacing": 70}} }%%
flowchart TB
subgraph channels["📱 CHANNELS"]
WEB["🌐 Web Chat<br/><small>Embedded</small>"]
SMS["💬 SMS<br/><small>Twilio</small>"]
WHATS["📱 WhatsApp<br/><small>Business</small>"]
SLACK["💼 Slack<br/><small>Enterprise</small>"]
end
subgraph agentforce["🤖 AGENTFORCE"]
direction TB
subgraph agents["AI AGENTS"]
SA["🎧 Service Agent<br/><small>Customer Support</small>"]
SDA["📞 SDR Agent<br/><small>Lead Qualification</small>"]
COACH["🎯 Sales Coach<br/><small>Guidance</small>"]
end
subgraph topics["TOPICS & ACTIONS"]
T1["📦 Order Status<br/><small>Track, Update</small>"]
T2["🔄 Return Request<br/><small>RMA, Refund</small>"]
T3["✅ Lead Qualify<br/><small>Score, Route</small>"]
A1["⚡ Apex Actions<br/><small>Custom Logic</small>"]
A2["🔄 Flow Actions<br/><small>Automation</small>"]
end
subgraph foundation["FOUNDATION"]
DM["☁️ Data Cloud<br/><small>Unified Profile</small>"]
TRUST["🔐 Trust Layer<br/><small>Guardrails</small>"]
PROMPT["📝 Prompt Builder<br/><small>Templates</small>"]
end
end
subgraph backend["⚙️ BACKEND"]
APEX["⚡ Apex Services<br/><small>Business Logic</small>"]
FLOW["🔄 Flow Orchestration<br/><small>Processes</small>"]
INT["🔗 Integrations<br/><small>Named Creds</small>"]
end
subgraph datasources["💾 DATA SOURCES"]
CRM[("💼 CRM Data<br/><small>Accounts, Cases</small>")]
EXT[("🏭 External Data<br/><small>ERP, APIs</small>")]
KB[("📚 Knowledge Base<br/><small>Articles</small>")]
end
%% Channel to Agent
WEB --> SA
SMS --> SA
WHATS --> SA
SLACK --> SDA
SLACK --> COACH
%% Agent to Topics
SA --> T1
SA --> T2
SDA --> T3
%% Topics to Actions
T1 --> A1
T2 --> A2
T3 --> A1
%% Foundation connections
agents --> DM
agents --> TRUST
topics --> PROMPT
%% Backend connections
A1 --> APEX
A2 --> FLOW
APEX --> INT
%% Data connections
DM --> CRM
DM --> EXT
TRUST --> KB
%% Node Styling - Channels (slate-200)
style WEB fill:#e2e8f0,stroke:#334155,color:#1f2937
style SMS fill:#e2e8f0,stroke:#334155,color:#1f2937
style WHATS fill:#e2e8f0,stroke:#334155,color:#1f2937
style SLACK fill:#e2e8f0,stroke:#334155,color:#1f2937
%% Node Styling - Agents (pink-200)
style SA fill:#fbcfe8,stroke:#be185d,color:#1f2937
style SDA fill:#fbcfe8,stroke:#be185d,color:#1f2937
style COACH fill:#fbcfe8,stroke:#be185d,color:#1f2937
%% Node Styling - Topics (violet-200)
style T1 fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
style T2 fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
style T3 fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
%% Node Styling - Actions (indigo-200)
style A1 fill:#c7d2fe,stroke:#4338ca,color:#1f2937
style A2 fill:#c7d2fe,stroke:#4338ca,color:#1f2937
%% Node Styling - Foundation (teal-200)
style DM fill:#99f6e4,stroke:#0f766e,color:#1f2937
style TRUST fill:#99f6e4,stroke:#0f766e,color:#1f2937
style PROMPT fill:#99f6e4,stroke:#0f766e,color:#1f2937
%% Node Styling - Backend (cyan-200/orange-200)
style APEX fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style FLOW fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style INT fill:#fed7aa,stroke:#c2410c,color:#1f2937
%% Node Styling - Data (amber-200)
style CRM fill:#fde68a,stroke:#b45309,color:#1f2937
style EXT fill:#fde68a,stroke:#b45309,color:#1f2937
style KB fill:#fde68a,stroke:#b45309,color:#1f2937
%% Subgraph Styling - 50-level fills with dark dashed borders
style channels fill:#f8fafc,stroke:#334155,stroke-dasharray:5
style agentforce fill:#fdf2f8,stroke:#be185d,stroke-dasharray:5
style agents fill:#fdf2f8,stroke:#be185d,stroke-dasharray:5
style topics fill:#f5f3ff,stroke:#6d28d9,stroke-dasharray:5
style foundation fill:#f0fdfa,stroke:#0f766e,stroke-dasharray:5
style backend fill:#ecfeff,stroke:#0e7490,stroke-dasharray:5
style datasources fill:#fffbeb,stroke:#b45309,stroke-dasharray:5ASCII Fallback Template
┌─────────────────────────────────────────────────────────────────────────────┐
│ SYSTEM LANDSCAPE │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────┐
│ 👥 USERS │
│ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │
│ │ Sales Reps │ │ Managers │ │ Partners │ │
│ │ (Mobile) │ │ (Desktop) │ │ (Portal) │ │
│ └───────┬───────┘ └───────┬───────┘ └───────┬───────┘ │
└──────────│──────────────────│──────────────────│────────────────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ ☁️ SALESFORCE PLATFORM │
│ ┌───────────────────────────────────────────────────────────────────────┐ │
│ │ CORE CRM │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ Sales Cloud │ │Service Cloud│ │ Experience │ │ │
│ │ │ │ │ │ │ Cloud │ │ │
│ │ └──────┬──────┘ └──────┬──────┘ └─────────────┘ │ │
│ └─────────│────────────────│────────────────────────────────────────────┘ │
│ │ │ │
│ ┌─────────▼────────────────▼────────────────────────────────────────────┐ │
│ │ AUTOMATION │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ Flows │──│ Apex │──│ Platform │ │ │
│ │ │ │ │ │ │ Events │ │ │
│ │ └─────────────┘ └──────┬──────┘ └──────┬──────┘ │ │
│ └──────────────────────────│────────────────│───────────────────────────┘ │
└─────────────────────────────│────────────────│──────────────────────────────┘
│ │
▼ ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ 🔄 INTEGRATION LAYER │
│ ┌─────────────────────────┐ ┌─────────────────────────┐ │
│ │ MuleSoft │ │ API Gateway │ │
│ │ Anypoint │──│ │ │
│ └───────────┬─────────────┘ └───────────┬─────────────┘ │
└──────────────│────────────────────────────│─────────────────────────────────┘
│ │
▼ ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ 🏢 EXTERNAL SYSTEMS │
│ ┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐ │
│ │ ERP │ │ Marketing │ │ Data Storage │ │
│ │ ┌───────┬───────┐ │ │ ┌───────┬───────┐ │ │ ┌───────┬───────┐ │ │
│ │ │ SAP │NetSuit│ │ │ │ MC │Pardot │ │ │ │Snowflk│ S3 │ │ │
│ │ └───────┴───────┘ │ │ └───────┴───────┘ │ │ └───────┴───────┘ │ │
│ └─────────────────────┘ └─────────────────────┘ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘Component Types (Tailwind 200-level)
| Category | Examples | Icon | Fill (200) | Stroke (700+) |
|---|---|---|---|---|
| Users | Sales, Service, Partners | 👥 | #ddd6fe | #6d28d9 |
| Salesforce Clouds | Sales, Service, Marketing | ☁️ | #a5f3fc | #0e7490 |
| Automation | Flow, Apex, Events | ⚡ | #c7d2fe | #4338ca |
| AI/Analytics | Einstein, Tableau, CRM Analytics | 🤖 | #fbcfe8 | #be185d |
| Integration | MuleSoft, API Gateway | 🔗 | #fed7aa | #c2410c |
| External Systems | ERP, Marketing, Data | 🏢 | #a7f3d0 | #047857 |
| Storage | Database, Data Lake, Files | 💾 | #fde68a | #b45309 |
Connection Types
| Pattern | Description | Arrow |
|---|---|---|
| Sync Request/Response | REST API call | <--> |
| Async (Event-based) | Platform Events, CDC | --> |
| Batch/ETL | Scheduled data load | --> (dashed) |
| Real-time streaming | CometD, Pub/Sub | ==> |
Customization Points
- Replace example systems with actual integrations
- Add or remove clouds based on implementation
- Include specific API names and versions
- Show data flow direction and volumes
B2B Commerce Data Model Template
Pre-built data model for Salesforce B2B Commerce using flowchart LR format with color coding and relationship indicators.
Objects Included
| Object | Type | Description |
|---|---|---|
| WebStore | STD | Online storefront |
| WebCart | STD | Shopping cart |
| CartItem | STD | Cart products |
| BuyerGroup | STD | Customer groups |
| BuyerAccount | STD | B2B customers |
| ProductCatalog | STD | Product catalog |
| CommerceEntitlementPolicy | STD | Access policies |
| CartCheckoutSession | STD | Checkout process |
---
Query Org Metadata (Recommended)
Enrich diagram with live org data:
python3 ~/.claude/skills/sf-diagram-mermaid/scripts/query-org-metadata.py \
--objects WebStore,WebCart,CartItem,BuyerGroup,BuyerAccount \
--target-org myorg---
Mermaid Template (Preferred)
Left-to-right flowchart with color coding.
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
%% ═══════════════════════════════════════════════════════════════
%% B2B COMMERCE DATA MODEL
%% LEGEND: LK = Lookup (-->), MD = Master-Detail (==>)
%% Colors: Blue = Standard, Orange = Custom, Green = External
%% ═══════════════════════════════════════════════════════════════
%% Store Structure
WebStore["WebStore<br/>(count)"]
ProductCatalog["ProductCatalog<br/>(count)"]
Product2["Product2<br/>(count)"]
%% Buyer Structure
BuyerGroup["BuyerGroup<br/>(count)"]
BuyerAccount["BuyerAccount<br/>(count)"]
BuyerGroupMember["BuyerGroupMember<br/>(count)"]
Account["Account<br/>(count)"]
%% Cart Structure
WebCart["WebCart<br/>(count)"]
CartItem["CartItem<br/>(count)"]
CartCheckout["CartCheckoutSession<br/>(count)"]
%% Entitlements
CEPolicy["CommerceEntitlementPolicy<br/>(count)"]
CEProduct["CommerceEntitlementProduct<br/>(count)"]
CEBuyerGroup["CommerceEntitlementBuyerGroup<br/>(count)"]
%% Store to Products
WebStore -->|"LK"| ProductCatalog
ProductCatalog ==>|"MD"| Product2
%% Buyer Structure
BuyerGroup ==>|"MD"| BuyerGroupMember
Account -->|"LK"| BuyerAccount
WebStore -->|"LK"| BuyerAccount
BuyerAccount -->|"LK"| BuyerGroupMember
%% Cart
WebStore -->|"LK"| WebCart
Account -->|"LK"| WebCart
WebCart ==>|"MD"| CartItem
Product2 -->|"LK"| CartItem
WebCart -->|"LK"| CartCheckout
%% Entitlements
CEPolicy ==>|"MD"| CEProduct
CEPolicy ==>|"MD"| CEBuyerGroup
Product2 -->|"LK"| CEProduct
BuyerGroup -->|"LK"| CEBuyerGroup
%% Standard Objects - Sky Blue
style WebStore fill:#bae6fd,stroke:#0369a1,color:#1f2937
style ProductCatalog fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Product2 fill:#bae6fd,stroke:#0369a1,color:#1f2937
style BuyerGroup fill:#bae6fd,stroke:#0369a1,color:#1f2937
style BuyerAccount fill:#bae6fd,stroke:#0369a1,color:#1f2937
style BuyerGroupMember fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Account fill:#bae6fd,stroke:#0369a1,color:#1f2937
style WebCart fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CartItem fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CartCheckout fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CEPolicy fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CEProduct fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CEBuyerGroup fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Key Concepts
B2B Commerce Flow
WebStore → ProductCatalog → Product2
↓ ↓
BuyerAccount → WebCart → CartItem → Order
↓
BuyerGroup → Entitlements (What they can see/buy)Buyer vs Account
| Object | Purpose |
|---|---|
| Account | Standard CRM account |
| BuyerAccount | Commerce-enabled account |
| BuyerGroup | Pricing/entitlement grouping |
Entitlement Model
CommerceEntitlementPolicy
├── CommerceEntitlementProduct (What products)
└── CommerceEntitlementBuyerGroup (Who can see)Controls which products each BuyerGroup can view and purchase.
Cart States
| Status | Description |
|---|---|
| Active | Current shopping cart |
| Checkout | In checkout process |
| Closed | Converted to Order |
| Abandoned | Inactive cart |
---
Simplified Version (Core Objects Only)
For presentations focusing on core commerce flow:
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
WebStore["WebStore"]
BuyerAccount["BuyerAccount"]
WebCart["WebCart"]
Order["Order"]
WebStore -->|"hosts"| BuyerAccount
BuyerAccount -->|"LK"| WebCart
WebCart -.->|"converts"| Order
style WebStore fill:#bae6fd,stroke:#0369a1,color:#1f2937
style BuyerAccount fill:#bae6fd,stroke:#0369a1,color:#1f2937
style WebCart fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Order fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Pricing Model
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
BuyerGroup["BuyerGroup"]
Pricebook2["Pricebook2"]
PBE["PricebookEntry"]
Product2["Product2"]
WebStorePB["WebStorePricebook"]
WebStore["WebStore"]
BuyerGroup -->|"LK"| Pricebook2
Pricebook2 ==>|"MD"| PBE
Product2 -->|"LK"| PBE
WebStore ==>|"MD"| WebStorePB
Pricebook2 -->|"LK"| WebStorePB
style BuyerGroup fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Pricebook2 fill:#bae6fd,stroke:#0369a1,color:#1f2937
style PBE fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Product2 fill:#bae6fd,stroke:#0369a1,color:#1f2937
style WebStorePB fill:#bae6fd,stroke:#0369a1,color:#1f2937
style WebStore fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Cart to Order Conversion
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
WebCart["WebCart"]
CartItem["CartItem"]
CartCheckout["CartCheckoutSession"]
Order["Order"]
OrderItem["OrderItem"]
OrderSummary["OrderSummary"]
WebCart ==>|"MD"| CartItem
WebCart -->|"LK"| CartCheckout
CartCheckout -.->|"creates"| Order
Order ==>|"MD"| OrderItem
Order -->|"LK"| OrderSummary
style WebCart fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CartItem fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CartCheckout fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Order fill:#bae6fd,stroke:#0369a1,color:#1f2937
style OrderItem fill:#bae6fd,stroke:#0369a1,color:#1f2937
style OrderSummary fill:#bae6fd,stroke:#0369a1,color:#1f2937---
ASCII Fallback
┌─────────────────────────────────────────────────────────────────────────────┐
│ B2B COMMERCE DATA MODEL (L→R) │
│ Legend: LK = Lookup (-->), MD = Master-Detail (==>) │
└─────────────────────────────────────────────────────────────────────────────┘
STORE & PRODUCTS
┌──────────────┐ ┌──────────────────┐ ┌──────────────┐
│ WEBSTORE │── LK ──>│ PRODUCT_CATALOG │═══ MD ═>│ PRODUCT2 │
│ (count) │ │ (count) │ │ (count) │
└──────┬───────┘ └──────────────────┘ └──────────────┘
│
│ BUYERS
│
│ LK ┌──────────────────┐ ┌──────────────┐
└────────────────>│ BUYER_ACCOUNT │◄── LK ──│ ACCOUNT │
│ (count) │ │ (count) │
└────────┬─────────┘ └──────────────┘
│
│ LK
▼
┌──────────────────┐
│ BUYER_GROUP_ │◄══ MD ══┌──────────────┐
│ MEMBER (count) │ │ BUYER_GROUP │
└──────────────────┘ │ (count) │
└──────────────┘
CART
┌──────────────┐ ┌──────────────────┐ ┌──────────────┐
│ WEBSTORE │── LK ──>│ WEBCART │═══ MD ═>│ CART_ITEM │
│ │ │ (count) │ │ (count) │
└──────────────┘ └────────┬─────────┘ └──────────────┘
│
│ LK
▼
┌──────────────────┐ converts ┌──────────────┐
│CART_CHECKOUT_ │·········>│ ORDER │
│SESSION (count) │ │ (count) │
└──────────────────┘ └──────────────┘---
Key Relationships Summary
| Parent | Child | Type | Behavior |
|---|---|---|---|
| WebStore | ProductCatalog | LK | Store products |
| WebStore | BuyerAccount | LK | Store customers |
| WebStore | WebCart | LK | Shopping carts |
| ProductCatalog | Product2 | MD | Catalog products |
| BuyerGroup | BuyerGroupMember | MD | Group members |
| Account | BuyerAccount | LK | Commerce enablement |
| WebCart | CartItem | MD | Cart products |
| WebCart | CartCheckoutSession | LK | Checkout |
| CommerceEntitlementPolicy | CommerceEntitlementProduct | MD | Product access |
| CommerceEntitlementPolicy | CommerceEntitlementBuyerGroup | MD | Group access |
---
Limits & Considerations
| Limit | Value |
|---|---|
| Products per store | Unlimited (LDV) |
| Buyer accounts per store | Unlimited |
| Cart items per cart | 500 |
| Active carts per buyer | 1 |
| Price books per buyer group | Multiple |
| Entitlement policies | Unlimited |
---
B2B vs B2C Commerce
| Feature | B2B Commerce | B2C Commerce |
|---|---|---|
| Customer | Business (Account) | Consumer (Contact) |
| Pricing | Contract/negotiated | List price |
| Catalog | Entitlement-based | Public |
| Checkout | Quote/approval | Immediate |
| Platform | LWR/Aura | LWR/Headless |
---
Best Practices
1. Use `flowchart LR` - Left-to-right flow for readability 2. Keep objects simple - Name + record count only 3. Replace `(count)` placeholders - With actual counts from query 4. Add LDV indicator - For objects >2M records: LDV[~4M] 5. Color code object types - Blue=Standard, Orange=Custom, Green=External
Campaigns Data Model Template
Pre-built data model for Salesforce Campaigns using flowchart LR format with color coding and relationship indicators.
Objects Included
| Object | Type | Description |
|---|---|---|
| Campaign | STD | Marketing campaigns |
| CampaignMember | STD | Campaign responses (Lead/Contact) |
| CampaignMemberStatus | STD | Status values per campaign |
| CampaignInfluence | STD | Attribution to opportunities |
| Lead | STD | Potential customers |
| Contact | STD | Existing contacts |
| Opportunity | STD | Influenced deals |
---
Query Org Metadata (Recommended)
Enrich diagram with live org data:
python3 ~/.claude/skills/sf-diagram-mermaid/scripts/query-org-metadata.py \
--objects Campaign,CampaignMember,CampaignInfluence,Lead,Contact,Opportunity \
--target-org myorg---
Mermaid Template (Preferred)
Left-to-right flowchart with color coding.
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
%% ═══════════════════════════════════════════════════════════════
%% CAMPAIGNS DATA MODEL
%% LEGEND: LK = Lookup (-->), MD = Master-Detail (==>)
%% Colors: Blue = Standard, Orange = Custom, Green = External
%% ═══════════════════════════════════════════════════════════════
%% Core Campaign Objects
Campaign["Campaign<br/>(count)"]
CampaignMember["CampaignMember<br/>(count)"]
CampaignMemberStatus["CampaignMemberStatus<br/>(count)"]
%% Attribution
CampaignInfluence["CampaignInfluence<br/>(count)"]
%% Related Objects
Lead["Lead<br/>(count)"]
Contact["Contact<br/>(count)"]
Opportunity["Opportunity<br/>(count)"]
%% Relationships - Campaign to Members
Campaign ==>|"MD"| CampaignMember
Campaign ==>|"MD"| CampaignMemberStatus
Lead -->|"LK"| CampaignMember
Contact -->|"LK"| CampaignMember
%% Relationships - Attribution
Campaign -->|"LK"| CampaignInfluence
Contact -->|"LK"| CampaignInfluence
Opportunity -->|"LK"| CampaignInfluence
%% Campaign Hierarchy
Campaign -.->|"Parent"| Campaign
%% Primary Campaign Source
Campaign -->|"LK"| Opportunity
%% Standard Objects - Sky Blue
style Campaign fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CampaignMember fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CampaignMemberStatus fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CampaignInfluence fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Lead fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Contact fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Opportunity fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Key Concepts
Campaign Hierarchy
- Campaigns support Parent Campaign self-lookup
- Enables rollup reporting across campaign groups
- Max hierarchy depth: 5 levels
CampaignMember Polymorphism
- CampaignMember links to either Lead OR Contact (not both)
- Uses
LeadIdorContactIdlookup fields - Status tracked via CampaignMemberStatus
Campaign Influence Models
| Model | Description |
|---|---|
| Primary Campaign Source | First-touch attribution (Opportunity.CampaignId) |
| Campaign Influence 1.0 | Manual influence records |
| Customizable Campaign Influence | Multi-touch with weighted attribution |
---
Simplified Version (Core Objects Only)
For presentations focusing on core campaign flow:
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
Campaign["Campaign"]
CampaignMember["CampaignMember"]
Lead["Lead"]
Contact["Contact"]
Campaign ==>|"MD"| CampaignMember
Lead -->|"LK"| CampaignMember
Contact -->|"LK"| CampaignMember
style Campaign fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CampaignMember fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Lead fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Contact fill:#bae6fd,stroke:#0369a1,color:#1f2937---
ASCII Fallback
┌─────────────────────────────────────────────────────────────────────────────┐
│ CAMPAIGNS DATA MODEL (L→R) │
│ Legend: LK = Lookup (-->), MD = Master-Detail (==>) │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────┐
┌───>│ CAMPAIGN_MEMBER │<─── LK ──┬──────────────┐
│ MD │ (count) │ │ │
│ └─────────────────────┘ │ │
┌──────────────┐ │ ┌────┴─────┐ ┌────┴─────┐
│ CAMPAIGN │─────────┤ │ LEAD │ │ CONTACT │
│ (count) │ │ ┌─────────────────────┐ │ (count) │ │ (count) │
└──────┬───────┘ └───>│ CAMPAIGN_MEMBER_ │ └──────────┘ └────┬─────┘
│ MD │ STATUS (count) │ │
│ Parent └─────────────────────┘ │
▼ │
┌──────────────┐ ┌─────────────────────┐ │
│ CAMPAIGN │── LK ───────>│ CAMPAIGN_INFLUENCE │<──── LK ────────────────┤
│ (parent) │ │ (count) │ │
└──────────────┘ └──────────┬──────────┘ │
│ │
│ LK │
▼ │
┌─────────────────────┐ │
│ OPPORTUNITY │ │
│ (count) │ │
└─────────────────────┘---
Key Relationships Summary
| Parent | Child | Type | Behavior |
|---|---|---|---|
| Campaign | CampaignMember | MD | Cascade delete |
| Campaign | CampaignMemberStatus | MD | Cascade delete |
| Lead | CampaignMember | LK | Optional (polymorphic) |
| Contact | CampaignMember | LK | Optional (polymorphic) |
| Campaign | CampaignInfluence | LK | Attribution link |
| Campaign | Opportunity | LK | Primary Campaign Source |
| Campaign | Campaign | LK | Parent Campaign (hierarchy) |
---
Limits & Considerations
| Limit | Value |
|---|---|
| Campaign hierarchy depth | 5 levels |
| CampaignMembers per campaign | No hard limit (LDV consideration) |
| CampaignInfluence records | Depends on attribution model |
---
Best Practices
1. Use `flowchart LR` - Left-to-right flow for readability 2. Keep objects simple - Name + record count only 3. Replace `(count)` placeholders - With actual counts from query 4. Add LDV indicator - For objects >2M records: LDV[~4M] 5. Color code object types - Blue=Standard, Orange=Custom, Green=External
Consent Data Model Template
Pre-built data model for Salesforce Consent Management (GDPR/Privacy) using flowchart LR format with color coding and relationship indicators.
Objects Included
| Object | Type | Description |
|---|---|---|
| Individual | STD | Privacy identity |
| Contact | STD | Contact record |
| Lead | STD | Lead record |
| ContactPointEmail | STD | Email contact points |
| ContactPointPhone | STD | Phone contact points |
| ContactPointAddress | STD | Address contact points |
| DataUsePurpose | STD | Purpose definitions |
| ContactPointConsent | STD | Consent per contact point |
| CommSubscription | STD | Communication subscriptions |
| CommSubscriptionConsent | STD | Subscription consent |
---
Query Org Metadata (Recommended)
Enrich diagram with live org data:
python3 ~/.claude/skills/sf-diagram-mermaid/scripts/query-org-metadata.py \
--objects Individual,ContactPointEmail,ContactPointPhone,DataUsePurpose,ContactPointConsent \
--target-org myorg---
Mermaid Template (Preferred)
Left-to-right flowchart with color coding.
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
%% ═══════════════════════════════════════════════════════════════
%% CONSENT DATA MODEL (GDPR/PRIVACY)
%% LEGEND: LK = Lookup (-->), MD = Master-Detail (==>)
%% Colors: Blue = Standard, Orange = Custom, Green = External
%% ═══════════════════════════════════════════════════════════════
%% Party Objects
Individual["Individual<br/>(count)"]
Contact["Contact<br/>(count)"]
Lead["Lead<br/>(count)"]
%% Contact Points
CPEmail["ContactPointEmail<br/>(count)"]
CPPhone["ContactPointPhone<br/>(count)"]
CPAddress["ContactPointAddress<br/>(count)"]
%% Consent Objects
DataUsePurpose["DataUsePurpose<br/>(count)"]
CPConsent["ContactPointConsent<br/>(count)"]
%% Subscriptions
CommSub["CommSubscription<br/>(count)"]
CommSubConsent["CommSubscriptionConsent<br/>(count)"]
%% Individual Links
Individual -->|"LK"| Contact
Individual -->|"LK"| Lead
%% Contact Points to Party
Individual ==>|"MD"| CPEmail
Individual ==>|"MD"| CPPhone
Individual ==>|"MD"| CPAddress
%% Consent
CPEmail -->|"LK"| CPConsent
CPPhone -->|"LK"| CPConsent
DataUsePurpose -->|"LK"| CPConsent
%% Subscriptions
CommSub ==>|"MD"| CommSubConsent
Contact -->|"LK"| CommSubConsent
%% Standard Objects - Sky Blue
style Individual fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Contact fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Lead fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CPEmail fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CPPhone fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CPAddress fill:#bae6fd,stroke:#0369a1,color:#1f2937
style DataUsePurpose fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CPConsent fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CommSub fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CommSubConsent fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Key Concepts
Individual Object
- Privacy identity that links to Contact/Lead/User
- Required for consent tracking
- Can be auto-created when Contact/Lead created
- Stores global privacy preferences
Contact Points
| Object | Purpose |
|---|---|
| ContactPointEmail | Email addresses |
| ContactPointPhone | Phone numbers |
| ContactPointAddress | Physical addresses |
| ContactPointSocialHandle | Social media IDs |
Each contact point links to an Individual.
Consent Model
DataUsePurpose → ContactPointConsent ← ContactPoint
(e.g., Marketing) (Opt-In/Out) (Email/Phone)Consent Values
| Value | Meaning |
|---|---|
| OptIn | Consent given |
| OptOut | Consent withdrawn |
| Seen | Notice displayed |
| NotSeen | Notice not yet shown |
---
Simplified Version (Core Objects Only)
For presentations focusing on core consent flow:
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
Individual["Individual"]
CPEmail["ContactPointEmail"]
DataUsePurpose["DataUsePurpose"]
CPConsent["ContactPointConsent"]
Individual ==>|"MD"| CPEmail
CPEmail -->|"LK"| CPConsent
DataUsePurpose -->|"LK"| CPConsent
style Individual fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CPEmail fill:#bae6fd,stroke:#0369a1,color:#1f2937
style DataUsePurpose fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CPConsent fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Communication Subscriptions Model
For email preference centers:
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
Contact["Contact"]
CommSub["CommSubscription<br/>(Newsletter)"]
CommSubConsent["CommSubscriptionConsent"]
CommChannel["CommSubscriptionChannel"]
CommSub ==>|"MD"| CommSubConsent
Contact -->|"LK"| CommSubConsent
CommSub ==>|"MD"| CommChannel
style Contact fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CommSub fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CommSubConsent fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CommChannel fill:#bae6fd,stroke:#0369a1,color:#1f2937---
ASCII Fallback
┌─────────────────────────────────────────────────────────────────────────────┐
│ CONSENT DATA MODEL (GDPR/PRIVACY) (L→R) │
│ Legend: LK = Lookup (-->), MD = Master-Detail (==>) │
└─────────────────────────────────────────────────────────────────────────────┘
┌──────────────┐
│ INDIVIDUAL │─────── LK ──────┬──────────────────────────────────┐
│ (count) │ │ │
└──────┬───────┘ ▼ ▼
│ ┌──────────────┐ ┌──────────────┐
│ │ CONTACT │ │ LEAD │
│ │ (count) │ │ (count) │
│ └──────────────┘ └──────────────┘
│
├═══ MD ═══>┌────────────────────┐
│ │ CONTACT_POINT_EMAIL│─── LK ──>┌────────────────────┐
│ │ (count) │ │CONTACT_POINT_ │
│ └────────────────────┘ │ CONSENT │
│ │ (count) │
├═══ MD ═══>┌────────────────────┐ └─────────┬──────────┘
│ │ CONTACT_POINT_PHONE│─── LK ───────────>│
│ │ (count) │ │
│ └────────────────────┘ │
│ │ LK
└═══ MD ═══>┌────────────────────┐ │
│CONTACT_POINT_ADDR │ ┌────────┴───────────┐
│ (count) │ │ DATA_USE_PURPOSE │
└────────────────────┘ │ (count) │
└────────────────────┘---
Key Relationships Summary
| Parent | Child | Type | Behavior |
|---|---|---|---|
| Individual | Contact | LK | Privacy identity |
| Individual | Lead | LK | Privacy identity |
| Individual | ContactPointEmail | MD | Cascade delete |
| Individual | ContactPointPhone | MD | Cascade delete |
| Individual | ContactPointAddress | MD | Cascade delete |
| ContactPointEmail | ContactPointConsent | LK | Email consent |
| ContactPointPhone | ContactPointConsent | LK | Phone consent |
| DataUsePurpose | ContactPointConsent | LK | Purpose reference |
| CommSubscription | CommSubscriptionConsent | MD | Cascade delete |
| Contact | CommSubscriptionConsent | LK | Subscriber |
---
GDPR Compliance Considerations
| Right | Implementation |
|---|---|
| Right to Access | Query Individual + Contact Points |
| Right to Rectification | Update Contact Points |
| Right to Erasure | Delete Individual (cascades) |
| Right to Restrict | Set ConsentCaptureSource |
| Right to Object | ContactPointConsent = OptOut |
---
Limits & Considerations
| Limit | Value |
|---|---|
| Contact Points per Individual | Unlimited |
| Data Use Purposes | Unlimited |
| Consent records | LDV consideration |
| Audit trail retention | Configurable |
---
Best Practices
1. Use `flowchart LR` - Left-to-right flow for readability 2. Keep objects simple - Name + record count only 3. Replace `(count)` placeholders - With actual counts from query 4. Add LDV indicator - For objects >2M records: LDV[~4M] 5. Color code object types - Blue=Standard, Orange=Custom, Green=External
Salesforce Files Data Model Template
Pre-built data model for Salesforce Files (Content) using flowchart LR format with color coding and relationship indicators.
Objects Included
| Object | Type | Description |
|---|---|---|
| ContentDocument | STD | File container |
| ContentVersion | STD | File versions |
| ContentDocumentLink | STD | Links files to records |
| ContentWorkspace | STD | Content libraries |
| ContentWorkspaceDoc | STD | Library membership |
| ContentFolder | STD | Folder structure |
| ContentAsset | STD | Asset files |
---
Query Org Metadata (Recommended)
Enrich diagram with live org data:
python3 ~/.claude/skills/sf-diagram-mermaid/scripts/query-org-metadata.py \
--objects ContentDocument,ContentVersion,ContentDocumentLink,ContentWorkspace \
--target-org myorg---
Mermaid Template (Preferred)
Left-to-right flowchart with color coding.
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
%% ═══════════════════════════════════════════════════════════════
%% SALESFORCE FILES DATA MODEL
%% LEGEND: LK = Lookup (-->), MD = Master-Detail (==>)
%% Colors: Blue = Standard, Orange = Custom, Green = External
%% ═══════════════════════════════════════════════════════════════
%% Core Content Objects
ContentDoc["ContentDocument<br/>(count)"]
ContentVer["ContentVersion<br/>(count)"]
CDLink["ContentDocumentLink<br/>(count)"]
%% Library Objects
Library["ContentWorkspace<br/>(count)"]
LibDoc["ContentWorkspaceDoc<br/>(count)"]
Folder["ContentFolder<br/>(count)"]
%% Asset
Asset["ContentAsset<br/>(count)"]
%% Any Salesforce Record
Record["Any Record<br/>(Account, Case, etc.)"]
%% Content Structure
ContentDoc ==>|"MD"| ContentVer
ContentDoc -->|"LK"| CDLink
Record -->|"LinkedEntityId"| CDLink
%% Library Structure
Library ==>|"MD"| LibDoc
ContentDoc -->|"LK"| LibDoc
Library ==>|"MD"| Folder
%% Asset
ContentDoc -->|"LK"| Asset
%% Standard Objects - Sky Blue
style ContentDoc fill:#bae6fd,stroke:#0369a1,color:#1f2937
style ContentVer fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CDLink fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Library fill:#bae6fd,stroke:#0369a1,color:#1f2937
style LibDoc fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Folder fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Asset fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Record fill:#ddd6fe,stroke:#6d28d9,color:#1f2937---
Key Concepts
Content Architecture
ContentDocument (Container)
├── ContentVersion (Current + History)
├── ContentDocumentLink (Sharing to Records)
└── ContentWorkspaceDoc (Library Membership)ContentDocument vs ContentVersion
| Object | Purpose |
|---|---|
| ContentDocument | File metadata container (one per file) |
| ContentVersion | Actual file data + versions |
Key: Always query ContentVersion for file data. ContentDocument is just the container.
ContentDocumentLink (CDL)
- Links ContentDocument to any Salesforce record
LinkedEntityIdis polymorphic (Account, Case, User, etc.)- Controls visibility/sharing
| ShareType | Visibility |
|---|---|
| V | Viewer |
| C | Collaborator |
| I | Inferred |
File Visibility
| Visibility | Access |
|---|---|
| AllUsers | All internal users |
| InternalUsers | Users with record access |
| SharedUsers | Explicitly shared users |
---
Simplified Version (Core Objects Only)
For presentations focusing on core file structure:
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
ContentDoc["ContentDocument"]
ContentVer["ContentVersion"]
CDLink["ContentDocumentLink"]
Record["Any Record"]
ContentDoc ==>|"MD"| ContentVer
ContentDoc -->|"LK"| CDLink
Record -->|"LinkedEntityId"| CDLink
style ContentDoc fill:#bae6fd,stroke:#0369a1,color:#1f2937
style ContentVer fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CDLink fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Record fill:#ddd6fe,stroke:#6d28d9,color:#1f2937---
Content Libraries Model
For file library organization:
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
Library["ContentWorkspace<br/>(Library)"]
LibDoc["ContentWorkspaceDoc"]
Folder["ContentFolder"]
ContentDoc["ContentDocument"]
Member["ContentWorkspaceMember"]
User["User"]
Library ==>|"MD"| LibDoc
Library ==>|"MD"| Folder
Library ==>|"MD"| Member
ContentDoc -->|"LK"| LibDoc
User -->|"LK"| Member
style Library fill:#bae6fd,stroke:#0369a1,color:#1f2937
style LibDoc fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Folder fill:#bae6fd,stroke:#0369a1,color:#1f2937
style ContentDoc fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Member fill:#bae6fd,stroke:#0369a1,color:#1f2937
style User fill:#bae6fd,stroke:#0369a1,color:#1f2937---
ASCII Fallback
┌─────────────────────────────────────────────────────────────────────────────┐
│ SALESFORCE FILES DATA MODEL (L→R) │
│ Legend: LK = Lookup (-->), MD = Master-Detail (==>) │
└─────────────────────────────────────────────────────────────────────────────┘
FILE STRUCTURE
┌──────────────────┐ ┌──────────────────┐
│ CONTENT_DOCUMENT │═══ MD ═>│ CONTENT_VERSION │
│ (count) │ │ (count) │
└────────┬─────────┘ └──────────────────┘
│
│ LK
▼
┌──────────────────────┐ ┌──────────────────┐
│CONTENT_DOCUMENT_LINK │<── LK ──│ ANY RECORD │
│ (count) │ │ (Account, Case) │
└──────────────────────┘ └──────────────────┘
LIBRARY STRUCTURE
┌──────────────────┐ ┌──────────────────────┐
│ CONTENT_WORKSPACE│═══ MD ═>│CONTENT_WORKSPACE_DOC │
│ (Library) │ │ (count) │
└────────┬─────────┘ └──────────┬───────────┘
│ │
│ MD │ LK
▼ ▼
┌──────────────────┐ ┌──────────────────────┐
│ CONTENT_FOLDER │ │ CONTENT_DOCUMENT │
│ (count) │ │ (count) │
└──────────────────┘ └──────────────────────┘---
Key Relationships Summary
| Parent | Child | Type | Behavior |
|---|---|---|---|
| ContentDocument | ContentVersion | MD | Cascade delete |
| ContentDocument | ContentDocumentLink | LK | Sharing links |
| ContentWorkspace | ContentWorkspaceDoc | MD | Library files |
| ContentWorkspace | ContentFolder | MD | Library folders |
| ContentWorkspace | ContentWorkspaceMember | MD | Library members |
| ContentDocument | ContentWorkspaceDoc | LK | File in library |
| ContentDocument | ContentAsset | LK | Asset reference |
---
Limits & Considerations
| Limit | Value |
|---|---|
| File size | 2 GB (max) |
| Versions per file | 20 (default, configurable) |
| Libraries per org | Varies by edition |
| CDL per file | No hard limit (LDV) |
| Files storage | Org storage limit |
---
Common Queries
Files attached to a record
SELECT ContentDocumentId, ContentDocument.Title
FROM ContentDocumentLink
WHERE LinkedEntityId = '001xxx'Latest version of a file
SELECT Id, Title, VersionData
FROM ContentVersion
WHERE ContentDocumentId = '069xxx'
AND IsLatest = true---
Best Practices
1. Use `flowchart LR` - Left-to-right flow for readability 2. Keep objects simple - Name + record count only 3. Replace `(count)` placeholders - With actual counts from query 4. Add LDV indicator - For objects >2M records: LDV[~4M] 5. Color code object types - Blue=Standard, Orange=Custom, Green=External
Forecasting Data Model Template
Pre-built data model for Salesforce Collaborative Forecasts using flowchart LR format with color coding and relationship indicators.
Objects Included
| Object | Type | Description |
|---|---|---|
| ForecastingType | STD | Forecast configuration |
| ForecastingItem | STD | Individual forecasts |
| ForecastingQuota | STD | User quotas |
| ForecastingAdjustment | STD | Manager adjustments |
| Opportunity | STD | Source opportunities |
| OpportunitySplit | STD | Revenue splits |
| User | STD | Forecast owners |
---
Query Org Metadata (Recommended)
Enrich diagram with live org data:
python3 ~/.claude/skills/sf-diagram-mermaid/scripts/query-org-metadata.py \
--objects ForecastingItem,ForecastingQuota,Opportunity,OpportunitySplit \
--target-org myorg---
Mermaid Template (Preferred)
Left-to-right flowchart with color coding.
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
%% ═══════════════════════════════════════════════════════════════
%% COLLABORATIVE FORECASTS DATA MODEL
%% LEGEND: LK = Lookup (-->), MD = Master-Detail (==>)
%% Colors: Blue = Standard, Orange = Custom, Green = External
%% ═══════════════════════════════════════════════════════════════
%% Forecast Configuration
FType["ForecastingType<br/>(count)"]
%% Forecast Data
FItem["ForecastingItem<br/>(count)"]
FQuota["ForecastingQuota<br/>(count)"]
FAdjust["ForecastingAdjustment<br/>(count)"]
%% Source Objects
Opportunity["Opportunity<br/>(count)"]
OppSplit["OpportunitySplit<br/>(count)"]
%% Users
User["User<br/>(count)"]
%% Period
Period["Period<br/>(count)"]
%% Forecast Type Configuration
FType -->|"LK"| FItem
FType -->|"LK"| FQuota
%% Forecast Items
User -->|"LK"| FItem
Period -->|"LK"| FItem
Opportunity -->|"LK"| FItem
%% Quotas
User -->|"LK"| FQuota
Period -->|"LK"| FQuota
%% Adjustments
FItem -->|"LK"| FAdjust
User -->|"adjusts"| FAdjust
%% Opportunity Splits
Opportunity ==>|"MD"| OppSplit
User -->|"LK"| OppSplit
%% Standard Objects - Sky Blue
style FType fill:#bae6fd,stroke:#0369a1,color:#1f2937
style FItem fill:#bae6fd,stroke:#0369a1,color:#1f2937
style FQuota fill:#bae6fd,stroke:#0369a1,color:#1f2937
style FAdjust fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Opportunity fill:#bae6fd,stroke:#0369a1,color:#1f2937
style OppSplit fill:#bae6fd,stroke:#0369a1,color:#1f2937
style User fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Period fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Key Concepts
Forecasting Types
| Type | Source Field | Description |
|---|---|---|
| Opportunity Revenue | Amount | Standard opportunity forecasting |
| Opportunity Quantity | Quantity | Unit-based forecasting |
| Product Family | Product2.Family | By product category |
| Opportunity Splits | Split Amount | Team selling |
| Custom Measure | Custom field | Custom currency/number |
Forecast Categories
| Category | Stage Mapping |
|---|---|
| Pipeline | Early stages |
| Best Case | High probability |
| Commit | Committed deals |
| Closed | Won deals |
| Omitted | Excluded from forecast |
Forecast Rollup Hierarchy
CEO
└── VP Sales
├── Regional Manager 1
│ ├── Sales Rep A
│ └── Sales Rep B
└── Regional Manager 2
└── Sales Rep CForecasts roll up through Role Hierarchy or Forecast Hierarchy.
---
Simplified Version (Core Objects Only)
For presentations focusing on core forecast flow:
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
User["User"]
Opportunity["Opportunity"]
FItem["ForecastingItem"]
FQuota["ForecastingQuota"]
User -->|"owns"| Opportunity
Opportunity -->|"contributes"| FItem
User -->|"has"| FQuota
User -->|"owns"| FItem
style User fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Opportunity fill:#bae6fd,stroke:#0369a1,color:#1f2937
style FItem fill:#bae6fd,stroke:#0369a1,color:#1f2937
style FQuota fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Opportunity Splits Model
For team selling with revenue splits:
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
Opportunity["Opportunity<br/>($100K)"]
Split1["OpportunitySplit<br/>(Rep A: 60%)"]
Split2["OpportunitySplit<br/>(Rep B: 40%)"]
FItem1["ForecastingItem<br/>(Rep A: $60K)"]
FItem2["ForecastingItem<br/>(Rep B: $40K)"]
Opportunity ==>|"MD"| Split1
Opportunity ==>|"MD"| Split2
Split1 -->|"contributes"| FItem1
Split2 -->|"contributes"| FItem2
style Opportunity fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Split1 fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Split2 fill:#bae6fd,stroke:#0369a1,color:#1f2937
style FItem1 fill:#bae6fd,stroke:#0369a1,color:#1f2937
style FItem2 fill:#bae6fd,stroke:#0369a1,color:#1f2937---
ASCII Fallback
┌─────────────────────────────────────────────────────────────────────────────┐
│ COLLABORATIVE FORECASTS DATA MODEL (L→R) │
│ Legend: LK = Lookup (-->), MD = Master-Detail (==>) │
└─────────────────────────────────────────────────────────────────────────────┘
┌──────────────────┐
│ FORECASTING_TYPE │─────── LK ──────┬──────────────────────────────────┐
│ (count) │ │ │
└──────────────────┘ ▼ ▼
┌──────────────────┐ ┌──────────────────┐
│ FORECASTING_ITEM │ │FORECASTING_QUOTA │
│ (count) │ │ (count) │
└────────┬─────────┘ └────────┬─────────┘
│ │
│ LK │ LK
▼ ▼
┌──────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ OPPORTUNITY │── LK ──>│ │ │ USER │
│ (count) │ │ │<──── LK ─────│ (count) │
└──────┬───────┘ └──────────────────┘ └──────────────────┘
│
│ MD
▼
┌──────────────────┐
│ OPPORTUNITY_SPLIT│
│ (count) │
└──────────────────┘---
Key Relationships Summary
| Parent | Child | Type | Behavior |
|---|---|---|---|
| ForecastingType | ForecastingItem | LK | Type configuration |
| ForecastingType | ForecastingQuota | LK | Type configuration |
| User | ForecastingItem | LK | Forecast owner |
| User | ForecastingQuota | LK | Quota owner |
| Period | ForecastingItem | LK | Time period |
| Period | ForecastingQuota | LK | Time period |
| Opportunity | ForecastingItem | LK | Source opportunity |
| Opportunity | OpportunitySplit | MD | Cascade delete |
| User | OpportunitySplit | LK | Split owner |
---
Limits & Considerations
| Limit | Value |
|---|---|
| Forecasting types | 4 (standard) + 4 (custom) |
| Forecast hierarchy levels | Role hierarchy depth |
| Splits per opportunity | Unlimited |
| Quota periods | Fiscal periods |
| Adjustment history | 12 months |
---
Forecast Hierarchy vs Role Hierarchy
| Option | Use Case |
|---|---|
| Role Hierarchy | Forecasts follow org chart |
| Forecast Hierarchy | Custom forecast rollup path |
| Territory Hierarchy | Territory-based forecasting |
---
Best Practices
1. Use `flowchart LR` - Left-to-right flow for readability 2. Keep objects simple - Name + record count only 3. Replace `(count)` placeholders - With actual counts from query 4. Add LDV indicator - For objects >2M records: LDV[~4M] 5. Color code object types - Blue=Standard, Orange=Custom, Green=External
Field Service Lightning (FSL) Data Model Template
Pre-built data model for Salesforce Field Service (formerly Field Service Lightning) using flowchart LR format with color coding and relationship indicators.
Objects Included
| Object | Type | Description |
|---|---|---|
| WorkOrder | STD | Service jobs |
| WorkOrderLineItem | STD | Job tasks |
| ServiceAppointment | STD | Scheduled visits |
| ServiceResource | STD | Technicians/assets |
| ServiceTerritory | STD | Service areas |
| AssignedResource | STD | Appointment assignments |
| Shift | STD | Resource schedules |
| TimeSheet | STD | Time tracking |
| TimeSheetEntry | STD | Time details |
| ProductConsumed | STD | Parts used |
| ProductRequired | STD | Parts needed |
---
Query Org Metadata (Recommended)
Enrich diagram with live org data:
python3 ~/.claude/skills/sf-diagram-mermaid/scripts/query-org-metadata.py \
--objects WorkOrder,WorkOrderLineItem,ServiceAppointment,ServiceResource,ServiceTerritory \
--target-org myorg---
Mermaid Template (Preferred)
Left-to-right flowchart with color coding.
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
%% ═══════════════════════════════════════════════════════════════
%% FIELD SERVICE LIGHTNING DATA MODEL
%% LEGEND: LK = Lookup (-->), MD = Master-Detail (==>)
%% Colors: Blue = Standard, Orange = Custom, Green = External
%% ═══════════════════════════════════════════════════════════════
%% Work Order Structure
WO["WorkOrder<br/>(count)"]
WOLI["WorkOrderLineItem<br/>(count)"]
%% Scheduling
SA["ServiceAppointment<br/>(count)"]
AR["AssignedResource<br/>(count)"]
%% Resources
SR["ServiceResource<br/>(count)"]
ST["ServiceTerritory<br/>(count)"]
STM["ServiceTerritoryMember<br/>(count)"]
Shift["Shift<br/>(count)"]
%% Time Tracking
TS["TimeSheet<br/>(count)"]
TSE["TimeSheetEntry<br/>(count)"]
%% Products/Parts
PC["ProductConsumed<br/>(count)"]
PR["ProductRequired<br/>(count)"]
%% Related
Case["Case<br/>(count)"]
Asset["Asset<br/>(count)"]
Account["Account<br/>(count)"]
%% Work Order Structure
WO ==>|"MD"| WOLI
Case -->|"LK"| WO
Asset -->|"LK"| WO
Account -->|"LK"| WO
%% Work Order to Appointments
WO -->|"LK"| SA
WOLI -->|"LK"| SA
ST -->|"LK"| SA
%% Assignment
SA ==>|"MD"| AR
SR -->|"LK"| AR
%% Resource Structure
ST ==>|"MD"| STM
SR -->|"LK"| STM
SR ==>|"MD"| Shift
%% Time Tracking
SR -->|"LK"| TS
TS ==>|"MD"| TSE
WO -->|"LK"| TSE
WOLI -->|"LK"| TSE
%% Products
WO ==>|"MD"| PC
WO ==>|"MD"| PR
WOLI ==>|"MD"| PC
WOLI ==>|"MD"| PR
%% Standard Objects - Sky Blue
style WO fill:#bae6fd,stroke:#0369a1,color:#1f2937
style WOLI fill:#bae6fd,stroke:#0369a1,color:#1f2937
style SA fill:#bae6fd,stroke:#0369a1,color:#1f2937
style AR fill:#bae6fd,stroke:#0369a1,color:#1f2937
style SR fill:#bae6fd,stroke:#0369a1,color:#1f2937
style ST fill:#bae6fd,stroke:#0369a1,color:#1f2937
style STM fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Shift fill:#bae6fd,stroke:#0369a1,color:#1f2937
style TS fill:#bae6fd,stroke:#0369a1,color:#1f2937
style TSE fill:#bae6fd,stroke:#0369a1,color:#1f2937
style PC fill:#bae6fd,stroke:#0369a1,color:#1f2937
style PR fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Case fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Asset fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Account fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Key Concepts
FSL Object Hierarchy
Case/Asset → WorkOrder → WorkOrderLineItem → ServiceAppointment
↓ ↓ ↓
ProductRequired ProductConsumed AssignedResource
↓
ServiceResourceWork Order vs Service Appointment
| Object | Purpose |
|---|---|
| WorkOrder | What needs to be done (job definition) |
| ServiceAppointment | When/where it will be done (scheduling) |
One WorkOrder can have multiple ServiceAppointments (multi-day jobs).
Resource Types
| Type | Description |
|---|---|
| Technician | Field worker (User-based) |
| Crew | Group of technicians |
| Dispatcher | Scheduling coordinator |
| Tool | Equipment (Asset-based) |
| Contractor | External resource |
Scheduling Policies
| Policy | Purpose |
|---|---|
| Customer First | Minimize customer wait |
| High Intensity | Maximize utilization |
| Soft Boundaries | Flexible territories |
| Emergency | Override normal rules |
---
Simplified Version (Core Objects Only)
For presentations focusing on core FSL flow:
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
WO["WorkOrder"]
SA["ServiceAppointment"]
SR["ServiceResource"]
ST["ServiceTerritory"]
WO -->|"LK"| SA
SA ==>|"assigned"| SR
ST -->|"LK"| SA
style WO fill:#bae6fd,stroke:#0369a1,color:#1f2937
style SA fill:#bae6fd,stroke:#0369a1,color:#1f2937
style SR fill:#bae6fd,stroke:#0369a1,color:#1f2937
style ST fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Inventory/Parts Model
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
WO["WorkOrder"]
WOLI["WorkOrderLineItem"]
PR["ProductRequired"]
PC["ProductConsumed"]
PI["ProductItem"]
PL["Location"]
Product2["Product2"]
WO ==>|"MD"| WOLI
WOLI ==>|"MD"| PR
WOLI ==>|"MD"| PC
PR -->|"LK"| Product2
PC -->|"LK"| Product2
PI -->|"LK"| Product2
PI -->|"LK"| PL
style WO fill:#bae6fd,stroke:#0369a1,color:#1f2937
style WOLI fill:#bae6fd,stroke:#0369a1,color:#1f2937
style PR fill:#bae6fd,stroke:#0369a1,color:#1f2937
style PC fill:#bae6fd,stroke:#0369a1,color:#1f2937
style PI fill:#bae6fd,stroke:#0369a1,color:#1f2937
style PL fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Product2 fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Time Tracking Model
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
SR["ServiceResource"]
TS["TimeSheet"]
TSE["TimeSheetEntry"]
WO["WorkOrder"]
SA["ServiceAppointment"]
SR -->|"LK"| TS
TS ==>|"MD"| TSE
WO -->|"LK"| TSE
SA -->|"LK"| TSE
style SR fill:#bae6fd,stroke:#0369a1,color:#1f2937
style TS fill:#bae6fd,stroke:#0369a1,color:#1f2937
style TSE fill:#bae6fd,stroke:#0369a1,color:#1f2937
style WO fill:#bae6fd,stroke:#0369a1,color:#1f2937
style SA fill:#bae6fd,stroke:#0369a1,color:#1f2937---
ASCII Fallback
┌─────────────────────────────────────────────────────────────────────────────┐
│ FIELD SERVICE LIGHTNING DATA MODEL (L→R) │
│ Legend: LK = Lookup (-->), MD = Master-Detail (==>) │
└─────────────────────────────────────────────────────────────────────────────┘
WORK ORDER STRUCTURE
┌──────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ CASE │── LK ──>│ WORK_ORDER │═══ MD ═>│ WORK_ORDER_LINE │
│ (count) │ │ (count) │ │ ITEM (count) │
└──────────────┘ └────────┬─────────┘ └────────┬─────────┘
│ │
┌──────────────┐ │ LK │ LK
│ ASSET │── LK ────────────┤ │
│ (count) │ ▼ ▼
└──────────────┘ ┌──────────────────┐ ┌──────────────────┐
│SERVICE_APPOINTMENT│◄────────│ │
│ (count) │ └──────────────────┘
└────────┬─────────┘
│ MD
▼
┌──────────────────┐ ┌──────────────────┐
│ASSIGNED_RESOURCE │── LK ──>│ SERVICE_RESOURCE │
│ (count) │ │ (count) │
└──────────────────┘ └────────┬─────────┘
│ MD
▼
┌──────────────────┐
│ SHIFT │
│ (count) │
└──────────────────┘---
Key Relationships Summary
| Parent | Child | Type | Behavior |
|---|---|---|---|
| WorkOrder | WorkOrderLineItem | MD | Cascade delete |
| WorkOrder | ServiceAppointment | LK | Scheduling |
| ServiceAppointment | AssignedResource | MD | Cascade delete |
| ServiceResource | AssignedResource | LK | Resource reference |
| ServiceTerritory | ServiceTerritoryMember | MD | Cascade delete |
| ServiceResource | Shift | MD | Cascade delete |
| ServiceResource | TimeSheet | LK | Time owner |
| TimeSheet | TimeSheetEntry | MD | Cascade delete |
| WorkOrder | ProductConsumed | MD | Parts used |
| WorkOrder | ProductRequired | MD | Parts needed |
| Case | WorkOrder | LK | Source case |
| Asset | WorkOrder | LK | Serviced asset |
---
Limits & Considerations
| Limit | Value |
|---|---|
| Work Order Line Items per WO | 200 (default) |
| Appointments per Work Order | Unlimited |
| Resources per Territory | Unlimited |
| Optimization batch size | 50 appointments |
| Shift duration | Max 24 hours |
| Service History retention | Configurable |
---
FSL Managed Package Objects
| Object | Purpose |
|---|---|
| FSL__Scheduling_Policy__c | Optimization rules |
| FSL__Service_Goal__c | SLA definitions |
| FSL__Resource_Preference__c | Customer preferences |
| FSL__Time_Dependency__c | Appointment sequences |
---
Best Practices
1. Use `flowchart LR` - Left-to-right flow for readability 2. Keep objects simple - Name + record count only 3. Replace `(count)` placeholders - With actual counts from query 4. Add LDV indicator - For objects >2M records: LDV[~4M] 5. Color code object types - Blue=Standard, Orange=Custom/Managed, Green=External
Party Model (Industry Cloud) Data Model Template
Pre-built data model for Salesforce Party Model used in Industry Clouds (Financial Services Cloud, Health Cloud, etc.) using flowchart LR format with color coding.
Objects Included
| Object | Type | Description |
|---|---|---|
| Account | STD | Person or Business accounts |
| Contact | STD | Individual contacts |
| AccountContactRelation | STD | Account-Contact junction (ACR) |
| AccountContactRole | STD | Role-based relationship |
| ContactContactRelation | Managed | Contact-to-Contact relationships |
| AccountAccountRelation | Managed | Account-to-Account relationships |
---
Query Org Metadata (Recommended)
Enrich diagram with live org data:
python3 ~/.claude/skills/sf-diagram-mermaid/scripts/query-org-metadata.py \
--objects Account,Contact,AccountContactRelation,AccountContactRole \
--target-org myorg---
Mermaid Template (Preferred)
Left-to-right flowchart with color coding.
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
%% ═══════════════════════════════════════════════════════════════
%% PARTY MODEL (INDUSTRY CLOUD) DATA MODEL
%% LEGEND: LK = Lookup (-->), MD = Master-Detail (==>)
%% Colors: Blue = Standard, Orange = Custom, Green = External
%% ═══════════════════════════════════════════════════════════════
%% Core Party Objects
Account["Account<br/>(count)"]
Contact["Contact<br/>(count)"]
%% Standard Relationships
ACR["AccountContactRelation<br/>(count)"]
ACRole["AccountContactRole<br/>(count)"]
%% Industry Cloud Extensions (Managed)
CCR["ContactContactRelation<br/>(count)"]
AAR["AccountAccountRelation<br/>(count)"]
%% Standard Account-Contact
Account -->|"LK"| Contact
Account -->|"LK"| ACR
Contact -->|"LK"| ACR
%% Opportunity Roles
Account -->|"LK"| ACRole
Contact -->|"LK"| ACRole
%% Contact-to-Contact (FSC/Health)
Contact -->|"LK"| CCR
Contact -->|"RelatedContact"| CCR
%% Account-to-Account (FSC/Health)
Account -->|"LK"| AAR
Account -->|"RelatedAccount"| AAR
%% Standard Objects - Sky Blue
style Account fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Contact fill:#bae6fd,stroke:#0369a1,color:#1f2937
style ACR fill:#bae6fd,stroke:#0369a1,color:#1f2937
style ACRole fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CCR fill:#bae6fd,stroke:#0369a1,color:#1f2937
style AAR fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Key Concepts
Person Accounts vs Business Accounts
| Type | RecordType | IsPersonAccount |
|---|---|---|
| Business | Business_Account | false |
| Person | Person_Account | true |
Person Accounts merge Account + Contact into single record.
AccountContactRelation (ACR)
- Indirect relationship between Account and Contact
- Enables many-to-many Account↔Contact
- Has
Rolesmulti-select picklist IsDirectflag indicates primary relationship
Industry Cloud Extensions
| Object | Cloud | Purpose |
|---|---|---|
| ContactContactRelation | FSC, Health | Family/household relationships |
| AccountAccountRelation | FSC, Health | Business relationships |
| FinancialAccount | FSC | Financial accounts |
| HealthCloudGA__EhrPatient__c | Health | Patient records |
---
Person Account Model
Shows Person Account relationships:
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
PersonAccount["Account<br/>(IsPersonAccount=true)"]
ACR["AccountContactRelation"]
CCR["ContactContactRelation"]
PersonAccount -->|"Indirect ACR"| ACR
PersonAccount -->|"Person-to-Person"| CCR
style PersonAccount fill:#bae6fd,stroke:#0369a1,color:#1f2937
style ACR fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CCR fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Financial Services Cloud Extension
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
Account["Account<br/>(count)"]
Contact["Contact<br/>(count)"]
FinAcct["FinancialAccount<br/>(count)"]
FinAcctRole["FinancialAccountRole<br/>(count)"]
CCR["ContactContactRelation<br/>(count)"]
Account -->|"LK"| FinAcct
FinAcct ==>|"MD"| FinAcctRole
Contact -->|"LK"| FinAcctRole
Contact -->|"LK"| CCR
%% Standard - Sky Blue
style Account fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Contact fill:#bae6fd,stroke:#0369a1,color:#1f2937
%% FSC Managed - Orange (treated as custom)
style FinAcct fill:#fed7aa,stroke:#c2410c,color:#1f2937
style FinAcctRole fill:#fed7aa,stroke:#c2410c,color:#1f2937
style CCR fill:#fed7aa,stroke:#c2410c,color:#1f2937---
ASCII Fallback
┌─────────────────────────────────────────────────────────────────────────────┐
│ PARTY MODEL (INDUSTRY CLOUD) DATA MODEL (L→R) │
│ Legend: LK = Lookup (-->), MD = Master-Detail (==>) │
└─────────────────────────────────────────────────────────────────────────────┘
┌──────────────┐ ┌──────────────────────────┐
│ ACCOUNT │──────────── LK ─────────────>│ ACCOUNT_CONTACT_RELATION │
│ (count) │ │ (count) │
└──────┬───────┘ └────────────┬─────────────┘
│ │
│ LK │ LK
▼ │
┌──────────────┐ │
│ CONTACT │<─────────────────────────────────────────┘
│ (count) │
└──────┬───────┘
│
│ LK (both sides)
▼
┌──────────────────────────┐
│ CONTACT_CONTACT_RELATION │ (FSC/Health Cloud)
│ (count) │
└──────────────────────────┘
┌──────────────┐ ┌──────────────────────────┐
│ ACCOUNT │──────────── LK ─────────────>│ ACCOUNT_ACCOUNT_RELATION │
│ (parent) │ │ (count) │
└──────────────┘ └──────────────────────────┘
▲ │
└───────────────── RelatedAccount ──────────────────┘---
Key Relationships Summary
| Parent | Child | Type | Behavior |
|---|---|---|---|
| Account | Contact | LK | Primary account |
| Account | AccountContactRelation | LK | Indirect relationships |
| Contact | AccountContactRelation | LK | Indirect relationships |
| Account | AccountContactRole | LK | Opportunity roles |
| Contact | AccountContactRole | LK | Opportunity roles |
| Contact | ContactContactRelation | LK | Person-to-person |
| Account | AccountAccountRelation | LK | Business-to-business |
---
Limits & Considerations
| Limit | Value |
|---|---|
| ACR per Account | No hard limit |
| ACR per Contact | No hard limit |
| Roles per ACR | Multi-select (limited by picklist size) |
| Person Account fields | Merged Account + Contact fields |
---
Industry Cloud Packages
| Cloud | Key Objects |
|---|---|
| Financial Services | FinancialAccount, FinancialAccountRole, Securities, Holdings |
| Health Cloud | CarePlan, CareProgram, EhrPatient, Medication |
| Manufacturing | SalesAgreement, RebateProgram, VisitPlan |
| Consumer Goods | RetailStore, StoreProduct, Promotion |
---
Best Practices
1. Use `flowchart LR` - Left-to-right flow for readability 2. Keep objects simple - Name + record count only 3. Replace `(count)` placeholders - With actual counts from query 4. Add LDV indicator - For objects >2M records: LDV[~4M] 5. Color code object types - Blue=Standard, Orange=Custom/Managed, Green=External
Quote & Order Data Model Template
Pre-built data model for Salesforce Quotes and Orders using flowchart LR format with color coding and relationship indicators.
Objects Included
| Object | Type | Description |
|---|---|---|
| Opportunity | STD | Sales deals |
| Quote | STD | Price quotes |
| QuoteLineItem | STD | Quote products |
| Order | STD | Customer orders |
| OrderItem | STD | Order products |
| Product2 | STD | Product catalog |
| PricebookEntry | STD | Product prices |
| Pricebook2 | STD | Price lists |
| Contract | STD | Customer contracts |
---
Query Org Metadata (Recommended)
Enrich diagram with live org data:
python3 ~/.claude/skills/sf-diagram-mermaid/scripts/query-org-metadata.py \
--objects Opportunity,Quote,QuoteLineItem,Order,OrderItem,Product2,Contract \
--target-org myorg---
Mermaid Template (Preferred)
Left-to-right flowchart with color coding.
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
%% ═══════════════════════════════════════════════════════════════
%% QUOTE & ORDER DATA MODEL
%% LEGEND: LK = Lookup (-->), MD = Master-Detail (==>)
%% Colors: Blue = Standard, Orange = Custom, Green = External
%% ═══════════════════════════════════════════════════════════════
%% Product Catalog
Pricebook2["Pricebook2<br/>(count)"]
Product2["Product2<br/>(count)"]
PBE["PricebookEntry<br/>(count)"]
%% Quote Objects
Opportunity["Opportunity<br/>(count)"]
Quote["Quote<br/>(count)"]
QLI["QuoteLineItem<br/>(count)"]
%% Order Objects
Order["Order<br/>(count)"]
OrderItem["OrderItem<br/>(count)"]
Contract["Contract<br/>(count)"]
%% Account
Account["Account<br/>(count)"]
%% Product Catalog Relationships
Pricebook2 ==>|"MD"| PBE
Product2 -->|"LK"| PBE
%% Quote Relationships
Opportunity ==>|"MD"| Quote
Quote ==>|"MD"| QLI
PBE -->|"LK"| QLI
Product2 -->|"LK"| QLI
Pricebook2 -->|"LK"| Quote
%% Order Relationships
Account -->|"LK"| Order
Contract -->|"LK"| Order
Quote -->|"LK"| Order
Order ==>|"MD"| OrderItem
PBE -->|"LK"| OrderItem
Product2 -->|"LK"| OrderItem
Pricebook2 -->|"LK"| Order
%% Contract
Account -->|"LK"| Contract
%% Standard Objects - Sky Blue
style Pricebook2 fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Product2 fill:#bae6fd,stroke:#0369a1,color:#1f2937
style PBE fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Opportunity fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Quote fill:#bae6fd,stroke:#0369a1,color:#1f2937
style QLI fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Order fill:#bae6fd,stroke:#0369a1,color:#1f2937
style OrderItem fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Contract fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Account fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Key Concepts
Quote-to-Cash Flow
Opportunity → Quote → Order → Invoice → Payment
↓ ↓ ↓
OLI QLI OrderItemSynced Quote
- One Quote per Opportunity can be marked as Synced
- Synced Quote copies line items to OpportunityLineItems
IsSyncing = trueon Synced Quote
Quote to Order Conversion
| Action | Result |
|---|---|
| Create Order from Quote | Creates Order + OrderItems |
| Quote.OrderId | Links Quote to created Order |
| Reduction Orders | Negative quantity adjustments |
Pricebook Structure
Pricebook2 (Standard + Custom)
↓
PricebookEntry (Product + Price per Pricebook)
↓
Product2 (Catalog)---
Simplified Version (Core Flow)
For presentations focusing on Quote-to-Order flow:
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
Opportunity["Opportunity"]
Quote["Quote"]
Order["Order"]
Contract["Contract"]
Opportunity ==>|"MD"| Quote
Quote -->|"creates"| Order
Contract -->|"LK"| Order
style Opportunity fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Quote fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Order fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Contract fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Product Catalog Detail
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
Pricebook2["Pricebook2<br/>(Standard + Custom)"]
Product2["Product2<br/>(Catalog)"]
PBE["PricebookEntry<br/>(Price per Book)"]
Pricebook2 ==>|"MD"| PBE
Product2 -->|"LK"| PBE
style Pricebook2 fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Product2 fill:#bae6fd,stroke:#0369a1,color:#1f2937
style PBE fill:#bae6fd,stroke:#0369a1,color:#1f2937---
ASCII Fallback
┌─────────────────────────────────────────────────────────────────────────────┐
│ QUOTE & ORDER DATA MODEL (L→R) │
│ Legend: LK = Lookup (-->), MD = Master-Detail (==>) │
└─────────────────────────────────────────────────────────────────────────────┘
PRODUCT CATALOG QUOTE FLOW
┌──────────────┐ ┌─────────────────┐ ┌──────────────┐
│ PRICEBOOK2 │═══ MD ═>│ PRICEBOOKENTRY │ │ OPPORTUNITY │
│ (count) │ │ (count) │ │ (count) │
└──────────────┘ └────────┬────────┘ └──────┬───────┘
│ │ MD
│ LK ▼
┌──────────────┐ │ ┌──────────────┐
│ PRODUCT2 │─────── LK ───────┤ │ QUOTE │
│ (count) │ │ │ (count) │
└──────────────┘ │ └──────┬───────┘
│ │ │ MD
│ │ ▼
│ │ ┌──────────────┐
└────────── LK ────────────┼─────────────────>│QUOTELINEITEM │
└─────── LK ──────>│ (count) │
└──────────────┘
ORDER FLOW
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ ACCOUNT │── LK ──>│ ORDER │═══ MD ═>│ ORDERITEM │
│ (count) │ │ (count) │ │ (count) │
└──────────────┘ └──────┬───────┘ └──────────────┘
│
┌──────────────┐ │
│ CONTRACT │────── LK ──────┘
│ (count) │
└──────────────┘---
Key Relationships Summary
| Parent | Child | Type | Behavior |
|---|---|---|---|
| Opportunity | Quote | MD | Cascade delete |
| Quote | QuoteLineItem | MD | Cascade delete |
| Order | OrderItem | MD | Cascade delete |
| Pricebook2 | PricebookEntry | MD | Cascade delete |
| Product2 | PricebookEntry | LK | Product reference |
| PricebookEntry | QuoteLineItem | LK | Price reference |
| PricebookEntry | OrderItem | LK | Price reference |
| Account | Order | LK | Customer |
| Contract | Order | LK | Contract reference |
| Quote | Order | LK | Source quote |
---
Limits & Considerations
| Limit | Value |
|---|---|
| Quotes per Opportunity | Unlimited (1 synced) |
| QuoteLineItems per Quote | 200 (configurable) |
| Orders per Account | Unlimited |
| OrderItems per Order | 200 (configurable) |
| Custom Pricebooks | Unlimited |
| Products | 5 million (LDV) |
---
Contract-Based Orders
For orgs using Contracts with Orders:
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
Account["Account"]
Contract["Contract"]
Order["Order"]
ReductionOrder["Order<br/>(Reduction)"]
Account -->|"LK"| Contract
Contract -->|"LK"| Order
Order -.->|"reduces"| ReductionOrder
style Account fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Contract fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Order fill:#bae6fd,stroke:#0369a1,color:#1f2937
style ReductionOrder fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Best Practices
1. Use `flowchart LR` - Left-to-right flow for readability 2. Keep objects simple - Name + record count only 3. Replace `(count)` placeholders - With actual counts from query 4. Add LDV indicator - For objects >2M records: LDV[~4M] 5. Color code object types - Blue=Standard, Orange=Custom, Green=External
Sales Cloud Data Model Template
Pre-built data model for Salesforce Sales Cloud using flowchart LR format with color coding and relationship indicators.
Objects Included
| Object | Type | Description |
|---|---|---|
| Account | STD | Companies and organizations |
| Contact | STD | People associated with accounts |
| Lead | STD | Potential customers |
| Opportunity | STD | Sales deals and revenue |
| OpportunityLineItem | STD | Products on opportunities |
| Product2 | STD | Product catalog |
| Campaign | STD | Marketing campaigns |
| CampaignMember | STD | Campaign responses |
---
Query Org Metadata (Recommended)
Enrich diagram with live org data:
python3 ~/.claude/skills/sf-diagram-mermaid/scripts/query-org-metadata.py \
--objects Account,Contact,Lead,Opportunity,Product2,Campaign \
--target-org myorg---
Mermaid Template (Preferred)
Left-to-right flowchart with color coding.
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
%% ═══════════════════════════════════════════════════════════════
%% SALES CLOUD DATA MODEL
%% LEGEND: LK = Lookup (-->), MD = Master-Detail (==>)
%% Colors: Blue = Standard, Orange = Custom, Green = External
%% ═══════════════════════════════════════════════════════════════
%% Core Objects
Lead["Lead<br/>(count)"]
Account["Account<br/>(count)"]
Contact["Contact<br/>(count)"]
Opportunity["Opportunity<br/>(count)"]
%% Product Objects
Product2["Product2<br/>(count)"]
OLI["OpportunityLineItem<br/>(count)"]
%% Campaign Objects
Campaign["Campaign<br/>(count)"]
CampaignMember["CampaignMember<br/>(count)"]
%% Relationships - Lead Conversion
Lead -.->|"converts"| Account
Lead -.->|"converts"| Contact
%% Relationships - Account to children
Account -->|"LK"| Contact
Account -->|"LK"| Opportunity
%% Relationships - Opportunity
Opportunity ==>|"MD"| OLI
Product2 -->|"LK"| OLI
Contact -->|"LK"| Opportunity
%% Relationships - Campaign
Campaign ==>|"MD"| CampaignMember
Lead -->|"LK"| CampaignMember
Contact -->|"LK"| CampaignMember
Campaign -->|"LK"| Opportunity
%% Standard Objects - Sky Blue
style Lead fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Account fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Contact fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Opportunity fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Product2 fill:#bae6fd,stroke:#0369a1,color:#1f2937
style OLI fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Campaign fill:#bae6fd,stroke:#0369a1,color:#1f2937
style CampaignMember fill:#bae6fd,stroke:#0369a1,color:#1f2937---
Simplified Version (Core Objects Only)
For presentations focusing on core sales flow:
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
Lead["Lead"]
Account["Account"]
Contact["Contact"]
Opportunity["Opportunity"]
Lead -.->|"converts"| Account
Lead -.->|"converts"| Contact
Account -->|"LK"| Contact
Account -->|"LK"| Opportunity
Contact -->|"LK"| Opportunity
style Lead fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Account fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Contact fill:#bae6fd,stroke:#0369a1,color:#1f2937
style Opportunity fill:#bae6fd,stroke:#0369a1,color:#1f2937---
ASCII Fallback
┌─────────────────────────────────────────────────────────────────────────────┐
│ SALES CLOUD DATA MODEL (L→R) │
│ Legend: LK = Lookup (-->), MD = Master-Detail (==>), -.-> = converts │
└─────────────────────────────────────────────────────────────────────────────┘
┌──────────┐ ┌──────────┐ ┌──────────────┐
│ LEAD │··········│ ACCOUNT │── LK ───>│ CONTACT │
│ (count) │ converts │ (count) │ │ (count) │
└────┬─────┘ └────┬─────┘ └──────┬───────┘
│ │ │
│ converts │ LK │ LK
│ ▼ ▼
│ ┌──────────────┐ ┌─────────────────┐
└───────────────>│ OPPORTUNITY │<──────│ (via OCR) │
│ (count) │ └─────────────────┘
└──────┬───────┘
│ MD
▼
┌──────────────────────┐
│ OPPORTUNITY_LINE_ITEM│◄── LK ──┌───────────┐
│ (count) │ │ PRODUCT2 │
└──────────────────────┘ │ (count) │
└───────────┘
┌──────────┐ ┌─────────────────┐
│ CAMPAIGN │═══ MD ══>│ CAMPAIGN_MEMBER │
│ (count) │ │ (count) │
└──────────┘ └─────────────────┘---
Key Relationships Summary
| Parent | Child | Type | Behavior |
|---|---|---|---|
| Account | Contact | LK | Optional parent |
| Account | Opportunity | LK | Optional parent |
| Opportunity | OpportunityLineItem | MD | Cascade delete |
| Product2 | OpportunityLineItem | LK | Optional parent |
| Campaign | CampaignMember | MD | Cascade delete |
| Campaign | Opportunity | LK | Primary campaign source |
| Lead | (converts to) | - | Account + Contact created |
---
Adding Custom Objects
Use orange styling for custom objects:
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
Account["Account<br/>(317)"]
Invoice["Invoice__c<br/>(1,200)"]
Account ==>|"MD"| Invoice
%% Standard - Sky Blue
style Account fill:#bae6fd,stroke:#0369a1,color:#1f2937
%% Custom - Orange
style Invoice fill:#fed7aa,stroke:#c2410c,color:#1f2937---
Best Practices
1. Use `flowchart LR` - Left-to-right flow for readability 2. Keep objects simple - Name + record count only 3. Replace `(count)` placeholders - With actual counts from query 4. Add LDV indicator - For objects >2M records: LDV[~4M] 5. Color code object types - Blue=Standard, Orange=Custom, Green=External
<!-- Parent: sf-diagram-mermaid/SKILL.md -->
Mermaid Preview Server Guide
After generating the diagram, offer the user a localhost preview for real-time iteration.
Start Preview
1. Save Mermaid code to temporary file:
Write: /tmp/mermaid-preview.mmd
[Mermaid code content]2. Start preview server (runs in background):
# From installed skill folder:
python ~/.claude/skills/sf-diagram-mermaid/scripts/mermaid_preview.py start --file /tmp/mermaid-preview.mmd
# Or from project folder (if working locally):
python [project-root]/skills/sf-diagram-mermaid/scripts/mermaid_preview.py start --file /tmp/mermaid-preview.mmd3. Provide URL to user:
Preview available: http://localhost:8765
>
The browser will auto-reload when you update the diagram.
Iteration Workflow
- User views diagram in browser
- User requests changes ("make boxes pink", "add another node")
- You update
/tmp/mermaid-preview.mmdusing the Write tool - Browser auto-reloads with new diagram (via SSE)
- Repeat until user is satisfied
Stop Preview
When user is done:
python ~/.claude/skills/sf-diagram-mermaid/scripts/mermaid_preview.py stopPreview Server Features
- Live reload via Server-Sent Events (SSE)
- Dark/light theme auto-detection
- Copy Mermaid code button
- Download as SVG button
- Connection status indicator
Related skills
Forks & variants (1)
Sf Diagram Mermaid has 1 known copy in the catalog totaling 34 installs. They canonicalize to this original listing.
- jaganpro - 34 installs
FAQ
What output formats does sf-diagram-mermaid support?
Mermaid syntax diagrams with ASCII fallback for Salesforce architecture views.
When should I use sf-diagram-mermaid?
When visualizing Salesforce ERD, sequence, or architecture diagrams in documentation.
Is sf-diagram-mermaid safe to install?
Review the Security Audits panel on this page before installing in production.