Skip to content

FastAPI web app with clothing recommendations, real-time weather data, and user history tracking.

License

Notifications You must be signed in to change notification settings

MikhailKras/weather-buddy

Repository files navigation

WeatherBuddy Logo

WeatherBuddy

Backend Technologies

Python FastAPI PostgreSQL MongoDB Redis Celery Pytest

Frontend Technologies

Bootstrap JavaScript CSS

Example of search process

Website Demo

This is a Python web application built with FastAPI that provides current weather information. The application utilizes a PostgreSQL database that contains a table with 25,000+ cities. Users can retrieve the following information for each city:

  • Current clothing recommendations based on weather conditions (clothing information stored in MongoDB)
  • Current weather and location information (from the PostgreSQL database, including population, timezone, region, country, etc.)

Prerequisites

Before you proceed, please make sure you have the following installed on your machine:

Getting Started

  • Clone this git repo
git clone https://github.com/MikhailKras/weather-buddy.git
  • Change your working directory to the weather-buddy directory:
cd weather-buddy
  • Set enviroment variables in .env.prod

  • Build docker image:

docker compose --env-file .env.prod build app
  • Up docker compose:
docker compose --env-file .env.prod up -d

After the successful process, you can access the Weather Buddy app by going to http://localhost:9999 in your web browser.

Features

  • User authentication with OAuth 2.0 and bearer JWT token
  • Two-step registration process:
    • Step 1: Choose city name
    • Step 2: Input additional information (username, email, password)
  • Email verification with synchronous SMTP using smtplib and Celery for asynchronous email tasks
  • Rate limiter for several endpoints with FastAPI-Limiter (using Redis)
  • CSS styles and Bootstrap 5 framework for frontend
  • JavaScript scripts for sending requests to the API
  • Search history: Track and display user's search history for cities and coordinates

Clothing Document Example (MongoDB)

{
  "_id": "64834ea1fda0d16eceebf0ca",
  "temperatureRange": { "min": 10, "max": 15 },
  "precipitation": {
    "None": {
      "UpperBody": {
        "BaseLayer": { "clothingItems": ["Light long-sleeve shirt"] },
        "MidLayer": { "clothingItems": ["Light jacket"] },
        "OuterLayerShell": { "clothingItems": [] },
        "Accessories": { "clothingItems": ["Hat"] }
      },
      "LowerBody": {
        "BaseLayer": { "clothingItems": ["Light pants"] },
        "MidLayer": { "clothingItems": [] },
        "OuterLayerShell": { "clothingItems": [] },
        "Accessories": { "clothingItems": [] }
      },
      "Footwear": { "clothingItems": ["Sneakers"] }
    },
    "Rain": {
      "UpperBody": {
        "BaseLayer": { "clothingItems": ["Light long-sleeve shirt"] },
        "MidLayer": { "clothingItems": ["Raincoat"] },
        "OuterLayerShell": { "clothingItems": [] },
        "Accessories": { "clothingItems": ["Umbrella"] }
      },
      "LowerBody": {
        "BaseLayer": { "clothingItems": ["Light pants"] },
        "MidLayer": { "clothingItems": [] },
        "OuterLayerShell": { "clothingItems": [] },
        "Accessories": { "clothingItems": [] }
      },
      "Footwear": { "clothingItems": ["Waterproof sneakers"] }
    }
  }
}

License

This project is licensed under the MIT License - see the LICENSE file for details.