How mchirino89/rickandmorty works
Project Type and Purpose
• The project is a Proof-of-Concept (PoC) for a programmatic UIKit app that displays a simple list of characters and a detail view. It interacts with the public Rick and Morty API to fetch random characters.
• It uses Swift Package Manager (SPM) dependencies (MauriUtils, MauriNet, MauriKit) and is built in Xcode, indicating an iOS client app with a focus on clean architecture and a modular approach.
File Structure
• Notice the top-level "R&M" directory that contains the main source code.
• Inside, the project is organized by Clean Architecture layers:
• Entities (core business objects like endpoint descriptions)
• UseCases (user actions – e.g., fetching random characters, showing character details)
• InterfaceAdapters (UI layer implementing MVVM: view controllers, views, UI assets, DTOs)
• Drivers (frameworks and external connections – e.g., network requests, in-house cache framework for images, app setup files)
• There is also a comprehensive tests directory (R&MTests) containing unit tests, integration tests (NavigationTestCases and SnapshotTestCases), and various test doubles (dummies, fakes, stubs, spies).
• Additional project configuration files (e.g., .swiftlint.yml, Info.plist files), CI integration workflows (.github/workflows), and documentation resources (DocResources, Preview) are also present.
README for Additional Insights
• The README emphasizes that the architecture is based on Uncle Bob’s Clean Architecture – with clearly defined layers for Entities, Use Cases, Interface Adapters, and Drivers.
• It details that the UI design pattern is MVVM, with responsibilities split among view controllers, view models, and data transmission objects.
• It presents reasoning behind using SOLID principles, component decoupling, and integration tests to safeguard navigation and layout behaviors.
a. Main Components:
• Entities: Representing the core objects (e.g., endpoint data for characters).
• Use Cases: Contain the business logic for actions like loading a list of random characters and presenting details.
• Interface Adapters: The MVVM components – view controllers, UI components, DTOs, and asset management.
• Frameworks/Drivers: External integrations, including the network layer (via MauriNet), caching (in-house CacheFramework), and iOS setup/configuration.
• Test Suite: An additional layer to indicate testing of repositories, navigation, and UI snapshots.
b. Relationships and Interactions:
• Data flows from the Drivers (network requests, caching layer) into the Use Cases. The Use Cases process the business logic.
• Processed data is handed off to Interface Adapters, which transform it into UI-friendly data structures (using DTOs) and ultimately render it via MVVM views and controllers.
• Entities remain at the core, stable data representations used across the other layers.
• Additionally, there is a navigation coordinator pattern (via the MainCoordinator in the Navigation folder) ensuring loose coupling between UI components.
c. Architectural Patterns or Design Principles:
• Clean Architecture: Segregation of responsibilities across Entities, Use Cases, Interface Adapters, and Drivers.
• MVVM for organizing the UI code.
• Use of SOLID principles throughout the codebase with specific emphasis on single responsibilities (as seen with dedicated files for delegates, data sources, and test doubles).
• “Lego-oriented” design which emphasizes composability and modularity.
d. Relevant Technologies, Frameworks, or Libraries:
• UIKit for the UI.
• Swift Package Manager (SPM) for dependency management.
• The external libraries: MauriUtils, MauriNet, MauriKit.
• Testing frameworks (embedded within Xcode) alongside unit and snapshot testing.