How pelayochristian/my-weather-app works
To accurately represent the architecture of the “Weather Dashboard on SF Experience Cloud” project, follow these guidelines. The goal is to break the system into its core components, show how data flows between them, and highlight the Salesforce-specific integration points.
Project Type and Purpose
• This is a full-stack, Salesforce Experience Cloud (LWR) application that surfaces weather data.
• Frontend: Lightning Web Components (LWC) running in an Experience Cloud site.
• Backend: Apex classes handling controller, service, and model logic.
• Integration: External OpenWeather REST API via Salesforce Named Credentials and Custom Metadata.
Main Components
a. User & Browser
b. Experience Cloud (LWR) Site
c. Lightning Web Components
• mwBaseTemplate, mwDashboardWrapper, mwDayForecastCard, etc.
• PubSub module for inter-component messaging
d. Apex Layer
• Controller: MW_OpenWeatherOneCallController
• Service: MW_OpenWeatherOneCallService
• Models: MW_OpenWeatherOneCall, MW_OpenWeatherGeoLocation
• Utility: MW_UtilHelper, MockCalloutService (for testing)
e. Configuration & Security
• Custom Metadata: My_Weather_Config__mdt (stores API key)
• Named Credential: Open_Weather_Service (endpoint abstraction)
• CSP Trusted Sites & Remote Site Settings (allow callouts)
f. Static Resources
g. External Service
• OpenWeather REST API
Relationships & Data Flow
1. User loads the Experience Cloud site in browser.
2. LWR template serves LWC components.
3. LWC invokes @AuraEnabled Apex controller methods (MW_OpenWeatherOneCallController).
4. Controller delegates to service layer (MW_OpenWeatherOneCallService).
5. Service constructs a callout using Named Credential + endpoint path from MW_UtilHelper (retrieves API key from Custom Metadata).
6. External HTTP request to OpenWeather API returns JSON.
7. JSON parsed into Apex model objects (MW_OpenWeatherOneCall, MW_OpenWeatherGeoLocation).
8. Controller returns structured data to LWC.
9. LWC populates UI elements (cards, panels) and uses PubSub to communicate between components.
Architectural Patterns & Principles
• MVC Separation:
• Model classes encapsulate JSON schema and parsing
• Service layer handles integration concerns
• Controller layer exposes Apex methods to LWC
• Service Abstraction: Named Credentials + Utility class for API key management
• Event-Bus (PubSub) for decoupled component communication
• Test-Driven Structure: Separate test classes alongside each Apex class