A simple app that shows statistics about the import and export energy.
it's really important to understand the following before heading to the other sections, so based on the following json structure:
{
"measurement": "energy",
"timestamp": "2022-04-30T23:30:00.000Z",
"tags": {
"muid": "123-456-789",
"quality": "measured"
},
"0100011D00FF": 0.0883,
"0100021D00FF": 0
}
Let's understand the below:
-
measurement
: the type of measurement, and we have 2 types:energy
andpower
-
timestamp
: the time in which the electricity meter readings have been captrued(every 15 minutes). -
muid
: smart meter ID -
0100011D00FF
: it's called import energy and basically this is used to determine how much energy have been consumed. -
0100021D00FF
: it's called export energy and basically this is used to determine how much energy have been produced.
you have 3 options to get started, and before choosing the appropriate option, you have to do the following for the last 2 options:
- copy
.env.example
and rename the copied file to.env
and change all the details from that file
for the first and the secend options, project url is: http://localhost:3000
for the last option, project url is: http://localhost
After choosing the appropriate option, navigate to the project url in the browser and then you will be able to start using the project.
Please note that LIMIT
in the configuration files is used to limit the number of data returned by the 3rd party API and setting it to -1
will return all the data.
- copy
k8s/config.yaml.example
and rename the copied file toconfig.yaml
and change all the details from that file
Usage:
kubectl apply -f ./k8s
please note that: if you are using minikube
, you have to run minikube tunnel
in the terminal
Usage:
docker compose up -d
- run
npm install
- run
nodemon app.js
-
Front-end
: HTML, CSS, Bootstrap, jQuery and JavaScript -
Back-end
: Node.js, Express and MongoDB -
DevOps
: Docker, Kubernetes and SonarQube
if I was to spend additional time on the project I would do the following:
- write unit tests
- updating backend architecture (ex: using express router)
- separate front-end and back-end
Here is the quality of the code before and after applying some SonarQube improvements:
Before:
After:
- You can run SonarQube by copying
sonar-project.properties.example
and saving it assonar-project.properties
and then update all the info, and after that you can run the following:
sonar-scanner
- You can check out the API docs from here: API Documentation