Responsive weather application that shows current conditions and short‑term forecasts based on the user’s location or a searched city.
The interface provides a complete overview of temperature, feels‑like temperature, humidity, wind, precipitation, snow, air quality, cloud cover, pressure, visibility, UV index and daylight/nighttime hours, integrated with an interactive map.
The backend acts as a secure proxy to the external third‑party weather API, handling API keys and query parameters.
Angular 19with standalone components for the user interfaceTypeScriptfor strongly typed application logicRxJSfor reactive handling of HTTP callsAngular CLIand@angular-devkit/build-angularfor build, development and testingLeafletfor the interactive weather mapzone.jsfor Angular change detectionKarmaandJasminefor unit testingconcurrentlyto run frontend, backend and public tunnel in parallelapi/directory with serverless‑style backend functions (e.g. Vercel)- External weather service
WeatherAPI(consumed through the server‑side proxy)
- Clone the repository to your local machine.
- Move into the project folder:
cd weather-app - Install the dependencies:
npm install
- (Optional, for full‑stack development) Configure the environment variable
API_KEYwith your WeatherAPI key for the backend (api/forecast.js,api/searchSuggestion.js).
-
Start frontend only (if the backend is already deployed elsewhere):
npm start
-
Start both frontend and backend locally with
/apiproxied tohttp://localhost:3000:npm run start:all
start:backend: runs the backend environment (e.g.vercel dev) on port3000.start:frontend: runs Angular on port4200withproxy.conf.jsonfor routing/apicalls.
-
To access the application, open the browser at:
http://localhost:4200
On startup:
- If the user grants geolocation permissions, the app uses the browser coordinates to fetch forecasts.
- Alternatively, the user can search for a city via the search bar; the backend returns location suggestions and forecasts for the selected place.
- The interface displays a weather dashboard, hourly and daily charts, map, air‑quality indicators and other informative widgets.
weather-app/
├─ api/
│ ├─ forecast.js # Serverless-style function for weather forecasts
│ └─ searchSuggestion.js # Serverless-style function for search suggestions
├─ public/
│ ├─ desktop-application.png # Desktop screenshot
│ ├─ mobile-desktop.MP4 # Mobile preview (not embedded in README)
│ ├─ day.png, night.png # Day/night theme images
│ └─ icon.png # Application icon
├─ src/
│ ├─ main.ts # Angular bootstrap
│ ├─ index.html # Main HTML document
│ ├─ styles.scss # Global styles
│ └─ app/
│ ├─ app.component.* # Root component and main layout
│ ├─ app.config.ts # Routing/bootstrap configuration
│ ├─ app.service.ts # Service for geolocation and internal API calls
│ ├─ header/ # Header and main controls
│ ├─ search-bar/ # City search with suggestions
│ ├─ location-permission/ # Geolocation permission handling
│ ├─ week-temperature/ # Daily temperatures
│ ├─ hours-temperature/ # Hourly temperatures
│ ├─ feels-like-temperature/ # Feels-like temperature
│ ├─ uv/, humidity/, wind/ # UV, humidity and wind indicators
│ ├─ precipitation/, snow/ # Precipitation and snow
│ ├─ cloud-cover/, visibility/ # Cloud cover and visibility
│ ├─ air-quality/, pressure/ # Air quality and pressure
│ ├─ sun-hours/, moon-hours/ # Sunlight and nighttime hours
│ ├─ maps/ # Weather map with Leaflet
│ ├─ loading-item/ # Loading component
│ └─ menu/ # Side menu or settings
├─ angular.json # Angular workspace configuration
├─ proxy.conf.json # Proxy `/api` → `http://localhost:3000`
├─ package.json # NPM scripts and dependencies
├─ tsconfig*.json # TypeScript configuration files
└─ dist/ # Generated production build
-
Overall architecture
- Single Page Application based on Angular with the root component
AppComponent. - Standalone modular components for each widget (temperature, wind, UV, maps, etc.), imported into the root component.
AppServicecentralizes geolocation logic and internal API calls (/api/forecast,/api/searchSuggestion).
- Single Page Application based on Angular with the root component
-
Initial data flow
- In
ngOnInit,AppComponentcallsgetCurrentPosition()fromAppService, which usesnavigator.geolocationto obtain latitude and longitude from the browser. - On success, it calls
getForecast(lat, lon), which performs an HTTP GET request to the internal endpoint/api/forecast. - The response (weather forecast) is stored in
weatherData, and the loading state is set toresolved; in case of error, error messages and theerrorstate are set.
- In
-
Manual search and suggestions
- The search bar sends user input to
AppService, which calls:getSuggestions(query)→GET /api/searchSuggestionto obtain location suggestions.getForecastByCity(city)→GET /api/forecast?q={city}to load forecasts for the selected city.
AppComponentreceives events from child components (e.g. selected day/hour) and updatesselectedDayandhourSelected, propagating data to the widgets that require it.
- The search bar sends user input to
-
Weather widgets and helper logic
- Components such as
week-temperature,hours-temperature,uv,humidity,air-quality,sun-hours,moon-hours,wind,precipitation,snow,pressure,visibility,cloud-cover,mapsaccess specific portions ofweatherDatato display charts, indicators and maps. - Dedicated methods in
AppComponentcompute derived values, for example:- Previous pressure value relative to the selected hour (
OnprevPressure). - Upcoming days with precipitation (
OnPrecipitationForecastDay). - Upcoming days with snow (
OnSnowForecastDay).
- Previous pressure value relative to the selected hour (
- Utility components like
loading-itemandlocation-permissionmanage loading states and geolocation permission requests.
- Components such as
-
Backend and proxy
- The functions in
api/are designed as serverless endpoints:- They read parameters from the query string (
lat,lon,q,days,lang). - They validate input and check for the
API_KEYenvironment variable. - They call the external WeatherAPI service, handle errors and return normalized JSON to the frontend.
- They read parameters from the query string (
proxy.conf.jsonroutes all local/apirequests tohttp://localhost:3000, keeping frontend (port4200) and backend separated.
- The functions in
-
GET /api/forecast- Description: returns detailed weather forecasts and air‑quality information.
- Query parameters:
lat(number, optional) – latitude.lon(number, optional) – longitude.q(string, optional) – city name or"lat,lon"string as an alternative tolat/lon.days(string, optional, default3) – number of forecast days.lang(string, optional, defaultit) – language for WeatherAPI textual responses.
- Rules:
lat/lontake precedence; if not provided,qis used instead.- If no valid parameter is provided, the endpoint returns
400with an error message. - Requires
process.env.API_KEYto be set; otherwise returns500.
- Output:
- JSON compatible with the WeatherAPI
forecast.jsonresponse (current conditions, hourly and daily forecasts, air quality).
- JSON compatible with the WeatherAPI
-
GET /api/searchSuggestion- Description: provides location suggestions based on a search string.
- Query parameters:
q(string, required) – city or partial string, optionally"lat,lon".lang(string, optional, defaultit) – language for results.
- Rules:
- If
qis empty, the endpoint returns400with an error message. - Requires the
API_KEYenvironment variable; otherwise returns500.
- If
- Output:
- JSON array of results, structured like WeatherAPI
search.json.
- JSON array of results, structured like WeatherAPI
-
https://api.weatherapi.com/v1/forecast.json- Used by
api/forecast.js. - Main parameters:
key– API key (process.env.API_KEY).q– location (city name or"lat,lon").days– number of forecast days.aqi–yesto include air‑quality data.lang– language for textual descriptions.
- Used by
-
https://api.weatherapi.com/v1/search.json- Used by
api/searchSuggestion.js. - Main parameters:
key– API key (process.env.API_KEY).q– search string.lang– language for results.
- Used by
Integration happens exclusively through the project backend: the frontend calls /api endpoints, while the API_KEY is managed only on the server side.
- Deployed URL: https://mattiaortolani-weather-app.vercel.app/
- Development and maintenance: Mattia Ortolani
- The project is distributed without an explicit license: the code is publicly available for read‑only inspection only and may not be used, copied, modified or redistributed.

