How crisronda/reactnative-moodle works
Primary Layers/Components
• Client (Presentation) Layer:
• This includes the UI components (found in the “src/screens” folder, with separate sub-folders for authentication/signin and the main/home screens).
• The navigation layer is managed in “src/navigation” with separate flows for Signin and Main.
• The hooks (in “src/hooks”) support state management for authentication, course retrieval, and user data.
• Business Logic & State Management:
• The Redux components are under “src/redux” with actions, reducers, and types clearly defining the application state and update flows.
• In addition, custom hooks (like useAuth, useCourses, useUser) further encapsulate business logic.
• Service/Integration Layer:
• Service integrations for Moodle are in “src/services/moodle”, while integration with Firebase and Firestore are in “src/services/fcm” and “src/services/firestore” respectively.
• This layer is responsible for handling network calls to external services (Moodle and Firebase) and any data transformation.
• Notification & Wrappers:
• The “src/wrappers/Notifications” directory contains logic for formatting and handling notifications, bridging the native Firebase/FCM notifications.
• Native Code & Platform-Specific Layers:
• The “android” and “ios” directories contain platform-specific configurations and native code (e.g., MainActivity.java, AppDelegate, Xcode project files, and the Gradle configuration).
• These ensure the React Native layer properly integrates with the native runtime and third-party services like Firebase.
Relationships & Data Flows
• A user initiates actions via the UI screens (e.g., login or course selection).
• These UI interactions trigger events that are managed by navigation flows and custom hooks.
• Hooks then dispatch actions to the Redux store, which coordinates state updates in the application.
• When actions require external data (like authentication or course information), the Redux actions call corresponding service functions:
• Moodle service calls (authentication and course fetching) located under “src/services/moodle.”
• Firebase/FCM integration for notifications, handled via “src/services/fcm” and “src/wrappers/Notifications.”
• Responses then update the Redux store, which in turn propagates changes back to the UI.
• Native modules in the “android” and “ios” directories ensure proper configuration and integration for platform-specific requirements (e.g., handling push notifications on the device).
Architectural Patterns & Design Principles
• The separation of concerns is well-practiced by dividing the project into UI, state management, and service/integration layers.
• Use of Redux and hooks suggests a unidirectional data flow pattern, ensuring predictable state interactions.
• The clear division between service wrappers and presentation components helps with maintainability and testability.
• There's an emphasis on modularity (each service and feature has its own directory) which aligns with modern React Native best practices.
Technology and Frameworks
• React Native for building cross-platform mobile apps.
• Redux for state management.
• Firebase (with FCM and Firestore) for backend services like notifications and data persistence.
• Moodle web services for external course data integration.
• Navigation components for handling different flows (Signin and Main).