Giter VIP home page Giter VIP logo

django-weather-app's Introduction

Weather Board Django App

This repo introduces a simple Django app that utilises OpenWeather API to create a board of weather information of arbitrary locations that a user can manage.

Available Functionality

User

  • Add a place to get weather data
    • Type a location of interest in the search bar
    • Select the desired option
    • Press the Add button
  • Remove a place from the board
    • Press a Rubbish Bin icon on the card corresponding to the location you're looking to remove
  • Update the weather details
    • Currently implemented via repeated adding of the place. If the place being added already exists, the weather info will be updated for the existing record and no new place will be added.

alt text

Supporting Functionality

Autocomplete

Suggest locations from entered details and based on the geo-coding API recommendations. alt text

Admin console

Manage the raw backend using an admin account (needs to be set on the server from within the container) alt text

App Details

Requirements

  • Docker client needs to be installed and running
  • .env file in the same directory as the source code
    • sample file with the required params is available at sample-env-file
    • Note, admin console CSS wouldn't work properly unless the app is in the DEBUG mode (set DJANGO_DEBUG=1 in .env), it has to do with serving static files in the production environment which I've not setup for the purposes of this exercise.

Build Container & Access the app

  1. Once ready, from the code directory run:
    • docker compose up
  2. Access the app at
    • http://0.0.0.0:8000/
  3. Use Ctr+C to stop the container
  4. Clean up (remove the container and the image)
    • docker compose down --rmi all

App Structure

  • Backend:

    • Django
    • OpenWeatherAPI
    • SQLite managed by Django
    • PyTest
  • Frontend:

    • Django HTML templates
    • Ajax
    • jQuery
    • Bootstrap

Testing

For tests with coverage details from the working directory of the container (/wdir) run:

  • pytest --cov --cov-config /wdir/src/.coveragerc src

Coverage report

alt text

There is a total of 9 tests as described below:

  • Open Weather API - test the API connection and API handling fundtionality, namely OpenWeatherAPI class & data containers
  • Backend endpoint testing - test IO for backend endpoints
  • Frontend template selection - test that a correct template is executed
  • Database management - test that objects are created in and removed from the database as expected

Future Work

Technical Improvements

  • [FIXED] Frontend: refactor card construction/list management
  • [FIXED] Backend: improve the consistency of the naming
    • Currently, location coordinates & autocomplete names are fetched from geo-coding but the final location names used on cards are extracted from the weather API and are obtained via the cords.
    • This often results in slight discrepancies between "what was added" and "what is shown on the card"
    • Solutions: (i) reuse geo-coding names or (ii) have a consistent coord-location mapping
  • Backend: standard handler to a response
  • Backend: standardised error management
  • Add CI/CD

Additional Functionality

  • [Simple] Add a button to update card info in a more convenient way
  • [Simple] Make cards look nice, add weather icons
  • [Med] Add card-level functionality to generate holiday/things to do ideas
  • [Med] Add card-level functionality to gather hottest events
  • [Hard] Add card-level functionality to gather sentiment and most popular articles/insta/X posts about the place

django-weather-app's People

Contributors

dminskiy avatar

Watchers

 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.