A feature-rich iOS application for browsing and managing your favorite movies, built using SwiftUI and following Apple's Human Interface Guidelines (HIG). This app demonstrates modern iOS development practices, clean architecture, and fundamental programming principles.
- Browse popular movies with infinite scrolling
- Search for movies with debounced input
- View detailed movie information
- Save favorite movies locally
- Share movie details
- Pull-to-refresh functionality
- Elegant error handling and loading states
The app follows the MVVM (Model-View-ViewModel) architectural pattern, ensuring clean separation of concerns and maintainable code. Here's how the components are organized:
Movie
: Represents movie data from TMDB APIMovieResponse
: Handles API response paginationDatabaseManager.FavoriteMovie
: Local database model for saved favorites
ContentView
: Main app containerMovieListView
: Displays movie list with searchMovieDetailView
: Shows detailed movie informationMovieRowView
: Individual movie cell in the list
MovieListViewModel
: Manages movie list state and paginationMovieDetailViewModel
: Handles movie details and favorites
MovieService
: Manages API communication with TMDBDatabaseManager
: Handles local data persistence
The app interfaces with The Movie Database (TMDB) API to fetch movie data. The MovieService
class handles all network communication using modern Swift concurrency (async/await).
// Example API call
let movies = try await MovieService.shared.fetchPopularMovies(page: 1)
GRDB (SQLite wrapper) is used for local storage of favorite movies, providing efficient data persistence and querying capabilities.
// Example database operation
try DatabaseManager.shared.addFavorite(movie)
The app follows Apple's Human Interface Guidelines with:
- Consistent navigation patterns
- Clear visual hierarchy
- Responsive feedback
- Smooth animations
- Appropriate loading states
- Debounced search to minimize API calls
- Efficient image loading with AsyncImage
- Pagination for large datasets
- Actor-based concurrency for thread safety
- Reusable views like
LoadingIndicatorView
- Shared networking logic in
MovieService
- Common database operations in
DatabaseManager
- Clear, focused view structures
- Straightforward data flow
- Minimal state management
- Intuitive user interactions
Each component has a single, well-defined purpose:
- Views handle only UI rendering
- ViewModels manage state and business logic
- Service classes handle specific tasks (networking, database)
The app implements comprehensive error handling:
- Custom
MovieError
types for specific failure cases - User-friendly error messages
- Graceful fallbacks
- Retry mechanisms
- iOS 15.0+
- Xcode 13.0+
- Swift 5.5+
- GRDB Swift Package
- GRDB: SQLite database management
- TMDB API Key (required for movie data)
- Clone the repository
- Open
GrappaMovie.xcodeproj
in Xcode - Add your TMDB API key in
MovieService.swift
- Build and run
The project follows Swift standard coding conventions:
- Clear naming conventions
- Comprehensive documentation comments
- Organized file structure
- Consistent formatting
Potential areas for enhancement:
- Offline support
- Advanced filtering options
- User reviews and ratings
- Personalized recommendations
- Movie trailers integration
While not currently implemented, the MVVM architecture makes the app highly testable:
- ViewModels can be tested in isolation
- Service layers can be mocked
- Database operations can be tested with in-memory storage
Feel free to submit issues and enhancement requests.
This project is intended for educational purposes as part of a Computer Science course.
- TMDB for providing the movie database API
- GRDB for the SQLite wrapper
- Apple's SwiftUI framework and Human Interface Guidelines