Loading repository data…
Loading repository data…
sachithasamadhib / repository
Fidenz Weather App – A full-stack application that retrieves and displays real-time weather information using the OpenWeatherMap API. The app includes secure authentication and authorization with Auth0, multi-factor authentication (MFA), data caching, and a responsive UI
A secure, full‑stack weather application built for the Fidenz Technologies assignment. It consists of a Spring Boot (Java 21) backend that fetches current weather from OpenWeatherMap and a React + Vite + TypeScript frontend secured with Auth0. Caching is implemented with Caffeine to reduce API calls.
.
├─ fidenz-backend/
│ └─ fidenz-weather-app/ # Spring Boot 3 app (Java 21)
│ ├─ src/main/java/com/fidenz/assignment/fidenz_weather_app
│ │ ├─ config/ # Security, caching, RestTemplate, exception handling
│ │ ├─ controller/ # WeatherController (REST endpoints)
│ │ ├─ model/ # WeatherResponse DTO
│ │ └─ service/ # WeatherService (OpenWeatherMap calls)
│ ├─ src/main/resources/
│ │ ├─ application.properties # Uses env/.env via spring-dotenv
│ │ └─ cities.json # Seed list of city codes
│ └─ pom.xml
└─ fidenz-frontend/
└─ frontend/ # React + Vite + TS + Tailwind
├─ src/
│ ├─ api/weatherApi.ts # Axios instance w/ Auth0 bearer token
│ ├─ auth/AuthProvider.tsx # Auth0 provider wiring (RBAC scopes)
│ ├─ components/ # Navbar, WeatherCard
│ ├─ pages/ # Dashboard (grid), CityDetail (details page)
│ └─ config.ts # Frontend env config
├─ index.html, vite.config.ts, package.json
└─ eslint.config.js
read:weatherfrontend.origin)Login Page
Dashboard
City Detail
Both apps are configured via environment variables. The backend additionally supports a .env file (thanks to spring-dotenv).
fidenz-backend/fidenz-weather-app/)api_key — OpenWeatherMap API keyurl — OpenWeatherMap current weather endpoint (default recommended: https://api.openweathermap.org/data/2.5/weather)frontend_origin — Frontend origin for CORS (e.g., http://localhost:5173)issuer — Auth0 issuer URL (e.g., https://YOUR_TENANT.us.auth0.com/ with trailing slash)audience — Auth0 API identifier (must match the API you create in Auth0)These map to application.properties:
spring.application.name=fidenz-weather-app
server.port=8080
openweathermap.api.key=${api_key}
openweathermap.api.url=${url}
spring.cache.type=caffeine
frontend.origin=${frontend_origin}
spring.security.oauth2.resourceserver.jwt.issuer-uri=${issuer}
spring.security.oauth2.resourceserver.jwt.audience=${audience}
fidenz-frontend/frontend/)VITE_API_BASE_URL — API base URL (default: http://localhost:8080/api)VITE_AUTH0_DOMAIN — Auth0 domain (bare domain only, e.g., dev-xxxx.us.auth0.com)VITE_AUTH0_CLIENT_ID — Auth0 SPA Client IDVITE_AUTH0_AUDIENCE — Auth0 API identifier (same value as backend audience)VITE_AUTH0_SCOPE — Default: openid profile email read:weatherVITE_AUTH0_REDIRECT_URI — Optional; default uses window.location.originNotes:
VITE_AUTH0_DOMAIN or VITE_AUTH0_CLIENT_ID are missing.VITE_AUTH0_DOMAIN must be a domain only (no protocol or slashes).https://fidenz-weather-api (use this as audience in both apps)read:weatherhttp://localhost:5173http://localhost:5173http://localhost:5173read:weather to your user (or via a role) so it appears in the token.Backend accepts authorities from both scope and permissions claims, mapping them to SCOPE_* internally.
Backend (in fidenz-backend/fidenz-weather-app/):
.env with the variables shown above./mvnw.cmd spring-boot:run./mvnw.cmd clean package then run java -jar target/fidenz-weather-app-0.0.1-SNAPSHOT.jarFrontend (in fidenz-frontend/frontend/):
.env with the variables shown abovenpm installnpm run dev (Vite defaults to http://localhost:5173)Ensure backend frontend_origin matches the dev server origin exactly.
Base URL: ${VITE_API_BASE_URL} (defaults to http://localhost:8080/api)
Security: Bearer token (Auth0) with scope read:weather
/weather
WeatherResponse[] for all cities from cities.json/weather/{cityId}
WeatherResponse for the requested cityWeatherResponse shape:
{
"cityID": "1248991",
"cityName": "Colombo",
"description": "broken clouds",
"temperature": 30.5,
"tempMin": 29.0,
"tempMax": 32.0,
"pressure": 1012,
"humidity": 70,
"visibility": 10000,
"windSpeed": 4.12,
"windDegree": 240,
"sunrise": 1726890210,
"sunset": 1726933899
}
Error responses (examples):
{ "error": "bad_request", "message": "..." }{ "error": "server_error", "message": "..." }@Cacheable("weather"))src/main/resources/cities.json contains the default list of city codesfrontend_origin matches the exact origin reported by the browser (protocol, host, and port)VITE_AUTH0_DOMAIN, VITE_AUTH0_CLIENT_ID, and VITE_AUTH0_AUDIENCEread:weather permission and RBAC is enabledissuer must be the full issuer URL with a trailing slashapi_key and url are correct and reachable from the backendmvn clean package produces target/fidenz-weather-app-0.0.1-SNAPSHOT.jar
api_key, url, issuer, audience, frontend_originnpm run build generates a production build in dist/
VITE_* at build time (they’re baked into the bundle).WeatherController (@PreAuthorize("hasAuthority('SCOPE_read:weather')")), JWT audience/issuer validation, and strict CORSCacheConfigThis codebase is provided for evaluation as part of an assignment.