The USGS Earthquake Tracker is a full-stack application that provides real-time visualization of earthquake data from the United States Geological Survey (USGS). It combines a Spring Boot backend with a React frontend to fetch, process, and display earthquake information and seismograph data.
- Java 17
- Spring Boot 2.6.3
- Spring Web
- Spring WebFlux
- Project Lombok
- Jackson (for JSON processing)
- Maven (for dependency management)
- React 17
- Chart.js and react-chartjs-2 (for seismograph visualization)
- Google Maps JavaScript API (for mapping earthquakes)
- USGS Earthquake API
- Google Maps JavaScript API
The application follows a microservices architecture with a clear separation between the backend and frontend:
-
Spring Boot Backend:
- Fetches real-time earthquake data from the USGS API
- Processes and serves data to the frontend via RESTful endpoints
- Generates mock seismograph data for visualization
-
React Frontend:
- Consumes data from the backend API
- Renders an interactive map using Google Maps API
- Displays a seismograph chart using Chart.js
-
EarthquakeTrackerApplication: The main Spring Boot application class.
-
WebConfig: Configures CORS settings for cross-origin requests.
-
EarthquakeController: Handles HTTP requests for earthquake data.
-
SeismographController: Manages requests for seismograph data.
-
EarthquakeService: Business logic for processing earthquake data.
-
SeismographService: Generates mock seismograph data.
-
USGSApiClient: Utilizes WebClient to fetch data from the USGS API.
-
Earthquake: Model class representing earthquake data.
-
SeismographData: Model class for seismograph data.
-
App.js: Main React component orchestrating the application.
-
EarthquakeMap.js: React component for rendering the Google Maps interface.
-
SeismographChart.js: React component for displaying seismograph data using Chart.js.
GET /api/earthquakes
: Retrieves recent earthquake data.GET /api/seismograph
: Fetches seismograph data.
- JDK 17 or later
- Node.js and npm
- Maven
- Google Maps API key
- Clone the repository.
- Navigate to the project root directory.
- Run
mvn clean install
to build the project and download dependencies. - Start the Spring Boot application using
mvn spring-boot:run
.
- Navigate to the
frontend
directory. - Run
npm install
to install dependencies. - Create a
.env
file and add your Google Maps API key:REACT_APP_GOOGLE_MAPS_API_KEY=your_api_key_here
- Start the React development server with
npm start
.
- Ensure the Spring Boot backend is running on
http://localhost:8080
. - Start the React frontend, which will run on
http://localhost:3000
. - Access the application through a web browser at
http://localhost:3000
.
- Real-time Earthquake Data: Fetches and displays the latest earthquake information from USGS.
- Interactive Map: Visualizes earthquake locations using Google Maps, with markers indicating magnitude and location.
- Seismograph Visualization: Displays a mock seismograph chart for educational purposes.
- Responsive Design: Adapts to various screen sizes for optimal viewing on different devices.
- The backend periodically fetches earthquake data from the USGS API.
- Earthquake data is processed and stored in-memory.
- The frontend requests data from the backend API.
- Received data is rendered on the map and in the seismograph chart.
- The application uses reactive programming (WebFlux) for efficient handling of concurrent requests.
- Frontend optimizations include lazy loading of components and efficient re-rendering strategies.
- CORS is configured to allow requests only from the frontend origin.
- The Google Maps API key should be kept confidential and not exposed in public repositories.
- Implement real-time updates using WebSocket connections.
- Add user authentication and personalized earthquake alerts.
- Integrate machine learning models for earthquake prediction.
- Expand the application to include historical earthquake data analysis.