How himanshu231194/weatherwatch works
Project type and purpose
• Type: Cross-platform mobile application built with React Native and TypeScript.
• Purpose: Display current and weekly weather forecasts for a user-selected location, including a search interface that resolves ambiguities via the Open Meteo Geocoding API.
File structure
• Top-level folders:
– android/ & ios/: Native shell projects for Android (Gradle) and iOS (Xcode).
– src/: Core React Native code.
– __tests__/ and src/**/__tests__: Jest test suites.
• Key sub-directories in src/:
– api/: Modules that call the Open Meteo Forecast and Geocoding APIs.
– components/DropDown: Search UI component.
– helpers/: Pure functions (e.g., getWeatherImage.ts).
– constants/: Shared constants and endpoints.
– mock/: Test fixtures.
• Configuration files:
– App.tsx & index.js: Entry points.
– babel.config.js, metro.config.js, tsconfig.json, package.json: Build, bundler, and type settings.
– ESLint, Jest config, and native build configs.
README for additional insights
• Confirms third-party services:
• Open Meteo Forecast API
• Open Meteo Geocoding API
• Testing requirements: one complex component, one helper, one API request.
• No custom backend—app calls external REST endpoints directly.
a. Components
1. Native Shells
– Android (Java/Kotlin gradle project)
– iOS (Objective-C/Swift Xcode project)
2. React Native JS Layer
• Entry Point: index.js → App.tsx
• Presentation:
– App.tsx (WeatherScreen)
– DropDown search component
– Forecast list items (weekly cards)
• Data Layer:
– src/api/api.tsx:
· getCurrentWeather(latitude, longitude)
· getWeeklyForecast(latitude, longitude)
· geocodeLocation(name)
• Domain Logic:
– src/helpers/getWeatherImage.ts: Map weather codes → image assets
• Constants & Mocks:
– src/constants/constants.tsx (API URLs, keys)
– src/mock/common.mock.tsx (test fixtures)
3. External Services
– Open Meteo Forecast API
– Open Meteo Geocoding API
b. Data Flow & Interactions
1. App Startup
User opens app → App.tsx invokes api.getCurrentWeather with default coords → fetch → data → helper maps code → UI renders.
2. Search Workflow
User types in DropDown → api.geocodeLocation → receives list → user selects → invokes api.getWeeklyForecast → UI updates.
3. Testing Layer
Jest tests hit these modules in isolation: component snapshots, helper unit tests, API mock tests.
c. Architectural Patterns & Principles
• Layered Separation: Presentation (React components) / Data (API) / Domain (Helpers)
• Unidirectional Data Flow in React state/hooks
• Single Responsibility: each module has a clear role (UI vs API vs utilities)
• Cross-Platform Abstraction: native project shells delegate to a single JS bundle
Detail without over-splitting
• Layers: native shells, JS entry, UI, data, domain, external.
• Call out configuration/test artifacts only if relevant.