This module handles the complete backend data flow for the Earthquake Globe project. It connects to the live USGS Earthquake API, fetches real-time earthquake data, processes the GeoJSON response, and provides clean formatted data for the 3D Globe and Dashboard modules.
- Fetch live earthquake data from USGS API
- Process and clean raw GeoJSON data
- Create reusable API utility functions
- Handle API errors and loading states
- Implement live auto-refresh system
- Provide structured data for visualization
https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php
https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson✅ Real-time earthquake data fetching
✅ GeoJSON data processing
✅ Auto-refresh every 60 seconds
✅ Error handling system
✅ Reusable React hooks
✅ Clean formatted earthquake objects
src/
│
├── services/
│ └── usgsApi.js
│
├── hooks/
│ └── useEarthquakeData.js
│
├── utils/
│ └── filterData.js
│
└── mock/
└── mockEarthquakeData.json- JavaScript (ES6+)
- React
- Vite
- Fetch API
- USGS GeoJSON API
Clone repository:
git clone <repository-url>Install dependencies:
npm installRun development server:
npm run devconst API_URL =
"https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson";
export async function fetchEarthquakeData() {
try {
const response = await fetch(API_URL);
const data = await response.json();
�OB return data.features.map((quake) => ({
magnitude: quake.properties.mag,
place: quake.properties.place,
time: quake.properties.time,
lat: quake.geometry.coordinates[1],
lng: quake.geometry.coordinates[0],
depth: quake.geometry.coordinates[2],
}));
} catch (error) {
�OB console.error("Error fetching earthquake data:", error);
}
}�OB---
setInterval(fetchEarthquakeData, 60000);{
"magnitude": 5.4,
�OB "place": "Indonesia",
"time": 1715660000000,
"lat": -2.45,
"lng": 118.22,
�OB "depth": 35
}�OB | Field | Description | �OB|------|-------------| | magnitude | Earthquake magnitude | �OB| place | Earthquake location | �OB| time | Timestamp | | lat | Latitude | �OB| lng | Longitude | | depth | Depth in KM |
�OB
feature/api-systemfeature/usgs-fetch
feature/data-processing
feature/live-syncThis module supplies processed earthquake data to:
- 🌍 Globe Visualization Module
- 📈 Dashboard & Analytics Module
Role: Backend/API & Data Processing
Project: Live Earthquake Globe
Technology: React + USGS API + JavaScript