How stage88/react-weather works
Project Type and Purpose
• Full-stack mobile application: a React Native front-end with native iOS/Android containers, Redux for state, Realm for local persistence, and external REST APIs for data.
• Purpose: display weather and location data, allow user settings, persist favorites offline.
File Structure and Key Components
• Native containers:
– ios/ReactWeather.xcodeproj, AppDelegate, Info.plist, main.m
– android/app/, Gradle scripts, AndroidManifest.xml
• JavaScript app (under js/):
– UI Components (js/components/…)
– Navigation (js/navigators/)
– Actions & Reducers (js/actions/, js/reducers/)
– Store & Middleware (js/store/)
– Services (js/services/) for API calls
– Models & Persistence (js/realm/) using Realm
– Configuration (js/config.js) and entry points (js/app.js, index.ios.js, index.android.js)
Architectural Patterns
• Flux/Redux: single store, unidirectional data flow
• Modular component hierarchy (presentation vs. container components)
• Local database repository pattern via Realm schemas
Main Components
A. Mobile App Shell
– Native iOS (Obj-C/Swift) and Android (Java/Kotlin) runtimes
– React Native Bridge
B. JavaScript Layer
1. UI Layer (Components & Navigators)
2. State Management (Actions → Store → Reducers)
3. Persistence Layer (Realm)
4. Services Layer (REST API clients for weather & postcode)
C. External Services
– OpenWeatherMap API
– Australia Postcode API
Relationships & Data Flow
1. User taps UI → dispatch Action
2. Middleware (promise.js) intercepts → invokes Service
3. Service calls External API → returns JSON
4. Service writes/reads Realm (js/realm/) → persists data
5. Reducer updates Redux Store → UI subscribed components re-render
6. On app start: hydrate Store from Realm
Architectural Patterns & Principles
• Unidirectional data flow (Flux/Redux)
• Separation of concerns:
– Presentation vs. business logic vs. data access
• Offline‐first persistence with Realm
Essential Elements
• Native containers (iOS/Android)
• React Native bridge
• JS bundle with sub-components
• Redux flow: Actions → Reducers → Store
• Middleware/Promise layer
• Services layer calling External APIs
• Local Realm database
• External API endpoints