How saheeranas/react-native-redux-boilerplate works
Main Components
• User Interface (UI) Layer:
• Represents the mobile app front end built using React Native.
• Contains screens (app/screens, app/screens/auth) and UI components (app/components) such as Button, Card, Form, Layout, and Text.
• State Management Layer:
• Redux store integrated with Redux Toolkit (located in app/store, including tasksSlice.ts and userSlice.ts).
• Offline storage is handled via Redux Persist.
• Services or API Layer:
• Includes modules for API communication and logic (app/services folder with api-client.ts, auth.ts, news.ts, statusHandler.ts).
• Handles external network calls and secure token handling (app/utils/token.ts, app/utils/keyChain.ts).
• Navigation and Routing:
• Navigation is set up using React Navigation found in app/routes/RootNavigation.tsx and probably spread within the screens to manage transitions.
• Theming and Styling:
• Theme configuration and management through app/theme with files like theme.ts and useTheme.tsx.
• Configuration and Environment:
• Environment variables are handled using .env templates and set up tools (e.g., .env.template, .env.production.template).
• Other configuration and linting rules are provided (eslintrc.js, prettier configuration).
• Platform-specific Code:
• Native layer implementations for Android (android folder) and iOS (ios folder) determine native dependencies, builds, and assets.
Relationships and Interactions
• The UI layer (React Native components and screens) interacts with the Redux store to fetch and update application state.
• The Redux store works in tandem with Redux Persist to ensure offline compatibility.
• UI components trigger actions defined by Redux Toolkit, which then might call the services layer to perform API requests.
• The services layer manages asynchronous operations (using Axios and other libraries) and passes data back into the state management layer.
• Navigation components (RootNavigation.tsx and related screens) coordinate the flow between different UI screens, reacting to state changes as needed.
• The theming module provides consistency in UI styling and supports dark mode based on user or system preferences.
Important Architectural Patterns and Principles
• Separation of Concerns: UI, state management, services, and navigation are clearly separated into distinct folders.
• Modular Design: Each feature (authentication, CRUD operations, theming) is encapsulated in its own module for easier maintenance and scalability.
• Use of Cross-Platform Abstractions: Core business logic is written in TypeScript and managed through React Native, allowing for consistent behavior on both Android and iOS.
• Integration of Middleware/Dependencies: The use of Redux Toolkit and React Navigation shows a preference for standard, community-supported frameworks.
• Environment-Based Configuration: The use of different .env templates indicates attention to configuration management across different build targets (development vs. production).