Welcome to the NASA API Implementation project! This full-stack web application utilizes NASA's public APIs to provide users with captivating Astronomy Picture Of The Day (APOD) and Mars Rover Photos. Developed as part of a 30-day development internship program, this project demonstrates the integration of various modern technologies to create a robust, secure, and user-friendly application.
Discover breathtaking astronomical imagery and fascinating Mars exploration photos through an intuitive interface, complete with administrative features for data management and a comprehensive API for developers.
- View the current APOD with detailed explanations
- Browse previously saved APODs
- Admin functionality to manage APOD entries (CRUD operations)
- Select from three different Mars rovers:
- Curiosity
- Opportunity
- Spirit
- Choose from multiple cameras on each rover:
- FHAZ (Front Hazard Avoidance Camera)
- RHAZ (Rear Hazard Avoidance Camera)
- MAST (Mast Camera)
- CHEMCAM (Chemistry and Camera Complex)
- MAHLI (Mars Hand Lens Imager)
- MARDI (Mars Descent Imager)
- NAVCAM (Navigation Camera)
- PANCAM (Panoramic Camera)
- MINITES (Miniature Thermal Emission Spectrometer)
- Filter photos by Earth date
- Custom login page with JWT authentication
- Role-based access control (EMPLOYEE and ADMIN roles)
- OAuth2 resource server integration
- Protected API endpoints
- Comprehensive Swagger documentation
- RESTful API endpoints for APOD and Mars Rover data
- Detailed error handling
- Spring Boot 3 and Spring Framework 6 for application framework
- Spring MVC for web layer
- Spring Data JPA for data access
- Spring Security with JWT for authentication and authorization
- MySQL for database storage
- Swagger/OpenAPI for API documentation
- Thymeleaf for server-side templating
- Bootstrap for responsive UI components
- HTML5/CSS3 for markup and styling
- Docker for containerization
- AWS Elastic Beanstalk for cloud deployment
- Maven for dependency management
The application follows a layered architecture:
βββ com.openapi.nasa
β βββ NasaApiApplication.java (Main application class)
β βββ daorepo (Data Access Layer)
β β βββ NasaRepository.java
β βββ entity (Entity Classes)
β β βββ NasaApod.java
β βββ exceptionHandler (Error Handling)
β β βββ NasaErrorResponse.java
β β βββ NasaGlobalExceptionHandler.java
β β βββ NasaNotFoundException.java
β βββ model (Model Classes)
β β βββ MarsRover.java
β β βββ MarsRoverCamera.java
β β βββ MarsRoverPhoto.java
β β βββ RoverPhotoRequests.java
β βββ mvcController (Web Controllers)
β β βββ LoginController.java
β β βββ NasaMvcController.java
β βββ response (Response Objects)
β β βββ MarsRoverPhotosResponse.java
β βββ rest (REST Controllers)
β β βββ NasaApiController.java
β βββ security (Security Configuration)
β β βββ JwtAuthenticationResource.java
β β βββ OpenApiConfig.java
β β βββ SecurityConfiguration.java
β βββ service (Service Layer)
β βββ NasaApiService.java
β βββ NasaApiServiceImpl.java
βββ resources
β βββ templates
β βββ nasa
β βββ access-denied.html
β βββ apod.html
β βββ custom-login.html
β βββ custom-login-2.html
β βββ home-page.html
β βββ index.html
β βββ list-apods.html
β βββ result.html
β βββ update-apod-form.html
flowchart TD
START([User Accesses Application]) --> LOGIN{Login Required?}
LOGIN -->|Yes| AUTH[Authentication Process]
LOGIN -->|No| GUEST[Limited Guest Access]
AUTH -->|Success| ROLE{Verify Role}
AUTH -->|Failure| LOGIN_ERROR[Show Error Message]
ROLE -->|EMPLOYEE| HOME[Home Page]
ROLE -->|ADMIN| HOME
HOME --> APOD_VIEW[View APOD]
APOD_VIEW --> NASA_APOD[Fetch from NASA APOD API]
HOME --> ROVER_SELECT[Mars Rover Selection]
ROVER_SELECT --> SELECT_PARAMS[Select Parameters]
SELECT_PARAMS --> FETCH_PHOTOS[Fetch Mars Rover Photos]
FETCH_PHOTOS --> DISPLAY_PHOTOS[Display Rover Photos]
APOD_VIEW -->|Admin Only| MANAGE_APOD{Manage APOD Options}
MANAGE_APOD -->|Add/Update/Delete| DB_OPS[(Database Operations)]
- Java 17 or higher
- Maven 3.6+
- MySQL 8.0+
- NASA API Key (register at https://api.nasa.gov/)
-
Clone the repository
git clone https://github.com/yourusername/nasa-api-implementation.git cd nasa-api-implementation -
Configure application properties
- Create
application.propertiesinsrc/main/resources - Add the following configurations:
# Database Configuration spring.datasource.url=jdbc:mysql://localhost:3306/nasa_db spring.datasource.username=your_username spring.datasource.password=your_password spring.jpa.hibernate.ddl-auto=update # NASA API Configuration nasa.api.key=your_nasa_api_key # Server Configuration server.port=5000
- Create
-
Set up database
- Create a MySQL database named
nasa_db - Create tables for user authentication:
CREATE TABLE nasa_members ( user_id VARCHAR(50) NOT NULL, pw VARCHAR(100) NOT NULL, active BOOLEAN NOT NULL, PRIMARY KEY (user_id) ); CREATE TABLE nasa_roles ( user_id VARCHAR(50) NOT NULL, role VARCHAR(50) NOT NULL, PRIMARY KEY (user_id, role), FOREIGN KEY (user_id) REFERENCES nasa_members(user_id) ); -- Add an admin user INSERT INTO nasa_members (user_id, pw, active) VALUES ('admin', '{bcrypt}$2a$10$dXJ3SW6G7P50lGmMkkmwe.20cQQubK3.HZWzG3YB1tlRy.fqvM/BG', true); INSERT INTO nasa_roles (user_id, role) VALUES ('admin', 'ROLE_ADMIN'); INSERT INTO nasa_roles (user_id, role) VALUES ('admin', 'ROLE_EMPLOYEE'); -- Add a regular user INSERT INTO nasa_members (user_id, pw, active) VALUES ('user', '{bcrypt}$2a$10$dXJ3SW6G7P50lGmMkkmwe.20cQQubK3.HZWzG3YB1tlRy.fqvM/BG', true); INSERT INTO nasa_roles (user_id, role) VALUES ('user', 'ROLE_EMPLOYEE');
Note: The encrypted password is 'test123'
- Create a MySQL database named
-
Build the application
mvn clean install
-
Run the application
mvn spring-boot:run
-
Access the application
- Web interface: http://localhost:5000/nasa/home-page
- Swagger documentation: http://localhost:5000/swaggerdoc.html
GET /api/apod- Get current APODGET /api/apods- Get all stored APODsGET /api/save-apod- Save current APOD to databaseGET /api/apod/{apodId}- Get APOD by IDPUT /api/apod/{apodId}- Update APODDELETE /api/apod/{apodId}- Delete APOD
GET /api/rover/{roverName}/{earthDate}/{roverCamera}- Get Mars Rover photos
POST /authenticate- Get JWT tokenGET /get-token- Alternative method to get JWT token
-
EMPLOYEE Role:
- View APOD
- Access Mars Rover photos
- Access basic API endpoints
-
ADMIN Role:
- All EMPLOYEE permissions
- Manage APOD entries (create, update, delete)
- Access administrative endpoints
- Day 1-2: Project structure setup and requirements analysis
- Day 3-4: Entity design and repository implementation
- Day 5-7: NASA API integration for APOD and Mars Rover
- Day 8-10: MVC controller implementation
- Day 11-12: Thymeleaf template development
- Day 13-14: REST API implementation
- Day 15-17: Spring Security configuration with JWT
- Day 18-19: Role-based access control implementation
- Day 20-21: Exception handling and validation
- Day 22-24: UI enhancement and responsive design
- Day 25-26: Swagger documentation and API testing
- Day 27-28: Docker containerization and deployment preparation
- Day 29-30: Final testing and deployment to AWS Elastic Beanstalk
The Mars Rover endpoint allows for precise filtering of Mars photos:
/api/rover/{roverName}/{earthDate}/{roverCamera}
Examples:
/api/rover/curiosity/2015-06-03/fhaz- Get photos from Curiosity's front hazard camera from June 3, 2015/api/rover/opportunity/2018-01-10/pancam- Get photos from Opportunity's panoramic camera from January 10, 2018/api/rover/spirit/2010-02-15/navcam- Get photos from Spirit's navigation camera from February 15, 2010
If you access /swaggerdoc.html directly without logging in, you can use the bearer token (JWT Authentication) for authorization. To get a JWT Bearer token, use the endpoint: /get-token (e.g., http://localhost:5000/get-token).
Alternatively, you can use normal credentials to access http://localhost:5000/swaggerdoc.html.
This project was developed as part of a 30-day internship program. While it's primarily for educational purposes, contributions are welcome. Please feel free to fork the repository, make improvements, and submit pull requests.
For any questions or support regarding this project, please contact:
- Email: varungrvv@gmail.com
This project is licensed under the MIT License - see the LICENSE file for details.
- NASA Open APIs for providing access to incredible space data
- Spring Framework for the robust application framework
- All the interns who contributed to the development of this project
Developed with β€οΈ during the 30-day Development Internship Program.