Skip to content

An iOS app that interfaces with The Movie Database (TMDb) API to display popular movies and detailed information about each movie

Notifications You must be signed in to change notification settings

abrahamduran/tmdb-movies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Overview

This project is an iOS app that interfaces with The Movie Database (TMDb) API to display popular movies and detailed information about each movie. The app is built with SwiftUI and follows the MVVM architectural pattern. It demonstrates the usage of modern Swift development practices, including Swift Concurrency for asynchronous network calls, and implements both unit and UI testing to ensure code quality and reliability.

Key Features

  • Popular Movies Grid: Displays a grid of popular movies fetched from the TMDb API.
  • Movie Details: Shows detailed information about a selected movie, including cast, genres, and recommendations.
  • Localization Support: Actively supports localization by retrieving language and region-specific data from the API and using locale-aware formatters.
  • Caching: Implements simple caching to store popular movies and movie details for offline access.
  • Responsive Layout: Utilizes GeometryReader to adapt the layout to different screen sizes and orientations.
  • Error Handling: Manages network errors gracefully, showing user-friendly error messages.
  • Refreshing Content: Supports pull-to-refresh to update the content manually.
  • Localization: Currently the app has

Setup and Configuration

To run the project, you need to supply your own API key from TMDb. This key should be added to the Info.plist file under the TMDBApiKey key. Follow these steps:

  1. Obtain an API key from The Movie Database (TMDb) website.
  2. Open the project's Info.plist file in Xcode.
  3. Add a new entry with the key TMDBApiKey and paste your API key as the value.

Image Loading and Configuration

The Info.plist file contains keys TMDBProfilePath, TMDBPosterPath, and TMDBBackdropPath, used to construct the full image URLs. The appropriate values for these keys are detailed in the TMDb API documentation. Future enhancements could include using different paths for image loading based on the network conditions (Wi-Fi vs. cellular).

Development and Technical Considerations

Swift and SwiftUI

The project is developed entirely in Swift using SwiftUI, leveraging Swift's advanced features like Concurrency for network requests and property wrappers for state management.

Architecture

MVVM (Model-View-ViewModel) is chosen as the architectural pattern to separate concerns, facilitate unit testing, and enable better code organization and readability.

Caching

Caching is implemented with UserDefaults to quickly prototype and demonstrate the caching mechanism. In a production environment, a more robust solution like Core Data or a dedicated caching library should be considered for performance, scalability, and security.

Testing

  • Unit Tests: Cover core functionalities, including network fetching logic, data parsing, and error handling. While the code coverage is around 90%, there is always room to extend test coverage to less common edge cases and error conditions.
  • UI Tests: Focus on key user interactions within the app, ensuring that the main user flows work as expected. Future improvements can include more comprehensive testing of user flows and interactions, especially for dynamic content and error handling scenarios.

Dependency Injection

Currently, view models instantiate their dependencies as default parameters in their initializers, which works for this project scope. However, implementing a dependency injection container or factory pattern would enhance testability and maintainability, allowing for easier swapping of dependencies, particularly useful in testing scenarios (e.g., UI tests).

Future Improvements and Considerations

  • Security: While the requirenment asked to use an API Key, switching to header authentication (using Access Tokens) it's security enhancement to consider.
  • Advanced Caching: Transition to a more sophisticated caching mechanism like Core Data or Realm for better performance and offline data management.
  • Dependency Injection: Implement a DI container or use a framework like Swinject to manage dependencies, particularly for view models, which would significantly improve the flexibility and testability of the code.
  • UI Enhancements: Further refine the UI design and user experience, possibly incorporating animations, transitions, and more advanced SwiftUI components.
  • Comprehensive UI Testing: Expand UI tests to simulate more user scenarios, including navigation, error handling, and interaction with dynamic content.
  • Localization and Accessibility: Enhance support for multiple languages and improve accessibility features to cater to a broader audience.
  • Performance Optimization: Profile and optimize the app's performance, particularly in areas like image loading, data processing, and view rendering.
  • Network Data Optimization: In the future, the app could use image paths with lower resolution when on a cellular network to save on user data consumption.

Conclusion

This project serves as a solid foundation for a SwiftUI app that interacts with a web service, demonstrating best practices in app architecture, asynchronous programming, and testing. While it fulfills the primary requirements, the considerations and potential improvements outlined provide a roadmap for evolving the app into a more robust and feature-rich product.

About

An iOS app that interfaces with The Movie Database (TMDb) API to display popular movies and detailed information about each movie

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages