How fturkyilmaz/react-native-clean-architecture-mvvm-react-query--infinite-scroll works
Project Type & Purpose
• This is a React Native mobile application (iOS & Android) following Clean Architecture with an MVVM pattern, using React Query for data fetching and an infinite-scroll hook.
• It surfaces three key data domains: Users (from a REST endpoint), Pokémon, and Rick & Morty Characters.
File Structure Analysis
Top-level:
• android/ & ios/ – native project code (Kotlin/Java + Swift/Obj-C).
• src/ – JavaScript/TypeScript code organized into four layers:
– presentation/ (pages + ViewModels)
– infrastructure/ (network clients, hooks, ReactQuery provider)
– application/ (services, repositories)
– domain/ (entities, use cases)
• index.js & App.tsx – the JS entrypoints & Metro bundler configuration.
• config files (.babelrc, tsconfig, jest, eslint, metro.config.js).
Key README Insights
• Bootstrapped with React Native CLI.
• No built-in backend; it consumes external public APIs.
• Uses Yarn, Metro, React Query, TypeScript, and Jest for testing.
Main Components
a. Mobile Client (React Native JS runtime)
• UI Layer (presentation): Screens & navigation
• ViewModels (MVVM)
• ReactQuery Provider & infinite-scroll hook
b. Domain Layer
• Entities (User, Character, Pokémon)
• Use Cases (GetUserUseCase, GetCharactersUseCase, GetPokemonsUseCase)
c. Application Layer
• Repositories (UserRepository, CharacterRepository, PokemonRepository)
• Services (Pokemon.service.ts, RickAndMorty.service.ts, etc.)
d. Infrastructure Layer
• Network Stack (ApiClient + axiosInterceptor)
• ReactQuery integration, custom hooks
e. Platform Native Modules
• Android (MainActivity.kt, Gradle modules)
• iOS (AppDelegate.mm, Xcode project)
f. External APIs
• Pokémon API
• Rick & Morty API
• Users REST endpoint
Relationships & Data Flow
• UI screens invoke methods on their ViewModels.
• ViewModels use React Query hooks that call Use Cases.
• Use Cases orchestrate domain logic and delegate data access to Repositories.
• Repositories call Services, which use ApiClient to communicate with External APIs.
• ApiClient applies global axios interceptors for auth, error handling, logging.
• Results flow back up: API → ApiClient → Service → Repository → Use Case → React Query → ViewModel → UI.
Architectural Patterns & Principles
• Clean Architecture (separation into layers, dependency rule: outer → inner)
• MVVM (presentation with ViewModels bound to views)
• Dependency Injection (pass ApiClient into services/repositories)
• Single Responsibility (each layer has distinct concerns)
• React Query for caching, deduplication, polling.