Overview
The NASA Explorer app uses multiple model classes to represent data across different layers of the architecture. This page documents the response models, domain models, and favorite models.Architecture Layers
Data Layer
NasaResponse - Raw API response mappingDomain Layer
NasaModel - Business logic modelPersistence Layer
FavoriteNasaModel - Firebase storage modelNasaResponse (Data Layer)
Maps the complete structure of NASA’s APOD API response using Gson serialization.Fields
Title of the astronomy picture or video
URL of the standard resolution media
Date of the APOD in YYYY-MM-DD format
Detailed explanation of the astronomical content
Type of media: “image” or “video”
URL of the high-definition version (if available)
Version of the APOD API service
Copyright information for the media
Extension Function
Converts API response to domain model:The extension function filters out optional fields, keeping only essential data for the UI layer.
NasaModel (Domain Layer)
Simplified model containing only the data needed for business logic and UI rendering.Purpose
Decouples data layer from business logic and UI
Simplifies UI components by providing only necessary fields
Protects against API changes affecting the entire application
Fields
Display title for the astronomy image
Image or video URL for display
Date in YYYY-MM-DD format for sorting and display
Full explanation text for detail screens
Usage Example
FavoriteNasaModel (Persistence Layer)
Model for storing favorite images in Firebase with unique identifiers.Fields
Unique ID generated by Firebase for each saved image
Title of the favorited astronomy image
Image URL for display in favorites list
Purpose
The
firebaseImageId is essential for:- Uniquely identifying favorites in Firebase
- Enabling delete operations
- Linking images to user comments
Usage Example
Model Transformation Flow
Best Practices
Use data classes for automatic
equals(), hashCode(), and copy() implementations.Related Components
- NASA API Service - Network calls returning
NasaResponse - NASA Repository - Transforms responses to domain models