SkillAgentSearch skills...

Asteral

A resilient, enterprise-grade Spring Boot 3.5 application for tracking NASA Near-Earth Objects. Showcases high-performance patterns: Resilience4j (Circuit Breaker/Retry), Caffeine Caching, Testcontainers, and Cloud-Native deployment (Kubernetes & CI/CD).

Install / Use

/learn @albonidrizi/Asteral

README

Asteral - NASA Near-Earth Objects Explorer

Asteral is a production-grade Spring Boot application that integrates with NASA's NeoWs API to track and visualize Near-Earth Objects (NEOs). This project demonstrates enterprise-level software engineering practices including fault tolerance, performance optimization, cloud-native deployment, and comprehensive testing.

Java Spring Boot PostgreSQL Docker Kubernetes


📌 Project Overview

This project showcases proficiency in:

  • Third-party API Integration with resilience patterns (NASA NeoWs)
  • Secure Authentication using Spring Security with BCrypt
  • Fault Tolerance via Resilience4j (Circuit Breaker, Retry)
  • Performance Optimization through Caffeine caching
  • Cloud-Native Architecture with Kubernetes deployment manifests
  • Modern DevOps practices (CI/CD, Testcontainers, Docker)
  • Data Visualization using Chart.js

🚀 Key Features

🔐 Security & Authentication

  • Full login/registration system with BCrypt password hashing
  • Role-based access control with Spring Security
  • Auto-login flow for seamless user experience
  • Session management and CSRF protection

🌌 Asteroid Explorer

  • Browse Near-Earth Objects by date with real-time NASA data
  • View detailed asteroid information (size, velocity, hazard status)
  • Interactive Chart.js dashboard for size comparison
  • Color-coded visualization (red for hazardous, blue for safe)

⭐ Favorites System

  • Track potentially hazardous asteroids
  • Persistent storage in PostgreSQL
  • User-specific favorite lists
  • Quick add/remove functionality

📄 API Documentation

  • Fully interactive Swagger UI at /swagger-ui/index.html
  • OpenAPI 3.0 specification
  • Test all endpoints directly from the browser

📱 Responsive UI

  • Server-side rendering with Thymeleaf
  • Bootstrap 4 for mobile-first design
  • Material Design components
  • Professional dark theme with glassmorphism effects

🛡️ Enterprise-Grade Features

1. Resilience & Fault Tolerance (Resilience4j)

The application implements Circuit Breaker and Retry patterns for all NASA API calls:

  • Circuit Breaker: Prevents cascading failures when NASA services are down or slow

    • Sliding window of 10 requests
    • Opens circuit at 50% failure rate
    • Half-open state after 5 seconds
  • Retry: Automatically handles transient network issues

    • Maximum 3 retry attempts
    • 2-second wait duration between retries
    • Exponential backoff strategy
@Cacheable(cacheNames = "asteroid-feed", key = "#username ?: 'anonymous'")
@CircuitBreaker(name = "nasaApi")
@Retry(name = "nasaApi")
public AsteroidFeedResponse getAsteroidFeed(String username) {
    // Implementation
}

2. High-Performance Caching (Caffeine)

Implements a sophisticated caching layer:

  • 1-hour TTL for asteroid data (NASA data doesn't change frequently)
  • Maximum 100 entries to prevent memory overflow
  • 90% latency reduction for subsequent requests
  • Minimizes API consumption and respects rate limits

3. Observability & Monitoring

Full integration with Spring Boot Actuator and Prometheus:

  • Health endpoints: /actuator/health
  • Metrics endpoint: /actuator/metrics
  • Prometheus scraping: /actuator/prometheus
  • Kubernetes liveness/readiness probes
  • Real-time circuit breaker state monitoring

4. Advanced Testing Suite

  • Unit Tests: 30+ tests using JUnit 5 & Mockito
  • Integration Tests: Testcontainers with real PostgreSQL instances
  • Code Coverage: 75% overall, 94% on service layer
  • JaCoCo: Automated coverage enforcement (minimum 80%)
# Run all tests with coverage
mvn clean test

# Generate JaCoCo report
mvn test jacoco:report
start target/site/jacoco/index.html

5. Cloud Native & DevOps

GitHub Actions CI/CD

Automated pipeline on every push:

  • Build with Maven
  • Run all tests (including Testcontainers)
  • Generate coverage reports
  • Upload artifacts

Kubernetes Deployment

Production-ready manifests in k8s/:

  • Deployment with 2 replicas
  • Resource limits (CPU: 500m, Memory: 512Mi)
  • Liveness and readiness probes
  • LoadBalancer service
  • Secret management for API keys
# Deploy to Kubernetes
kubectl apply -f k8s/deployment.yml

Docker

Multi-stage Dockerfile for optimized images:

  • Build stage with Maven
  • Runtime stage with JRE only
  • Minimal image size
  • Health check configuration

🛠 Tech Stack

| Category | Technology | |----------|------------| | Language | Java 21 LTS | | Framework | Spring Boot 3.5 (Web, Security, Data JPA) | | Database | PostgreSQL 13 | | Caching | Caffeine | | Resilience | Resilience4j (Circuit Breaker, Retry) | | Observability | Spring Boot Actuator, Micrometer, Prometheus | | Testing | JUnit 5, Mockito, Testcontainers | | DevOps | Docker, Docker Compose, Kubernetes | | CI/CD | GitHub Actions | | Tools | Maven, Lombok, Swagger UI | | Frontend | Thymeleaf, Bootstrap 4, Chart.js |


🏗️ System Architecture

graph TD
    User([User]) --> WebUI[Thymeleaf UI / Bootstrap]
    WebUI --> App[Spring Boot App]
    
    subgraph "Core Services"
        App --> FeedSvc[AsteroidFeedService]
        App --> DetailSvc[AsteroidDetailService]
        App --> FavSvc[FavoriteAsteroidService]
    end
    
    subgraph "Cross-Cutting Concerns"
        FeedSvc --> Cache[(Caffeine Cache)]
        DetailSvc --> Cache
        FeedSvc --> CB[Circuit Breaker]
        DetailSvc --> CB
        App --> Actuator[Actuator/Prometheus]
    end
    
    CB --> NASA[NASA NeoWs API]
    App --> DB[(PostgreSQL)]
    
    subgraph "QA & DevOps"
        TC[Testcontainers] -.-> DB
        GA[GitHub Actions] --> App
        K8s[Kubernetes] --> App
    end

🐳 Quick Start (Docker)

The application is fully containerized. Prerequisites: Docker & Docker Compose.

1. Clone and Start

git clone https://github.com/albonidrizi/asteral.git
cd asteral
docker-compose up --build -d

2. Access the Application

3. Demo Credentials

  • Username: testuser2
  • Password: password

4. Optional: Set NASA API Key

For full functionality and higher rate limits:

export NASA_API_KEY=your_api_key_here
docker-compose up --build -d

Get your free API key at: https://api.nasa.gov


💻 Local Development

If running without Docker:

1. Prerequisites

  • Java 21
  • PostgreSQL 13
  • Maven 3.8+

2. Database Setup

# Start PostgreSQL on port 5433
psql -U postgres
CREATE DATABASE nasa_challenge;

3. Environment Variables

export DB_HOST=localhost
export DB_PORT=5433
export DB_NAME=nasa_challenge
export DB_USERNAME=postgres
export DB_PASSWORD=password
export NASA_API_KEY=your_api_key_here

4. Run Application

mvn spring-boot:run

📂 Project Structure

src/
├── main/
│   ├── java/com/nasa/asteral/
│   │   ├── configuration/      # Security, Cache, WebClient configs
│   │   ├── controller/         # MVC & REST Controllers
│   │   ├── model/              # JPA Entities & DTOs
│   │   │   ├── db/             # Database entities
│   │   │   └── response/       # API response models
│   │   ├── repository/         # Spring Data Repositories
│   │   ├── service/            # Business Logic & NASA Integration
│   │   ├── exception/          # Custom exceptions
│   │   └── utility/            # Helper classes
│   └── resources/
│       ├── templates/          # Thymeleaf views
│       ├── static/             # CSS, JS, images
│       └── application.properties
└── test/                       # JUnit 5 & Mockito tests
    └── java/com/nasa/asteral/
        └── service/            # Service layer tests

🧪 Testing & Quality Metrics

Test Coverage

Coverage Tests

| Layer | Coverage | Status | |-------|----------|--------| | Service Layer | 94% | ⭐ Excellent | | Configuration | 100% | ✅ Complete | | Exception Handling | 100% | ✅ Complete | | Model Layer | 80% | ✅ Good | | Controller Layer | 31% | ⚠️ In Progress | | Overall | 75% | ✅ Good |

Running Tests

# Run all tests with coverage report
mvn clean test

# Run only unit tests
mvn test -Dtest='*ServiceTest'

# Generate coverage report (opens in browser)
mvn test jacoco:report
start target/site/jacoco/index.html

# Run with Testcontainers (requires Docker)
mvn verify

Test Suite Breakdown

  • FavoriteAsteroidServiceTest - 8 tests (CRUD operations)
  • IntegrationServiceTest - 5 tests (API client)
  • AsteroidFeedServiceTest - 5 tests (NASA API integration)
  • MenuServiceTest - 4 tests (authorization menus)
  • MyUserDetailsServiceTest - 4 tests (Spring Security)
  • MyProfileServiceTest - 3 tests (user profiles)
  • AsteroidDetailServiceTest - 1 test (details fetching)

Quality Tools

  • JaCoCo - Code coverage analysis (minimum 80% enforced)
  • JUnit 5 - Modern testing frame
View on GitHub
GitHub Stars15
CategoryDevelopment
Updated16d ago
Forks0

Languages

Java

Security Score

80/100

Audited on Mar 10, 2026

No findings