How jpougano/challenge-charlie works
Project type and purpose
• This is a single-page application (SPA) built with Create-React-App that runs entirely in the browser.
• Its sole purpose is to fetch and display weather forecasts (current and future) and a dynamic background image based on the user’s location or a manually entered city.
File structure
• Top level:
• challenge/ – the React project root (contains package.json, public/, src/, .env template)
• README.md – explains use cases, APIs, and setup
• public/ – static assets (index.html)
• src/ – React source code
• components/
– Content/Content.js, Content/style.css
– Search/Search.js, Search/style.css
• helpers/WeatherTheme.js – logic to map weather to a theme
• style/style.css and font assets
• App.js, index.js
Key insights from the README
• External services used:
• Bing Image API (with AllOrigins CORS proxy)
• OpenWeather API
• OpenCage Geocoding API
• No backend or database—just public APIs and browser geolocation
• Styling and fonts are static CSS assets
Main components
a. Browser Client
• Geolocation API
• React SPA (static JS/CSS delivered from a CDN or host)
b. React Application internals
• UI Components
– Search component (user input, city lookup)
– Content component (renders weather data and theme)
• Helper modules
c. Build/Deployment
• Static hosting (e.g., S3/Netlify)
• Environment variables (.env) injected at build time for API keys
d. External Services
• AllOrigins CORS proxy (for Bing background)
• Bing Image API
• OpenCage Geocoding API
• OpenWeather Forecast API
Relationships and data flow
1. User opens the SPA in the Browser
2. Browser geolocation permission → returns coordinates
3. React App calls OpenCage API to reverse-geocode coordinates → city name
4. React App calls OpenWeather API with coordinates or city name → forecast data
5. React App calls AllOrigins → proxies Bing Image API → background image URL
6. Data flows back into UI components → Content renders forecast + dynamic CSS (via WeatherTheme)
7. On user-typed city search, steps (3)–(6) repeat with new input
Architectural patterns and principles
• Component-based modularity: separate Search vs. Content vs. helper logic
• Single data-flow direction: user action → API call → state update → UI render
• External dependency isolation: environment variables store API keys; CORS proxy isolates browser limitations
• Styling separation: CSS modules and global style sheet
• Break the system into as many meaningful components as possible
• External dependencies and where API keys come from (.env at build time)
• Data flow direction and sequence (geolocation → geocode → weather → image)
• Notes on hosting, build step, and environment variable injection