# himanshu231194/weatherwatch architecture

> Architecture diagram of the GitHub repository himanshu231194/weatherwatch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/himanshu231194/weatherwatch
- Repository: https://github.com/himanshu231194/weatherwatch

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile App container
    subgraph "Mobile App"
        %% Native Platforms swimlane
        subgraph "Native Platforms"
            Android["Android Native Shell"]:::external
            iOS["iOS Native Shell"]:::external
        end

        %% React Native JS Layer swimlane
        subgraph "React Native JS Layer"
            %% JS Entry & Root
            Entry["index.js"]:::frontend
            App["App.tsx (WeatherScreen)"]:::frontend

            %% UI Components
            subgraph "UI Components"
                DropDown["DropDown Component"]:::frontend
                ForecastList["Forecast List Items"]:::frontend
            end

            %% API Service
            subgraph "API Service"
                API["api.tsx"]:::api
            end

            %% Helpers & Constants
            subgraph "Helpers / Constants"
                Helper["getWeatherImage.ts"]:::helper
                Constants["constants.tsx"]:::helper
                Mocks["common.mock.tsx"]:::helper
            end
        end
    end

    %% External Services
    ForecastAPI["Open Meteo Forecast API"]:::external
    GeocodeAPI["Open Meteo Geocoding API"]:::external

    %% Data Flows
    Entry -->|"renders"| App
    App -->|"calls getCurrentWeather()"| API
    App -->|"renders search UI"| DropDown
    DropDown -->|"calls geocodeLocation()"| API
    API -->|"GET /v1/forecast..."| ForecastAPI
    API -->|"GET /v1/search..."| GeocodeAPI
    ForecastAPI -->|"response"| API
    GeocodeAPI -->|"response"| API
    API -->|"data & images"| App
    App -->|"renders cards"| ForecastList
    API -->|"uses"| Helper
    App -->|"reads"| Constants

    %% Click Events
    click Android "https://github.com/himanshu231194/weatherwatch/tree/main/android/"
    click iOS "https://github.com/himanshu231194/weatherwatch/tree/main/ios/WeatherWatch/"
    click Entry "https://github.com/himanshu231194/weatherwatch/blob/main/index.js"
    click App "https://github.com/himanshu231194/weatherwatch/blob/main/App.tsx"
    click API "https://github.com/himanshu231194/weatherwatch/blob/main/src/api/api.tsx"
    click DropDown "https://github.com/himanshu231194/weatherwatch/blob/main/src/components/DropDown/DropDown.tsx"
    click Helper "https://github.com/himanshu231194/weatherwatch/blob/main/src/helpers/getWeatherImage.ts"
    click Constants "https://github.com/himanshu231194/weatherwatch/blob/main/src/constants/constants.tsx"
    click Mocks "https://github.com/himanshu231194/weatherwatch/blob/main/src/mock/common.mock.tsx"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef api fill:#90EE90,stroke:#333,stroke-width:1px
    classDef helper fill:#FFFFE0,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
