How trailheadapps/ecars works
Main Components
• Salesforce Org: Acts as the central data store (sales, service, leads, vehicles, etc.) and houses key business logic, Lightning Web Components, Apex controllers, flows, triggers, and custom objects.
• Heroku Applications:
– ecars-mqtt-broker: Provides the MQTT messaging layer for IoT interactions (e.g., car diagnostic data).
– ecars-realtime: Streams IoT sensor data, simulates sensors, and interfaces with a Postgres database for persistence.
– ecars-pwa: A progressive web app offering the customer-facing interface, integrating Lightning web components (and using Node scripts for tasks like Postgres table creation).
– ecars-services: Microservices that process tasks such as PDF generation, web push notifications, and composite API calls interacting with Salesforce.
• External Databases & Add-ons: Heroku Postgres databases used by ecars-realtime and PWA for storing and querying data.
• Integration Points/Configuration: Named credentials, environment variables (VAPID keys, Salesforce credentials), and configuration files that tie these systems together.
• Event-Driven/Integration Layers: Change Data Capture from Salesforce, WebSockets (for real-time updates), and MQTT event flows that connect disparate parts of the system.
Relationships and Data Flow
• How the PWA gathers customer input and sends requests through composite APIs to Salesforce.
• That the microservices app (ecars-services) interacts with Salesforce (using named credentials) to generate PDFs and send web push notifications.
• That Heroku Postgres is attached as an add-on to the streaming and PWA apps and is used for persisting IoT data and app state.
• Integration points such as updating Salesforce with external data from Heroku apps and receiving live data via WebSocket connections.
Architectural Patterns and Important Design Principles
• Monorepo Architecture: Demonstrate that several applications are managed in one repository for consistency.
• Event-Driven Communication: Emphasize that systems communicate through events (via MQTT, WebSockets, and change events in Salesforce), which promotes loose coupling.
• Cloud-Native Deployments: Note the deployment via Heroku with respective add-ons and the integration with Salesforce using scratch orgs and metadata deployments.
Representative Technologies and Frameworks
• Salesforce (including Lightning Web Components, Apex, Change Data Capture)
• Node.js (used across Heroku apps)
• MQTT protocol for IoT messaging and secure WebSockets (wss://)
• Heroku deployment and Postgres as a database
• Tools such as Lerna for monorepo management and Jest for testing
Specific Elements
– Sensor data flow: Vehicle devices → MQTT Broker → Real-time Streaming Service → Salesforce (and optionally into Postgres for persistence).
– Customer transactions: PWA → Salesforce (via Composite Graph API).
– Microservice interactions: Microservices application → Salesforce for PDF generation and Web Push notifications.
• Optionally, include configuration elements (e.g., named credentials, environment variables) as notes or annotations.
• Use callouts to denote where event-driven patterns are applied and where technologies like WebSockets, MQTT, and Change Data Capture are used.