An open API service indexing awesome lists of open source software.

https://github.com/kislaykashyap-hub/weather-forecast-lwc

Welcome to the Weather Forecast LWC Project! This Salesforce Lightning Web Component (LWC) app connects to the OpenWeather API to bring you real-time weather updates.
https://github.com/kislaykashyap-hub/weather-forecast-lwc

apex github html javascript lwc-component openweather-api salesforce sfdx soql xml

Last synced: 27 days ago
JSON representation

Welcome to the Weather Forecast LWC Project! This Salesforce Lightning Web Component (LWC) app connects to the OpenWeather API to bring you real-time weather updates.

Awesome Lists containing this project

README

        

# 🌦️ **Weather Forecast LWC Project** 🌍

### **Overview** πŸš€

Welcome to the **Weather Forecast LWC Project**! This Salesforce Lightning Web Component (LWC) app connects to the [OpenWeather API](https://openweathermap.org/api) to bring you **real-time weather updates**. The app lets you:
- Fetch a **5-day weather forecast** by entering a **city name** πŸŒ†.
- Automatically fetch weather data based on the **Billing City** of an **Account** record 🏒.

---

### **Key Features** ✨

1. **City-Based Weather Forecast** πŸŒ‡:
- Enter a city name to get a **5-day weather forecast**.
- Displays temperature, date, and weather conditions in a **user-friendly table**.

2. **Billing City-Based Weather Forecast** πŸ™οΈ:
- Automatically fetches weather data for the **Billing City** of an `Account` record.
- Perfect for Account-specific insights! πŸ—ΊοΈ

3. **Reusable Weather Table** πŸ”„:
- A **reusable** LWC component that can be used across different parts of your app to display weather data.

---

### **How It Works** πŸ”„

1. **City-Based Forecast** πŸŒ‡:
- Go to the page with `searchWeather` and enter a city name.
- Click **Search** to display the 5-day forecast in a table.

2. **Billing City Forecast** πŸ™οΈ:
- Go to an `Account` record that has the `Billing City` filled.
- The `weatherForecastByBillingCity` component will automatically show the weather for the **Billing City**.

---

### **Screenshots** πŸ“Έ

#### City-Based Weather Forecast
![City Weather](images/SearchWeather.png)

#### Billing City Weather Forecast
![Billing City Weather](images/BillingCity.png)

---

### **Project Structure** πŸ“‚
```
Weather-Forecast-LWC/
β”œβ”€β”€ force-app/
β”‚ └── main/
β”‚ └── default/
β”‚ β”œβ”€β”€ aura/
β”‚ β”œβ”€β”€ classes/
β”‚ β”‚ └── WeatherForecastController.cls
β”‚ β”œβ”€β”€ lwc/
β”‚ β”‚ β”œβ”€β”€ SearchWeatherForecoast/
β”‚ β”‚ β”œβ”€β”€ ForecastByBillingCity/
β”‚ β”‚ └── WeatherTableForecast/
β”‚ └── layouts/
β”œβ”€β”€ .gitignore
β”œβ”€β”€ README.md
└── images/
β”œβ”€β”€ SearchWeather.png
└── BillingCity.png
```

---

### **Setup Instructions** πŸ› οΈ

#### **1. Prerequisites** πŸ“‹
- **Salesforce Developer Org** or **Sandbox** (Make sure you have **API access** enabled).
- [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli) installed.
- **OpenWeather API Key** (Sign up [here](https://openweathermap.org/api) to get one).

#### **2. Clone the Repo** πŸ“₯
```bash
git clone https://github.com/KislayKashyap-hub/Weather-Forecast-LWC.git
cd Weather-Forecast-LWC
```

#### **3. Deploy to Salesforce** πŸš€
```bash
sfdx force:source:deploy -p force-app
```

#### **4. Add Remote Site Settings** πŸ”§
Go to **Setup** β†’ **Remote Site Settings** β†’ **New Remote Site** and add:
- **Name**: `OpenWeatherAPI`
- **URL**: `https://api.openweathermap.org`

#### **5. Replace API Key** πŸ”‘
Replace `YOUR_API_KEY` in the `WeatherController` Apex class with your actual OpenWeather API key:
```apex
String endpoint = 'https://api.openweathermap.org/data/2.5/forecast?q=' + cityName + '&appid=YOUR_API_KEY&units=metric';
```

#### **6. Assign Components** πŸ”²
- **Search Weather Component**: Add `searchWeather` to any Lightning App Page.
- **Billing City Weather Component**: Add `weatherForecastByBillingCity` to an `Account` Lightning Record Page.

---

### **Improvements & Future Enhancements** 🚧

- **Error Handling**: Add better handling for incorrect city names or empty `BillingCity`.
- **Secure the API Key**: Use Salesforce **Custom Metadata** or **Custom Settings** for storing the API key securely.
- **UI Enhancements**: Display more weather details like wind speed, humidity, etc.
- **Test Classes**: Improve the test coverage for Apex code to ensure reliability.

---

### **License** πŸ“œ
This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.

---

### **Contributing** 🀝
Contributions are welcome! Feel free to fork the repository, create a new branch, and submit a pull request.

---

### **Contact** πŸ“¬

You can reach out to me on the following platforms:

- πŸ“§ **Email**: [[email protected]](mailto:[email protected])
- 🌐 **LinkedIn**: [Kislay Kumar](https://www.linkedin.com/in/kislay-kumar-kk/)
- πŸ”— **Trailhead**: [Kislay Kumar on Trailhead](https://www.salesforce.com/trailblazer/g88z22m1ullatkw2wr)

---

### **Connect & Follow** 🌍

Let’s stay connected and keep building amazing projects together! πŸš€