# adisha2003/get-weather-app architecture

> Architecture diagram of the GitHub repository adisha2003/get-weather-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adisha2003/get-weather-app
- Repository: https://github.com/adisha2003/get-weather-app

## Overview

##### Project type and purpose
- This is a small full-stack, server-side-rendered web application (“get-weather-app”) that lets users search for weather data by city, state, or country.
- The backend is built with Node.js and Express, rendering dynamic pages with EJS and serving static frontend assets. It integrates with the OpenWeatherMap external API.

##### File structure
- Root files
- index.js – the main Express application entry point (routes, middleware, API calls).
- package.json / package-lock.json – Node dependencies and scripts.
- .gitignore, vercel.json – deployment and ignore settings.
- public/ – static assets
- public/js/script.js – client-side JavaScript.
- views/ – EJS templates used by the server
- views/index.ejs – main HTML template.

##### README for additional insights
- Confirms the stack: Node.js, Express.js, EJS, OpenWeatherMap API.
- Lists the features and the environment-variable‐based API key.

a. Main components
- Client (Browser): HTML + CSS + JS delivered to user.
- Web Server (Express app on Node.js): handles HTTP requests, fetches data, renders views.
- Template Engine (EJS): merges weather data with HTML templates.
- External Service (OpenWeatherMap API): provides weather data.
- Environment/config (.env): holds the API key.
b. Relationships & interactions
1. User submits a search query in the browser UI.
2. Browser sends HTTP GET/POST to Express server (index.js).
3. Server reads .env, builds request to OpenWeatherMap.
4. Server receives JSON response from OpenWeatherMap.
5. Server passes data into EJS (views/index.ejs) to produce HTML.
6. Server responds with rendered HTML + static assets (script.js).
7. Browser renders the result and may run script.js for any dynamic client behavior.
c. Architectural patterns & principles
- MVC-style separation:
- Controller: index.js route handlers and business logic.
- View: EJS templates in /views.
- Model: external API data (no internal database).
- Single-page request model (no SPA framework) – server-side rendering.
- Environment configuration (.env) for secrets.
d. Key technologies
- Node.js & Express.js – HTTP server and routing.
- EJS – view/template engine.
- OpenWeatherMap REST API – third-party data provider.
- Vercel configuration for deployment.

##### Detail
- Don’t omit the static folder; show that script.js is served separately from rendered HTML.
- Environment configuration step—how the API key flows into the server.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    Browser["Browser / Client"]:::frontend

    %% Server Side
    subgraph "Server Side"
        direction TB
        Env[".env Config"]:::config
        Express["Express Server\n(index.js)"]:::backend
        EJS["EJS Renderer\n(views/index.ejs)"]:::backend
        Static["Static Assets\n(public/js/script.js)"]:::backend
        VercelCfg["Vercel Config\n(vercel.json)"]:::config
        Package["Package Config\n(package.json)"]:::config
        GitIgnore[".gitignore"]:::config
        Readme["README.md"]:::config
    end

    %% External Service
    OpenWeather["OpenWeatherMap API"]:::external

    %% Data Flows
    Browser -->|"HTTP Request\n(search query)"| Express
    Express -->|"reads API key"| Env
    Express -->|"calls API"| OpenWeather
    OpenWeather -->|"JSON response"| Express
    Express -->|"renders view"| EJS
    EJS -->|"HTML response"| Browser
    Express -->|"serves asset"| Static
    Browser -->|"loads script.js"| Static

    %% Click Events
    click Express "https://github.com/adisha2003/get-weather-app/blob/main/index.js"
    click Static "https://github.com/adisha2003/get-weather-app/blob/main/public/js/script.js"
    click EJS "https://github.com/adisha2003/get-weather-app/blob/main/views/index.ejs"
    click VercelCfg "https://github.com/adisha2003/get-weather-app/blob/main/vercel.json"
    click Package "https://github.com/adisha2003/get-weather-app/blob/main/package.json"
    click GitIgnore "https://github.com/adisha2003/get-weather-app/blob/main/.gitignore"
    click Readme "https://github.com/adisha2003/get-weather-app/blob/main/README.md"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef external fill:#FFE4B5,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5;
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2;
```
