Skip to content

Sam12354/Weather-app-V5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

27 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒค๏ธ Weather Forecast App

A modern React application that delivers a 5-day weather forecast along with interactive and experimental features like AI chat, voice interaction, face detection, and more โ€” built to demonstrate real-world API integration and advanced browser capabilities.


๐Ÿš€ Live Demo (Local)

Open in your browser:

http://localhost:5173/

--

๐Ÿš€ Installation

Clone or download the project, then navigate into the project folder:

  • cd Weather-app-3-main
  • npm install
  • npm run dev

--

โœจ Features

๐ŸŒฆ๏ธ Weather Forecast

  • Fetches real-time weather data from OpenWeatherMap API
  • Displays a 5-day forecast
  • Shows:
    • Day of the week
    • Temperature (ยฐC)
    • Weather icons
    • Descriptions
  • Data is transformed for clean UI rendering
  • Currently set to display weather for London:
    const city = 'London';
    
    --

๐Ÿค– AI Chatbot

  • Chat with an AI inside the app
  • Powered by OpenRouter API
  • Features:
    • Real-time responses
    • Typing indicator
    • Controlled input
    • Dynamic messages
    • Requires an API key stored in your .env file:
VITE_CHAT_BOT_KEY=your_openrouter_api_key_here

--

๐ŸŽ™๏ธ Voice Bot (Speech-to-Speech)

Speak into your microphone and hear your voice repeated back using AI-generated speech in different voices.

โœจ Features

  • Speak into your microphone
  • AI responds with generated voice audio
  • Repeats what you say using AI-generated voices
  • Fully client-side (no backend required)

๐Ÿง  Tech Used

  • Browser SpeechRecognition API
  • Speechify API (text-to-speech)
  • Audio streaming with Blob
  • React state & refs

๐ŸŽง How It Works

  • Click โ€œTalkโ€ to start recording
  • Click โ€œHang Upโ€ to stop
  • The AI listens and repeats your speech back to you

๐Ÿ”Š Voice Customization

You can change the voice directly in the component:

const botAudioBlob = await getVoiceBotResponse(text, "rob");

Available voices include: "rob", "lisa", "emily", "oliver", "jesse", "ken", "grady", "lela" and more

To explore all voices:

Run the test.js script in your browser console It will log all available voice names and IDs

โš ๏ธ Requirements

  • Requires microphone permissions
  • Works only in browsers that support SpeechRecognition

๐Ÿ”‘ Setup (Voice Bot)

  • Create an account with Speechify
  • Generate an API key
  • Add it to your .env file:

VITE_VOICE_BOT_KEY=your_speechify_api_key_here

--

๐Ÿ” Voice Password (NEW)

  • Say a secret phrase to unlock a hidden route
  • Currently, the secret phrase is hardcoded as:

const secretPhrase = "unlock"; // โ€œvoice passwordโ€

  • If the correct phrase is spoken, the app redirects to /paypal
  • Demonstrates speech-based authentication using the browserโ€™s SpeechRecognition API
  • Future improvement: Allow users to set their own secret phrase instead of using the hardcoded default

--

๐Ÿ’ธ PayPal Integration (NEW)

  • Embedded PayPal donation button on the app
  • Built using the PayPal SDK (sandbox environment)
  • Click the button to be redirected to the PayPal donation page
  • Note: This is currently a demo; the hosted button ID needs to be replaced with your own PayPal sandbox or live ID for full functionality
  • Demonstrates integration of third-party payment buttons in React

--

๐Ÿง‘โ€๐Ÿ’ป Face Login (NEW)

  • Uses the webcam to detect a userโ€™s face
  • Redirects to /memes on successful detection
  • Demonstrates:
    • Face detection using face-api.js (GitHub)
    • Browser Camera API (navigator.mediaDevices.getUserMedia)
    • AI model usage for real-time face recognition

How It Works

  1. Loads pre-trained face detection models from face-api.js
  2. Accesses the userโ€™s webcam and streams video to a <video> element
  3. Detects the face in real-time when the user clicks โ€œScan Faceโ€
  4. If a face is detected, the app navigates to the hidden /memes route

โš ๏ธ Requirements

  • Requires camera permissions
  • Works only in browsers that support getUserMedia
  • Depends on face-api.js models being successfully loaded

๐Ÿ’ก Future Improvements

  • Add multiple user profiles with custom face recognition
  • Improve detection accuracy and speed
  • Combine with voice authentication for multi-factor security

--

๐Ÿ˜‚ Random Meme

The app fetches and displays a random meme to make the user experience more fun and engaging.

How It Works

  • Fetches a random meme from the Meme API
  • Displays the meme image dynamically in the app
  • A new meme is loaded every time the page is refreshed

Tech Used

  • React useEffect and useState
  • Async/Await for API calls
  • Dynamic image rendering in JSX

Documentation

--

๐ŸŒ  Daily Motivation Quote

The app displays a randomly generated motivational quote to brighten the userโ€™s day.

How It Works

  • Quotes are stored locally in the app
  • Click the โ€œReveal My Quote for Todayโ€ button to display a random quote
  • The button hides after clicking
  • Refreshing the page allows the button to be clicked again to generate a new quote

--

๐Ÿง  Fun Facts

The app displays random fun facts alongside the forecast.
A new fun fact is shown each time the page is refreshed.

--

๐Ÿงฐ Technologies & Tools Used

โš›๏ธ Frontend

  • React โ€“ Component-based UI development
  • React Router โ€“ Client-side routing and navigation
  • Vite โ€“ Fast development server and build tool
  • JavaScript (ES6+) โ€“ Application logic and API handling
  • CSS โ€“ Styling and layout

๐ŸŒ APIs & External Services

  • OpenWeatherMap API โ€“ Fetches real-time 5-day weather forecast data
  • Meme API โ€“ Retrieves random memes displayed in the app
  • OpenRouter API โ€“ Powers the AI chatbot responses
  • Speechify API โ€“ Converts text responses into AI-generated speech

๐Ÿง  AI & Browser Features

  • SpeechRecognition API โ€“ Converts user speech into text for voice features
  • face-api.js โ€“ Detects faces using the webcam for Face Login
  • Webcam / Camera API (getUserMedia) โ€“ Accesses the user's camera
  • Audio Streaming (Blob + URL.createObjectURL) โ€“ Plays generated AI voice responses

๐Ÿ” Environment & Security

  • Environment Variables (.env) โ€“ Secure storage for API keys

Example:

VITE_WEATHER_KEY=your_openweather_api_key_here
VITE_CHAT_BOT_KEY=your_openrouter_api_key_here
VITE_VOICE_BOT_KEY=your_speechify_api_key_here


โš™๏ธ React Concepts Demonstrated

  • React Hooks (useState, useEffect, useRef)
  • API data fetching with fetch
  • Async / Await handling
  • Conditional rendering
  • Component modularization
  • State management

๐ŸŽฒ Quiz Section (NEW)

  • Interactive React quizzes that let users test their knowledge across different categories. The app includes two quiz types:

1๏ธโƒฃ Geography Quiz

  • Fetches 10 geography questions from the Trivia API
  • Displays questions and answer options as clickable buttons
  • Users select answers and click Submit to see their score
  • Refreshing the page loads 10 new random questions

2๏ธโƒฃ Mixed Categories Quiz

  • Fetches 10 medium-difficulty questions from multiple categories: general_knowledge, history, music, science, food_and_drink, film_and_tv
  • Options for each question are shuffled randomly
  • Users select answers and click Submit to see their score
  • Refreshing the page loads 10 new random questions

๐Ÿ”‘ How It Works

  • User clicks a quiz type button on the main page
  • Questions are fetched from the Trivia API https://the-trivia-api.com
  • Options are displayed as clickable buttons
  • Users select answers and submit
  • Score is calculated and displayed
  • Refreshing the page reloads new random questions

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors