Model the Data: DTOs, Domain Models & Mapping
4 fill-in slots · from The AI Prompt Handbook for Mobile App Development
Your details
0/4 filledModel the Data: DTOs, Domain Models & Mapping
Background: Native [platform] app, [Swift / Kotlin]. Here's a sample of the API payload(s) I receive: [paste JSON]. Here's how the app actually uses this data in features: [describe]. Use case: Design the data models and the mapping between what the API sends and what the domain/UI needs. Implementation details: - Separate DTOs (wire format) from domain models (what the app reasons about)—or justify collapsing them if the app is small - iOS: Codable with custom keys/strategies for messy payloads; use value types and make illegal states unrepresentable. Android: kotlinx.serialization / Moshi with data classes. - Handle nullability, optional fields, dates, enums with unknown values, and snake_case → camelCase - Where mapping happens (DTO → domain) and how mapping errors are handled - Keep the domain model free of API quirks Deliverable: The DTO definitions for the payload, the clean domain models, the mapping functions, the decoding strategy for the messy fields, and how a malformed payload is handled gracefully.
Highlighted [slots] are still empty. Downloads are plain .txt — paste into any AI assistant.