# trailheadapps/az-insurance architecture

> Architecture diagram of the GitHub repository trailheadapps/az-insurance, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/trailheadapps/az-insurance
- Repository: https://github.com/trailheadapps/az-insurance

## Overview

##### Main Components
- Salesforce DX Environment:
– The scratch org serves as the central Salesforce instance where metadata and configuration are deployed.
– Deployment scripts (in the “bin” directory) and configuration (from the “config” folder, e.g., project-scratch-def.json) are used to establish the org.
- Experience Cloud & Lightning Web Runtime:
– Two Experience sites are defined (for example, “LWR Demo Agent1” and “LWR Demo Marketing1” under the experiences directory).
– These sites involve specific Experience metadata such as branding sets, configuration files, routes, pages, and themes.
- Backend Components:
– Apex classes (in the force-app/main/default/classes) form the business logic (e.g., ManagedContentController, NavigationLinkSetPickList, NavigationMenuItemsController).
– Flows and other automated processes reside in the “flows” folder.
- Frontend Components:
– Lightning Web Components (in force-app/main/default/lwc) encapsulate UI elements (navigation menus, record details, cards, etc.).
- Data & Content:
– Sample content and media are provided in the “data” folder (the zip files) and imported via CMS in the org.
– Managed content types and static resources are key in delivering the visual design and content.
- CI/CD and Development Tools:
– GitHub workflows (under .github/workflows) for automated builds, testing, and continuous integration.
– Husky hooks, ESLint, and Prettier configuration files used to enforce code quality on commits.
– Package.json which also controls node-based tooling for linting and formatting.

##### Relationships and Interactions
- The developer machines (set up with Salesforce CLI, Visual Studio Code, Node.js, etc.) interact with a Salesforce scratch org to deploy and test metadata.
- The CI/CD pipeline (configured via GitHub Actions) automates validations and deployments.
- The Experience Cloud sites rely on deployed metadata (Apex, LWC, Visualforce pages) and imported CMS content to render the final user experience.
- There is a clear separation between backend logic (Apex classes, Object definitions, Flows) and frontend UI (LWC components and Experience configuration files).
- Sample Data import is a separate process that integrates with the deployed environment to populate the CMS workspaces.

##### Architectural Patterns and Design Principles
- Modular Design: The project is split into logical modules (e.g., experiences, lwc, classes, objects) following Salesforce DX best practices.
- Separation of Concerns: Clear division between UI (LWC components and Experience site configuration) and backend logic (Apex controllers, Flows).
- DevOps Integration: Use of GitHub workflows and pre-commit hooks enforces automation and code quality.
- Metadata-Driven Development: The majority of logic and configuration is stored as metadata files that can be deployed and managed via Salesforce CLI.

##### Relevant Technologies and Frameworks
- Salesforce DX, Experience Cloud, and Lightning Web Runtime.
- Salesforce CLI for deployment and org management.
- GitHub Actions for CI/CD.
- Node.js (with ESLint, Prettier) for code formatting and linting.
- Git as a version control system.

##### Elements
- Use clear labels for each component (e.g., “Scratch Org”, “Experience Cloud – LWR Demo Marketing”, “Apex Controllers”, “LWC Components”, “CMS & Content Imports”, “CI/CD Pipeline”).
– For frontend components (LWC and Experience sites), choose another.
- Detail the integration points (deployment scripts from the “bin” folder linking the developer’s environment with the Salesforce org).

## Diagram (Mermaid)

```mermaid
graph TD
  subgraph "Developer Environment"
    DEV["Developer Machine (CLI,VSCode,Node)"]:::tools
  end

  subgraph "CI/CD Pipeline"
    WORKFLOWS["GitHub Workflows"]:::tools
    HUSKY["Husky Pre-Commit Hooks"]:::tools
    ESLINT["ESLint Config"]:::tools
    PRETTIER["Prettier Config"]:::tools
    PKG["Package.json (Node Tooling)"]:::tools
  end

  subgraph "Salesforce DX Environment"
    SCRATCH["Scratch Org (Salesforce Instance)"]:::salesforce
    DEPLOY["Deployment Scripts"]:::salesforce
    CONFIG["Org Configuration"]:::salesforce
  end

  subgraph "Experience Cloud & LWR"
    AGENT["Experience Site: LWR Demo Agent1"]:::frontend
    MARKETING["Experience Site: LWR Demo Marketing1"]:::frontend
    NETWORKS["Networks Metadata"]:::frontend
  end

  subgraph "Backend Components"
    APEX["Apex Classes"]:::backend
    FLOWS["Flows"]:::backend
    MNGCT["Managed Content Types"]:::backend
    NAVMENU["Navigation Menus"]:::backend
    OBJ["Objects (LWR_Demo_Lead__c)"]:::backend
    PERM["Permissions (Permissionsets & Profiles)"]:::backend
  end

  subgraph "Frontend Components"
    LWC["Lightning Web Components"]:::frontend
    VF["Visualforce/Community Pages"]:::frontend
  end

  subgraph "Data & Content"
    CMS["CMS Content (Sample Data & Media)"]:::data
    STATIC["Static Resources"]:::data
  end

  %% Relationships from Developer to CI/CD
  DEV -->|"pushCode"| WORKFLOWS
  DEV -->|"pushCode"| HUSKY
  DEV -->|"pushCode"| ESLINT
  DEV -->|"pushCode"| PRETTIER
  DEV -->|"pushCode"| PKG

  %% CI/CD triggering deployments
  WORKFLOWS -->|"triggerDeploy"| DEPLOY
  HUSKY -->|"codeQuality"| ESLINT
  ESLINT -->|"configApply"| DEPLOY
  PRETTIER -->|"configApply"| DEPLOY
  PKG -->|"nodeTooling"| DEPLOY

  %% Deployment and org configuration
  DEPLOY -->|"loadConfig"| CONFIG
  DEPLOY -->|"deployTo"| SCRATCH

  %% Scratch Org deploying metadata
  SCRATCH -->|"hosts"| AGENT
  SCRATCH -->|"hosts"| MARKETING
  SCRATCH -->|"includes"| NETWORKS
  SCRATCH -->|"contains"| APEX
  SCRATCH -->|"contains"| FLOWS
  SCRATCH -->|"contains"| MNGCT
  SCRATCH -->|"contains"| NAVMENU
  SCRATCH -->|"contains"| OBJ
  SCRATCH -->|"contains"| PERM
  SCRATCH -->|"contains"| LWC
  SCRATCH -->|"contains"| VF
  SCRATCH -->|"integrates"| CMS
  SCRATCH -->|"integrates"| STATIC

  %% Click Events
  click DEPLOY "https://github.com/trailheadapps/az-insurance/tree/main/bin"
  click CONFIG "https://github.com/trailheadapps/az-insurance/blob/main/config/project-scratch-def.json"
  click AGENT "https://github.com/trailheadapps/az-insurance/tree/main/force-app/main/default/experiences/LWR_Demo_Agent1"
  click MARKETING "https://github.com/trailheadapps/az-insurance/tree/main/force-app/main/default/experiences/LWR_Demo_Marketing1"
  click NETWORKS "https://github.com/trailheadapps/az-insurance/tree/main/force-app/main/default/networks"
  click APEX "https://github.com/trailheadapps/az-insurance/tree/main/force-app/main/default/classes"
  click FLOWS "https://github.com/trailheadapps/az-insurance/tree/main/force-app/main/default/flows"
  click MNGCT "https://github.com/trailheadapps/az-insurance/tree/main/force-app/main/default/managedContentTypes"
  click NAVMENU "https://github.com/trailheadapps/az-insurance/tree/main/force-app/main/default/navigationMenus"
  click OBJ "https://github.com/trailheadapps/az-insurance/tree/main/force-app/main/default/objects/LWR_Demo_Lead__c"
  click PERM "https://github.com/trailheadapps/az-insurance/tree/main/force-app/main/default/permissionsets"
  click PERM "https://github.com/trailheadapps/az-insurance/tree/main/force-app/main/default/profiles"
  click LWC "https://github.com/trailheadapps/az-insurance/tree/main/force-app/main/default/lwc"
  click VF "https://github.com/trailheadapps/az-insurance/tree/main/force-app/main/default/pages"
  click CMS "https://github.com/trailheadapps/az-insurance/tree/main/data"
  click STATIC "https://github.com/trailheadapps/az-insurance/tree/main/force-app/main/default/staticresources"
  click WORKFLOWS "https://github.com/trailheadapps/az-insurance/tree/main/.github/workflows"
  click HUSKY "https://github.com/trailheadapps/az-insurance/blob/main/.husky"
  click ESLINT "https://github.com/trailheadapps/az-insurance/blob/main/.eslintignore"
  click PRETTIER "https://github.com/trailheadapps/az-insurance/blob/main/.prettierrc"
  click PKG "https://github.com/trailheadapps/az-insurance/blob/main/package.json"

  %% Styling Classes
  classDef salesforce fill:#f9e79f,stroke:#333,stroke-width:2px;
  classDef frontend fill:#aed6f1,stroke:#333,stroke-width:2px;
  classDef backend fill:#a9dfbf,stroke:#333,stroke-width:2px;
  classDef tools fill:#f5cba7,stroke:#333,stroke-width:2px;
  classDef data fill:#d6eaf8,stroke:#333,stroke-width:2px;
```
