AsteroidAlert is a modern, full-stack application designed to provide real-time alerts about potentially hazardous asteroids. It features a scalable Spring Boot microservices backend and a dynamic React.js frontend. The system fetches data directly from NASA's NeoWs (Near Earth Object Web Service) API, processes it to identify threats, and notifies users via email.
Secure sign-in using Google Authentication.
A personalized dashboard welcoming the user.
A history of all past asteroid alert notifications.
Further details about the asteroid selected.
Users can view detailed information about each alert and manage their notification settings.
System Architecture Diagram
- Secure User Authentication: Seamless and secure user login using Google Sign-In (OAuth 2.0).
- Real-time NASA Data: Fetches near-earth object data directly from the official NASA NeoWs API.
- Hazardous Asteroid Identification: Intelligently filters and identifies asteroids that are classified as potentially hazardous.
- Asynchronous Email Alerts: Leverages Apache Kafka to send timely and non-blocking email notifications to users about potential threats.
- Notification History: Provides users with a comprehensive history of all past asteroid alerts they have received.
- User-Managed Settings: Allows users to enable or disable their email notification preferences at any time.
- Scalable Microservices Architecture: Built with two core microservices for handling data retrieval and user notifications independently.
- Containerized Deployment: Fully containerized with Docker and Docker Compose for a streamlined, one-command setup.
- AsteroidAlert Service: This service is responsible for communicating with the NASA NeoWs API. It fetches the asteroid data for a given date range, filters for potentially hazardous objects, and publishes the findings as events to a Kafka topic.
- Notification Service: This service acts as the user-facing backend. It manages user authentication, stores user data and notification history in a MySQL database, consumes events from the Kafka topic, and sends out email alerts to subscribed users.
- The AsteroidAlert Service acts as a Kafka producer, publishing
AsteroidCollisionEventmessages whenever a hazardous asteroid is detected. - The Notification Service acts as a Kafka consumer, listening to the
asteroid-alerttopic. Upon receiving an event, it saves the alert to the database and triggers theEmailServiceto notify the relevant users. This decoupled approach ensures that the data fetching process is not blocked by the notification sending process, enhancing scalability and resilience.
- The Notification Service uses its own MySQL database instance to store all user-related data, including user profiles, settings, and a complete history of notifications. This ensures a clear separation of concerns between the services.
- Backend: Java 21, Spring Boot, Spring Security (OAuth2/JWT), Spring Kafka, Spring Data JPA
- Frontend: React.js, Vite
- Database: MySQL
- Messaging: Apache Kafka, Zookeeper
- Authentication: Google Identity Services (OAuth 2.0)
- Containerization: Docker, Docker Compose
- Mail Service: Mailtrap (for development)
- Docker ≥ 20.10
- Docker Compose ≥ 1.29
- Git
-
Clone the repository
git clone https://github.com/your-username/AsteroidAlert.git cd AsteroidAlert -
Configure Environment Variables You will need to set up your own API keys and credentials in the
application.propertiesfiles for both theAsteroidAlertandnotificationservicemodules.- NASA API Key (
nasa.api.key) - Google Client ID (
google.client-id) - Mailtrap credentials (
spring.mail.*) - Database credentials (
spring.datasource.*)
- NASA API Key (
-
Build and start all services
docker-compose up --build
-
Open the React frontend at
http://localhost:5173
AsteroidAlert-main/
├── AsteroidAlert/ # Spring Boot AsteroidAlert Service
│ ├── src/main/java/
│ └── pom.xml
├── notificationservice/ # Spring Boot Notification Service
│ ├── src/main/java/
│ └── pom.xml
├── client/ # React.js SPA
│ └── Asteroid/
│ ├── src/
│ └── package.json
├── docker-compose.yml # Orchestrates all containers
└── README.md # Project documentation
- The React app redirects users to Google for sign-in.
- Upon successful authentication, Google returns a JWT ID Token to the client.
- The React frontend stores this token and includes it in the
Authorization: Bearerheader for all subsequent API calls to the backend. - The Spring Boot Notification Service is configured as an OAuth 2.0 Resource Server. It validates the incoming JWT against Google's public keys to authenticate the user and secure its endpoints.





