- File:
src/components/Dashboard.js - Purpose: Renders the three widget components (
UserStats,Weather,Crypto) in a grid layout. - Reason: Centralizes the dashboard layout and ensures widgets are modular, making it easy to add or remove widgets as needed.
- UserStats.js: Displays mock user statistics (Total Users, Active Domains, Companies, Cities) with a static API response.
- Weather.js: Fetches weather data using the Open-Meteo API based on geolocation, including temperature, elevation, and wind speed.
- Crypto.js: Fetches cryptocurrency prices (Bitcoin, Ethereum, Cardano) using a mock API response.
- Reason: Each widget is isolated to handle specific data types, improving readability and scalability. Public APIs ensure real-time data simulation.
- useApi.js: Handles API data fetching with loading, error, and lastUpdated states.
- useAutoRefresh.js: Implements a 10-second auto-refresh for each widget using
setInterval. - useGeolocation.js: Retrieves latitude, longitude, and address using the browser's geolocation API and Nominatim for reverse geocoding.
- Reason: Custom hooks encapsulate reusable logic, reduce code duplication, and enhance performance by managing state and side effects efficiently.
- Auto-refresh is set to 10 seconds as per requirements, using
useAutoRefreshto avoid manual interval management. - Modular component design minimizes re-renders and optimizes resource usage.
- Reason: Ensures real-time updates without overwhelming the UI or API, aligning with the performance optimization goal.
- Open-Meteo API: For weather data based on geolocation.
- Mock API: Simulated for UserStats and CryptoPrices to mimic real API behavior.
- Nominatim (OpenStreetMap): For reverse geocoding to get the address from coordinates.
- Displays the dashboard with three widgets side by side on a larger screen.
- Last updated timestamps are visible for each widget (e.g., 3:44:52 PM EAT).
- Stacks widgets vertically for better readability on smaller screens.
- Maintains all data points with adjusted styling for mobile responsiveness.
- Clone the repository:
git clone https://github.com/MainaMwangiy/dashboard-challenge - Navigate to the project directory:
cd dashboard-challenge - Install dependencies:
npm installoryarn install - Start the development server:
npm startoryarn start - Open
http://localhost:3000in your browser.
- Geolocation Accuracy: Handled potential errors with fallback values and error messages in
useGeolocation. - API Rate Limits: Used mock data where necessary to simulate API behavior without exceeding limits.
- Responsive Design: Ensured widgets adapt to mobile and desktop using CSS flexbox and media queries.
- Add error boundaries for better robustness.
- Implement lazy loading for widgets to improve initial load time.
- Enhance styling with Tailwind CSS for rapid UI adjustments.
This project meets the requirements for the 1st round interview assessment for the Frontend Software Engineer role at iZone Africa Limited. The code is submitted within 24 hours as requested.
Thank you for the opportunity!

