Overview
The data model layer contains Data Transfer Objects (DTOs) that represent the JSON structure returned by the Space Flight News API. These DTOs are mapped to domain models for use in the application. Package:com.bsvillarraga.spaceflightnews.data.model
ArticleDto
Represents a complete article from the Space Flight News API. Source:ArticleDto.kt:7
Fields
Unique identifier for the article
Article title/headline
List of authors who wrote the article
URL to the original article on the news site
URL to the article’s featured image. Mapped from
image_url in JSON.Name of the news site that published the article (e.g., “Space.com”, “NASA”). Mapped from
news_site in JSON.Brief summary or excerpt of the article content
ISO 8601 timestamp when the article was published. Mapped from
published_at in JSON.ISO 8601 timestamp when the article was last updated. Mapped from
updated_at in JSON.Whether this article is featured/highlighted
List of space launches related to this article
List of space events related to this article
Mapper Methods
Example JSON
PaginationDto
Wrapper for paginated API responses. Source:PaginationDto.kt:5
Fields
Total number of articles available across all pages
URL for the next page of results.
null if this is the last page.URL for the previous page of results
Array of articles for the current page. Mapped from
results in JSON.Example JSON
AuthorDto
Represents an article author. Source:AuthorDto.kt:5
Fields
Full name of the author
Optional social media links for the author
Mapper Method
SocialDto
Social media links for an author. Source:SocialDto.kt:3
Fields
X (formerly Twitter) profile URL
YouTube channel URL
Instagram profile URL
LinkedIn profile URL
Mastodon profile URL
Bluesky profile URL
LaunchDto
Represents a space launch related to an article. Source:LaunchDto.kt:5
Fields
Unique identifier for the launch. Mapped from
launch_id in JSON.Launch service provider (e.g., “SpaceX”, “NASA”, “Roscosmos”)
Example JSON
EventDto
Represents a space event related to an article. Source:EventDto.kt:5
Fields
Unique identifier for the event. Mapped from
event_id in JSON.Event information provider (e.g., “Launch Library 2”)
Example JSON
Domain Mapping
DTOs are converted to domain models to separate API concerns from business logic:Benefits
- Separation of Concerns: API changes don’t affect UI layer
- Simplified Models: Domain models only include fields needed by UI
- Type Safety: Compile-time checking for model conversions
- Testability: Easy to mock domain models in tests
Related
- ArticlesApiClient - API endpoints that return these DTOs
- ArticleRepository - Converts DTOs to domain models
- Domain Models - Simplified models for UI layer