Code Monkey home page Code Monkey logo

evs's Introduction

EVS Notifications System

Nobody wants their aircon to switch off in the middle of the night when their credit runs out.

The EVS notification system scrapes your credit balance daily. When your balance falls below a preset threshold, the system notifies you via Telegram bot.

Architecture

Click here for an image of the system architecture.

All operations involving data is done through individual corresponding APIs.

Components

  • Postgres database
  • Vue website for dashboard analytics
  • Telegram bot

APIs

  • CRUD operations for database
  • GET operations only for dashboard
  • Endpoint for fetching balance via web scraping
  • Endpoint for sending one-time messages via Telegram bot

Daily-run services

  • Scrape all user balances and add to database
  • Retrieve all users to notify and send notifications

Pre-requisites

  1. Python 3.6+
  2. Either:
    • Postgres 9.5
    • Docker
  3. NodeJS

Deployment

Python

The following components use Python:

  • APIs (Flask)
  • Telegram bot (python-telegram-bot)
  • Daily-run services

All Python-based components have a requirements.txt file in their corresponding folder.

Vue dashboard

There is a corresponding README in the dashboard folder. A static site is bundled using Webpack and used for hosting.

Postgres

The database is run from a Docker container. To get a database up and running on your local machine:

docker pull postgres:9.5
docker run --rm -d \
    --name pg-docker \
    -e POSTGRES_USER=ubuntu \
    -e POSTGRES_PASSWORD=password \
    -e POSTGRES_DB=evs \
    -p 5432:5432 \
    -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data \
    postgres:9.5

Afterwards, to connect to the database:

PGPASSWORD=docker psql -h localhost -U postgres -d evs

For first-time setup, run \i create_tables.sql to define database schema.

evs's People

Contributors

dependabot[bot] avatar gabrielwong159 avatar piroton avatar

Watchers

 avatar  avatar

evs's Issues

Performance monitoring

  1. Number of balances written & time elapsed
  2. Number of notifications sent & time elapsed
  3. Number of commands daily

Use HTTPS for web API

Current web API serves over HTTP, with PythonAnywhere as HTTPS proxy. Serve web API over HTTPS as well, without certification authentication.

Error catching

Existing possibles errors are not properly caught and dealt with:

  • requests.exceptions.ConnectionError: failing to connect when fetching with web
  • psycopg2.OperationalError: failing to create a database connection

Balance table in Postgres

Balance table allows for multiple entries with same username and same date. Possibly prevent such insertions.

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.