Code Monkey home page Code Monkey logo

congenial-weatherman's Introduction

congenial-weatherman

A simple weather forcasting app build with FastAP, Strawberry, ODMantic and Mongodb

Getting started

You will need python 3.10 and above to run this app

Install or update pip pip install --upgrade pip

install virtualenv pip install virtualenv or install miniconda to isolate your python evironment

Create an python evironment using virtualenv virtualenv -p python3 venv (venv is the name of your environment and you can named it anything)

Or if you like to use miniconda create an environment like this conda create -n venv

Activate your env source venv/bin/activate

Install docker here

Start docker

Run

Create your .env file with touch .env and add the following variables. update to your specific use case

MONGO_PORT=27017
MONGO_USER=username
MONGO_PASSWORD=root
MONGO_DATABASE=dev
MONGO_HOST=db
REDIS_HOST=redis
REDIS_PORT=6379
DEBUG_MODE=True
PORT=80

WEATHER_API_ENDPOINT = "https://api.openweathermap.org/data/2.5"
WEATHER_API_KEY = [YOU API KEY]

To launch the app run make start

Testing

run pytest tests

go to http://localhost:8000/graphql run some queries and mutations

GraphQL Queries

  • query weather by city, date and time. Use date format utc "YYYY-MM-DD HH:MM:SS" Forcast date must be within 5 days of current date
query getWeather {
  getWeatherByCity(cityName: "Los Angeles", date: "2023-02-24 00:00:00") {
    name
    weatherData {
      dateTime
      humidity
      temperature
    }
  }
}
  • Get a user favorites weather data by user id, user_id is obtain during user creation
query getFavs {
  getFavorites(userId:"63f862cc0065fab44d366aa9") {
    name
    weatherData{
      dateTime
      temperature
      humidity
    }
  }
}
  • Check if a city's weather info exist
query getCity {
  getCityData (cityName: "Seattle") {
    name
    weatherData{
      dateTime
      temperature
      humidity
    }
  }
}
  • Query a user by user_id.
query user {
  getUser (firstName: "Elon", userId: "63f862cc0065fab44d366aa9") {
     id
    firstName
    lastName
  }
}

GraphQL Mutations

  • create a user
mutation myMutation{
 addUser(firstName:"Elon", lastName: "Monk") 
}
  • add favorite
mutation addFavs {
  addFavorites(city:"Los Angeles", userId: "63f862cc0065fab44d366aa9") {
    name
   weatherData {
    dateTime
    temperature
    humidity
  	}
  }
}
  • delete favorite
mutation deleteFav {
  removeFavorites(city:"Seattle", userId:"63f862cc0065fab44d366aa9") {
    name
    weatherData{
      dateTime
    }
  }
}

congenial-weatherman's People

Contributors

ledrui avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.