Characters App is a Swift-based iOS application built using MVVM architecture. The app displays a list of characters with their details and allows filtering characters by their status: Alive, Dead, or Unknown. The app also includes a detailed view for individual characters.
- Introduction
- Features
- App Screenshots
- How It Works
- Setup & Installation
- Architecture Overview
- Graphs
- Key Improvements
- Dependencies
- API Integration
- Future Enhancements
- Contributing
- License
- 📜 List of Characters: Displays a table view of all characters with their name, species, and status.
- 🔍 Filter Options: Filter characters by their status (Alive, Dead, Unknown).
- 🧍♂️ Character Details: View detailed information about a selected character, including:
- Name
- Species
- Gender
- Status
- Location
- Image
The main screen is a table view displaying all characters fetched from the API.
- Each row displays:
- Character's name.
- Character's species.
- Character's status (color-coded badges for Alive, Dead, and Unknown).
Users can filter the list by selecting a status filter. The options include:
- All
- Alive
- Dead
- Unknown
On selecting a character from the list, a detail view is shown with the character's:
- Profile image.
- Name.
- Species.
- Status.
- Gender.
- Location.
-
Clone the Repository
git clone https://github.com/username/characters-app.git
-
Open in Xcode
- Open the
.xcodeproj
or.xcworkspace
file.
- Open the
-
Install Dependencies
- Resolve Swift Package Manager (SPM) dependencies.
-
Run the App
- Select a simulator or a connected device.
- Click the Run button or press
⌘R
.
The app uses the MVVM architecture for a clean and scalable structure.
This layer is responsible for fetching data from external sources (e.g., APIs, databases). It includes:
CharactersDataSource
: Handles API calls.CharactersRepository
: Provides an interface between the API and the domain layer by handling data fetching and transforming raw API responses into domain models.
This layer focuses on the business logic and ensures that the app adheres to clean architecture principles. It includes:
CharactersUseCase
: Encapsulates the business logic and uses the repository to fetch or modify data as required.
This layer is concerned with the user interface and user interaction. It includes:
- ViewModel: Processes data provided by the domain layer into a format suitable for the view.
- Views/Controllers: Displays data and captures user interactions.
Presentation Layer
└── CharactersViewModel
↓
Domain Layer
└── CharactersUseCase
↑
Data Layer
├── CharactersRepository
↓
└── CharactersDataSource
- Factory Pattern for Initialization: Create a
DependencyContainer
to manage dependencies and build the graph. - Coordinator Pattern: Use a BaseCoordinator to manage child coordinators and modularize navigation logic, ensuring scalability, reusability, and cleaner separation of concerns across app flows.
- Sourcery Templates: Use Sourcery for protocol mocking, type erasure, and code generation to reduce boilerplate and speed up development.
UIKit
: For building the UI.SwiftUI
: For building the UI.URLSession
: For API communication.Kingfisher
: For image downloading and caching.Snapshot-Testing
: For snapshot views.Netfox
: For debugging network requests.SwiftLintPlugin
: A tool to enforce Swift style and conventions within your project.
The app fetches data from the Rick and Morty API.
-
Fetch All Characters
- URL:
https://rickandmortyapi.com/api/character
- URL:
-
Filter Characters by Status
- URL:
https://rickandmortyapi.com/api/character?page=1&status=<status>
- Replace
<status>
withalive
,dead
, orunknown
. - Use the
page
query parameter to paginate results.
- URL:
- 🌎 Connectivity Check: Show a "No Internet" alert automatically when the device is offline.
- 🔥 Favorites: Allow users to mark characters as favorites.
- 📊 Statistics: Display stats for the number of alive, dead, and unknown characters.
- 🌑 Dark Mode: Add support for system-wide dark mode.
Contributions are welcome! Follow these steps to contribute:
- Fork the repository.
- Create a feature branch:
git checkout -b feature-branch
- Commit your changes:
git commit -m "Add new feature"
- Push to the branch:
git push origin feature-branch
- Create a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.