CodingIdeas.ai
← Browse All Ideas

Build Guide

How to Build a Weather App

A weather app with AI plain-English forecasts ("bring a jacket at 3pm") gets 10× more daily opens than a raw data dump.

Beginner1–2 days

A weather app teaches API integration, geolocation, data visualisation, caching, and background refresh — core skills for any data-driven product.

Data model

The core tables you'll need before writing any UI.

Locationlat, lon, name, country — stored in localStorage, no DB needed for basic version
WeatherCachelocation_key, data (JSON from API), fetched_at — cache in localStorage or Redis to avoid re-fetching on every render

Build order

The sequence that minimises rewrites — build in this order.

1

Fetch and display current conditions

Call Open-Meteo's /forecast endpoint with hardcoded lat/lon. Display temperature, weather code (mapped to icon), humidity, and wind speed. Open-Meteo is free, no API key.

2

Add geolocation

Call navigator.geolocation.getCurrentPosition() on load. Use the returned lat/lon for the API call. Show a loading state while geolocation resolves.

3

City search

Use Open-Meteo's Geocoding API to search for cities by name. Show a dropdown of results. On select, store the lat/lon/name and refetch weather.

4

Hourly and 7-day forecast

Add the hourly and daily forecast sections to the API request. Render hourly as a horizontal scrolling row of cards. Daily as a vertical list with min/max temps and icons.

5

Favourite locations

Add a favourite button on each location. Store favourites in localStorage as an array of {name, lat, lon}. Add a favourites panel with one-click switching.

6

Cache API responses

Before calling the API, check if you have a cached response for this location from the last 15 minutes. If yes, use it. This prevents hitting API limits and speeds up repeat views.

7

AI plain-English summary

Take the day's hourly forecast data and send it to Claude Haiku with a prompt: "Summarise this forecast in one casual sentence for a non-technical user." Display above the data.

Done when

Observable behaviors that confirm V1 is complete — verify each one before you ship.

  • Current weather loads within 2 seconds of geolocation permission being granted

  • City search returns results within 500ms and switching location updates all forecast data

  • Hourly forecast row scrolls horizontally and shows correct icons for each weather code

  • AI summary shows a plain-English sentence above the raw forecast data

  • App opens with a default location pre-loaded — no input required on first visit

First Run Requirement

Default location is London, UK. Weather data loads on first visit without requiring geolocation permission or city search. User can update location after.

Build it with AI — Architect Prompt

Paste this into Claude, Cursor, Windsurf, or any AI coding tool. It includes the full context of this guide — data model, build order, done conditions, and pitfalls — so the AI starts with everything it needs.

ClaudeCursorWindsurfCopilotGemini
architect-prompt.txt
<context>
App: Weather App
Difficulty: Beginner
Estimated build time: 1–2 days
Tech stack (intermediate): Next.js + Open-Meteo + Mapbox for radar map embed

Data model:
  Location: lat, lon, name, country — stored in localStorage, no DB needed for basic version
  WeatherCache: location_key, data (JSON from API), fetched_at — cache in localStorage or Redis to avoid re-fetching on every render

FIRST RUN REQUIREMENT:
Default location is London, UK. Weather data loads on first visit without requiring geolocation permission or city search. User can update location after.

DONE WHEN — verify each before marking V1 complete:
  □ Current weather loads within 2 seconds of geolocation permission being granted
  □ City search returns results within 500ms and switching location updates all forecast data
  □ Hourly forecast row scrolls horizontally and shows correct icons for each weather code
  □ AI summary shows a plain-English sentence above the raw forecast data
  □ App opens with a default location pre-loaded — no input required on first visit

Recommended build order:
  1. Define API contract + schema + seed data (always first)
  2. Fetch and display current conditions — Call Open-Meteo's /forecast endpoint with hardcoded lat/lon. Display temperature, weather code (mapped to icon), humidity, and wind speed. Open-Meteo is free, no API key.
  3. Add geolocation — Call navigator.geolocation.getCurrentPosition() on load. Use the returned lat/lon for the API call. Show a loading state while geolocation resolves.
  4. City search — Use Open-Meteo's Geocoding API to search for cities by name. Show a dropdown of results. On select, store the lat/lon/name and refetch weather.
  5. Hourly and 7-day forecast — Add the hourly and daily forecast sections to the API request. Render hourly as a horizontal scrolling row of cards. Daily as a vertical list with min/max temps and icons.
  6. Favourite locations — Add a favourite button on each location. Store favourites in localStorage as an array of {name, lat, lon}. Add a favourites panel with one-click switching.
  7. Cache API responses — Before calling the API, check if you have a cached response for this location from the last 15 minutes. If yes, use it. This prevents hitting API limits and speeds up repeat views.
  8. AI plain-English summary — Take the day's hourly forecast data and send it to Claude Haiku with a prompt: "Summarise this forecast in one casual sentence for a non-technical user." Display above the data.
  9. End-to-end verification — walk every Done When condition above (always last)

Known pitfalls to avoid:
  - Calling the API on every render — wrap your fetch in a useEffect with the location as a dependency and cache the result. Without caching, switching tabs and back triggers a fresh API call every time.
  - Mapping weather codes manually — Open-Meteo returns numeric weather codes (0–99). Use their official code table to map them to descriptions and icons. Don't invent your own mapping.
  - Not handling geolocation denial — if the user denies location access, show a city search input immediately instead of a broken loading state.
</context>

<role>
You are a Senior Full-Stack Engineer and product architect who has shipped production Weather Apps before. You know exactly where developers get stuck and how to structure the project to avoid rewrites.
</role>

<task id="step-1-clarify">
Before writing any code or spec, ask me 3–5 clarifying questions that will meaningfully change the architecture. Focus on: scale expectations, auth requirements, platform (web / mobile / both), must-have vs nice-to-have features for the MVP, and any hard constraints (budget, deadline, existing infrastructure).

<example>
BAD: "What tech stack do you want to use?" — too broad, doesn't change architecture decisions.
GOOD: "Do you need real-time sync across devices, or is single-device with periodic refresh acceptable? This decides whether we use WebSockets or simple REST polling and significantly affects infrastructure complexity."
</example>

⚠️ Do NOT start planning or writing code until I answer. Present the questions, then stop and wait.
</task>

<task id="step-2-architect">
After I answer your questions, produce the following in order:

1. TECHNICAL SPECIFICATION
   - System architecture using → to show data and event flow
   - Core data model (refer to data model in <context>)
   - API contract — list ALL routes with request/response shapes BEFORE any implementation
     WHY: agreeing on contracts first prevents rewrites when frontend and backend shapes diverge
   - External APIs and integration points

2. MVP PLAN in three phases:

   SETUP   ✦ Step 1 (always): API contract + schema migration + seed data
     Done when: schema is migrated, seed script runs, app starts with demo data, zero manual setup.

   CORE FEATURES — build in this exact order:
   2. Fetch and display current conditions
   3. Add geolocation
   4. City search
   5. Hourly and 7-day forecast
   6. Favourite locations
   7. Cache API responses
   8. AI plain-English summary

   DONE WHEN — one observable condition per feature:
   □ Current weather loads within 2 seconds of geolocation permission being granted
   □ City search returns results within 500ms and switching location updates all forecast data
   □ Hourly forecast row scrolls horizontally and shows correct icons for each weather code
   □ AI summary shows a plain-English sentence above the raw forecast data
   □ App opens with a default location pre-loaded — no input required on first visit

   STRETCH GOALS — post-launch additions that are explicitly out of V1 scope.

3. BLOCKER ANALYSIS
   Flag: API rate limits, auth complexity, scope risks, cold-start problems, top 2–3 failure modes.

   FIRST RUN REQUIREMENT: Default location is London, UK. Weather data loads on first visit without requiring geolocation permission or city search. User can update location after.
   ✓ Done when: app launches with seed data and the full user journey works without any manual setup.

<self_check>
Before presenting your output, verify:
□ Every answer I gave to clarifying questions is reflected in the spec
□ Step 1 is ALWAYS: API contract + schema + seed — never UI first
□ Done When criteria are observable user behaviors, not internal states
□ The plan is realistic for one person to ship within 1–2 days
□ All known pitfalls from <context> are addressed in the spec
</self_check>
</task>

<task id="step-2.5-agents-md">
Generate an AGENTS.md file at the project root. This file is read automatically by Claude Code, Cursor, Windsurf, and all major AI coding tools at the start of every session.

Include:
- Project overview (2–3 sentences)
- Tech stack with exact version numbers
- Folder structure with one-line descriptions per directory
- Key architectural decisions and the WHY behind each
- Coding conventions: camelCase components, kebab-case files, max 200 lines per file, one concern per file
- Available commands: dev, build, test, lint, db:migrate, db:seed
- MVP scope boundaries — features explicitly out of V1

Note in the file: "Cursor users: symlink .cursorrules → AGENTS.md. Claude Code users: symlink CLAUDE.md → AGENTS.md."
</task>

<task id="step-3-implement">
Implement the full project in the exact order from step 2. For each step:
- Write complete code (no placeholders or TODOs)
- Confirm the step works before moving to the next

<constraints>
- Step 1 is ALWAYS: define all API routes + TypeScript request/response interfaces + run schema migration
  WHY: agreeing on contracts before writing a single component prevents shape mismatches that require rewrites
- Final step is ALWAYS: start the app and walk every Done When condition from <context> end-to-end
  WHY: a spec that passes unit tests but breaks the core user journey is not done
- Max 200 lines per file. WHY: every file must fit in one AI context window for complete reasoning
- One concern per file. WHY: mixing auth logic into API routes makes it impossible to reuse — extract to lib/auth.ts
- TypeScript strict mode, no `any` types. WHY: catches data shape mismatches at compile time, not in production
- All database queries in server components or API routes only. WHY: keeps credentials server-side
- All environment variables documented in .env.example. WHY: next developer sets up in under 5 minutes
</constraints>
</task>

How to use this prompt

  1. 1.Copy the prompt above
  2. 2.Open Claude, Cursor (Cmd+L), or Windsurf
  3. 3.Paste the prompt and send — the AI will ask 3–5 clarifying questions
  4. 4.Answer the questions, then it generates your full project spec
  5. 5.Continue in the same session to implement step by step

Common mistakes

What trips up most developers building this for the first time.

⚠️

Calling the API on every render — wrap your fetch in a useEffect with the location as a dependency and cache the result. Without caching, switching tabs and back triggers a fresh API call every time.

⚠️

Mapping weather codes manually — Open-Meteo returns numeric weather codes (0–99). Use their official code table to map them to descriptions and icons. Don't invent your own mapping.

⚠️

Not handling geolocation denial — if the user denies location access, show a city search input immediately instead of a broken loading state.

Recommended tech stack

Pick the level that matches your experience.

Beginner

Vanilla JS or React + Open-Meteo API — free, no key, complete in a day

Intermediate

Next.js + Open-Meteo + Mapbox for radar map embed

Advanced

Next.js + Open-Meteo + Claude API for AI summaries + PWA for mobile install + offline support

Take it further — related ideas

Each comes with revenue math, a full build guide, and a prompt to paste into Claude or Cursor.