...
Heroku is the cloud platform we will use to host API for application deployment, because it is easier to deploy small-size API for one project, Heroku also meets low computational demands and much more customer-oriented. So that’s why we use Heroku.
(Deveoplemt Development Software Architechture Architecture diagram)
Above shows how our application work in development, the deployment strategy have not been doen by use therefore we will add deployment architechture architecture later.
2. Discuss your current thinking about how parameters can be passed to your module and how results are collected. Show an example of a possible interaction. (e.g.- sample HTTP calls with URL and parameters) (Tingzhuang Zhou )
Initially we sign to put eveything everything query parameter in the request body, in order to make the URL string more readable for users, but soon we realized realize that GET request doensn’t countain doesn’t contain request body, therefore we have two options: to put query in query string, or to use POST request for the usage of request body, but to keep request format in standeredstandard, we have finally choose the query string as our selection.
Accessing Swagger Documentation
In local machine: http://localhost:4000/api-docs
In deployed public URL: https://news-website-seng3011.herokuapp.com/api-docs
...
API usage
Return all matching reports that match the parameters given
Code Block |
---|
GET/report/?country=''&city=''&start_date=''&end_date=''&key_terms='' |
Parameters:
country - the country to find reports for
city - the city to find reports for
start_date - the starting date and time to search for
end_date - the ending date and time to search for
key_terms - comma-separated list of key terms to search for e.g. disease names, symptoms. Can be left empty if the user wants to get all reports
If a report cannot be extracted, a message saying how many reports could not be extracted is provided, as well as a list of each article url and publish date of the article.
Example: getting all reports that mention “Outbreak” or are about “Hantavirus“ from Canberra, Australia between 2011-04-19T11:48:00 and 2022-03-16T09:38:00
Request
Code Block |
---|
curl -X 'GET' \ 'http://localhost:city4000/report?start=''&end= |
...
_date=2011-04-19T11%3A48%3A00&end_date=2022-03-16T09%3A38%3A00&city=Canberra&country=AU&key_terms=Outbreak%2CHantavirus' \
-H 'accept: appplication/json' |
Response
Code Block | ||
---|---|---|
| ||
[
{
"url": "http://www.upi.com/Top_News/World-News/2013/05/15/Salmonella-poisoning-outbreak-in-Australia/UPI-30421368619035/ ",
"headline": "Salmonella poisoning outbreak in Australia",
"main_text": "DICKSON, Australia, May 15 (UPI) -- At least 100 people have been diagnosed with salmonella poisoning after eating at a new restaurant in Australia, health officials said.",
"reports": []
},
{
"url": "https://www.foodsafetynews.com/2021/11/salmonella-top-cause-of-foodborne-outbreaks-in-australia/ ",
"headline": "",
"main_text": "Salmonella dominated reported outbreaks in Australia in 2016 causing several large incidents, according to a study published recently.",
"reports": []
},
{
"url": "https://www.foodsafetynews.com/2021/07/salmonella-dominates-outbreaks-in-australia/ ",
"headline": "",
"main_text": "More than 450 foodborne outbreaks were reported over a three-year period in Australia, according to a new study.",
"reports": []
},
"1 article(s) could not be scraped from: [{\"url\":\"http://www.healthcanal.com/infections/36035-Deadly-virus-discovered-bats-also-jumps-species.html \"}]"
] |
User can query a single report by providing
Code Block |
---|
GET/report/?{:reportId} |
...
User (frontend) related Actions
Each user will be login to our web APP by username and password. After login, user have ability to save/like the report as they wish. The saved report will be written in the database and can be Unsave as they wish. The potential usesage of this will be
...
Return all user saved report by
...
username
Request:
Code Block | ||
---|---|---|
| ||
GET/report/user/:username/ |
Response:
Code Block |
---|
[ { "url": "http://www.upi.com/Top_News/World-News/2013/05/15/Salmonella-poisoning-outbreak-in-Australia/UPI-30421368619035/ ", "headline": "Salmonella poisoning outbreak in Australia", "main_text": "DICKSON, Australia, May 15 (UPI) -- At least 100 people have been diagnosed with salmonella poisoning after eating at a new restaurant in Australia, health officials said.", "reports": [] }, { "url": "https://www.foodsafetynews.com/2021/11/salmonella-top-cause-of-foodborne-outbreaks-in-australia/:userId/ |
Save report to corresponding user, return success report saved
Code Block |
---|
POST/report/:userId/:reportId |
...
",
"headline": "",
"main_text": "Salmonella dominated reported outbreaks in Australia in 2016 causing several large incidents, according to a study published recently.",
"reports": []
},
{
"url": "https://www.foodsafetynews.com/2021/07/salmonella-dominates-outbreaks-in-australia/ ",
"headline": "",
"main_text": "More than 450 foodborne outbreaks were reported over a three-year period in Australia, according to a new study.",
"reports": []
},
"1 article(s) could not be scraped from: [{\"url\":\"http://www.healthcanal.com/infections/36035-Deadly-virus-discovered-bats-also-jumps-species.html \"}]"
] |
User can Save report to corresponding username
and reportId
return success saved report.
Request:
Code Block |
---|
POST/report/user/:username
Requset Body: {
Reports:[
{
"url": "http://www.upi.com/Top_News/World-News/2013/05/15/Salmonella-poisoning-outbreak-in-Australia/UPI-30421368619035/ ",
"headline": "Salmonella poisoning outbreak in Australia",
"main_text": "DICKSON, Australia, May 15 (UPI) -- At least 100 people have been diagnosed with salmonella poisoning after eating at a new restaurant in Australia, health officials said.",
"reports": []
},
]
} |
Response:
Code Block |
---|
{
"url": "http://www.upi.com/Top_News/World-News/2013/05/15/Salmonella-poisoning-outbreak-in-Australia/UPI-30421368619035/ ",
"headline": "Salmonella poisoning outbreak in Australia",
"main_text": "DICKSON, Australia, May 15 (UPI) -- At least 100 people have been diagnosed with salmonella poisoning after eating at a new restaurant in Australia, health officials said.",
"reports": []
}, |
User can Unsave/Remove report by username
and reportId
, return success deleted report
Request:
Code Block | ||
---|---|---|
| ||
DELETE/apireport/reportuser/:userIdusername/:reportId |
Response:
Code Block |
---|
{
"url": "http://www.upi.com/Top_News/World-News/2013/05/15/Salmonella-poisoning-outbreak-in-Australia/UPI-30421368619035/ ",
"headline": "Salmonella poisoning outbreak in Australia",
"main_text": "DICKSON, Australia, May 15 (UPI) -- At least 100 people have been diagnosed with salmonella poisoning after eating at a new restaurant in Australia, health officials said.",
"reports": []
}, |
Sample disease report
Code Block | ||
---|---|---|
| ||
report = { id: 'sample_id', url: 'http "url": "https://outbreakswww.globalincidentmap.com/xxx',who.int/csr/don/17-january-2020-novel-coronavirus-japan-ex-china/en/", "date_of_publication": "20222020-0201-2317 16xx:07xx:00xx", country "headline": "United KingdomNovel Coronavirus – Japan (ex-China)", city: "London", eventType: "Salmonella Outbreak (Suspected or Confirmed)", location: { latitude: 51.507, longitude: -0.128 } } |
The database design
...
"main_text": "On 15 January 2020, the Ministry of Health, Labour and Welfare, Japan (MHLW) reported an imported case of laboratory-confirmed 2019-novel coronavirus (2019-nCoV) from Wuhan, Hubei Province, China. The case-patient is male, between the age of 30-39 years, living in Japan. The case-patient travelled to Wuhan, China in late December and developed fever on 3 January 2020 while staying in Wuhan. He did not visit the Huanan Seafood Wholesale Market or any other live animal markets in Wuhan. He has indicated that he was in close contact with a person with pneumonia. On 6 January, he traveled back to Japan and tested negative for influenza when he visited a local clinic on the same day.",
"reports": [
{
"event_date": "2020-01-03 xx:xx:xx to 2020-01-15",
"locations": [
{
"country": "China",
"location": "Wuhan, Hubei Province"
},
{
"country": "Japan",
"location": ""
}
],
"diseases": [
"2019-nCoV"
],
"syndromes": [
"Fever of unknown Origin"
]
}
]
} |
We design a light weight database with 4 fields, the country and city are storing for fast enumerate purpose in query suggestions.
...
ReactJS: an open-source frontend JavaScript library
We chose ReactJS for the frontend because it supports the use of components, which allows us to reuse existing code instead of having to rewrite similar features, which in turn allows for faster development
React is also better in terms of performance comapred compared to other frameworks like Angular, as it only updates components in the DOM whose state has changed, instead of updating every component again, making our app lightweight and flexible
React also has plenty of documentation and online resources, so the members of our team who were unfamiliar with it would be able to pick it up quickly
...
MongoDB: a cross-platform, NoSQL database
Initial database options are: MongoDB, PostgreSQL, SQLite
We chose MongoDB as our database as our app isn’t very big, so we didn't need to use SQL
MongoDB is more scable as it will inital initial a new data fields whenevery whenever we create the documents in database, hence suitable for agile iteration when adding new feature later.
Additionally, MongoDB integrates well with NodeJS, and stores data in JSON format, which matches the format our API will output in
...
Postman: API testing application
We chose Postman over other tools such as Insomnia to test our API as a few of our members had experience using it
Postman also provides the ability to collaborate as a team to write, store and run test cases
Specific Libraries:
Web scraping - Puppeteer
...
:
...
Library - PuppeteerJS, Morgan(logger), Winston(Logger), Nodemon, CORS (TODO)
PuppeteerJS: an open-source NodeJS library
We use PuppeteerJS for scraping the website as the library allows the backend to run a headless (a code-only) version of Chrome to load the websites on.
A headless version of Chrome doesn’t use as much resources and as such can be easily run in any server, such as the hosting servers that we are using.
PuppeteerJS also have high-level API control of the Headless Chrome browser via the DevTools Protocol. This allows for the code to read the structure code of the website directly and to access the required parts of the website.
Morgan: HTTP request logger middleware for nodeNode.js
Winston: Another logger for both develop and production environment.
CORS: NPM package for solving Cross Origin Resouce Resource Sharing problems
dotEnv: abstracting environment variable and url configurations in .env file, making swaping of environment between development/production feasible.
UI design - Material UI
Material UI (MUI): an open-source frontend framework for React components based on Google’s Material Design
We decided to use MUI as it would make the development of our app quicker and easier. Since MUI defines its own components, we can use them to quickly design the UI of our app, instead of spending time writing our own CSS classes
Since we had decided to use React for our frontend, and MUI uses React components, it was only logical we used MUI over other non-React frameworks such as Bootstrap
Additionally, some of our team members already had some experience using it. The extensive documentation also means it will be quick and easy for the team members who haven’t used it before to pick up, as well as debug
By using MUI, we can keep our frontend UI theme consistent, and even customise it to suit our needs