-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5d7439
commit 91134b1
Showing
5 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# 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](assets/architecture.jpg) 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+ | ||
1. Either: | ||
* Postgres 9.5 | ||
* Docker | ||
1. 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<mxfile modified="2019-06-19T09:11:45.959Z" host="www.draw.io" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36" etag="oMmGu_xdu7RLcLjB1PFZ" version="10.7.7" type="device"><diagram name="Page-1" id="bfe91b75-5d2c-26a0-9c1d-138518896778">7Zttc6o4FMc/jS/bIQkCvmzt053p3emOnb23+2YnQsRskbghVr2ffhMIAoJKfQDdbd9ITkJIzv93YnKwHdSfLB45no6/M48EHWh4iw6660D5B6D8UJZlYgEri8+pp22ZYUB/EW00tHVGPRIVGgrGAkGnRaPLwpC4omDDnLN5sdmIBcWnTrFPSoaBi4Oy9Qf1xDixOtDO7E+E+uP0ycDqJTVD7L77nM1C/bwORKP4L6me4LQvPdFojD02z5nQfQf1OWMiuZos+iRQzk3dltz3sKF2NW5OQlHnhg/xNn69H9rBYzj/Dhc/u4tfoyut1QcOZiSdhhXI/m5HTHYrRy2W2lPWPzOWVlxFsY43soHpTBdZpbzy1ecTi0SUdiXHlPSW1KXmIa/TP4JV/WuXrm6GsRBETRXI6vmYCjKYYlfVziW50jYWk0BXr6QwZMFlE+rq60hw9k76LGA87hYZyHJ69qomJQSqcdIgSFuGLCR66A94QgMVDH8Q7uEQa7MGH0Fdzj3Dchxwi6QdB9QPpS0gIzVHzF19F1CD/iBcUMntjW4lmJpVgIckeGERFZQpqytpIDzX/HmtwYR6nnLabSTdQ0Nfz0aXXlWnd8DKLM/xYB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ymP2UPsm/Zf+wgO7/BQ==</diagram></mxfile> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
## Local machine | ||
``` | ||
sudo -u postgres createuser --interactive | ||
createdb evs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
requests | ||
|