- Node(>=11.12.0) and npm(>=6.7.0) installed
- mysql server and memcache server
- Get the maxmind key [maxmind.com].
- Run below command by replacing <YOUR_LICENSE_KEY> with your personal key :
cd node_modules/geoip-lite && npm run-script updatedb license_key=YOUR_LICENSE_KEY
- Create database in mysql server by running below command :
create database news_analysis
- Run
npm install
- Run below command to run migrations :
npm run migrations
- Start memcache server :
memcached -p 11211 -d
- Open the terminal and set the environment variables(On mac).
source environment.sh
- Import apis present under postman folder in postman application.
- Start the server by running below command :
node app.js
Overview:
- For get-news api, node-cache is used to cache the response for 24-hours.
- For get-news-analysis api, memcache is used to cache the response.
- There is a background script which fetches the top symbol request in minutes(configured in environment variable POPULAR_SYMBOL_VS_COUNTRY_COUNT) and updates the cache.
- For both the apis, worst case response time is 150ms and average is less than 100ms.