The project contains a working character browser that loads data from the Rick and Morty API. The current implementation lives inside a single massive ViewController.swift.
Your job is to refactor this code so it is production-ready.
The app must continue to work after your changes — pagination, caching, image loading, and date formatting should all remain functional.
- On launch, a list of characters loads and displays in a table view
- Each cell shows: avatar image, name, status with a colored indicator, species, and a formatted creation date (e.g. "Nov 4, 2017")
- Scrolling to the bottom automatically loads the next page of characters
- Previously loaded data is available from cache on subsequent launches (even before the network responds)
- If a network request fails, the user sees an error and can retry
- You can use any tools and any libraries (even Google), but no AI-assisted tools
60 minutes
The final solution should demonstrate:
- Separation of concerns — extract business logic out of
ViewControllerinto aViewModel(or equivalent), keep the view controller focused on UI only - Dedicated networking layer — isolate API calls behind a protocol-based service so the live API can be swapped for a mock without touching the UI
- Clear state management — loading / loaded / error / empty states are explicit and easy to reason about
- Working app — the app must compile and behave exactly as originally designed