Production-style Node.js system that scrapes opinion articles from El Pais, runs NLP analytics, stores data in MongoDB, and exposes data via an API and React dashboard.
.
├── scraper
│ ├── scraper.js
│ ├── translator.js
│ ├── imageDownloader.js
│ └── scheduler.js
├── api
│ ├── server.js
│ ├── routes
│ │ └── articles.js
│ └── controllers
│ └── articleController.js
├── database
│ ├── db.js
│ └── articleModel.js
├── analysis
│ ├── sentiment.js
│ ├── keywordExtraction.js
│ └── wordFrequency.js
├── dashboard
│ └── React frontend (Vite)
├── tests
│ └── browserstackTests.js
├── docker
│ └── Dockerfile
├── logs
├── images
├── utils
│ └── logger.js
├── package.json
├── .env
└── README.md
- Scrapes first 5 articles from
https://elpais.com/opinion/using Selenium WebDriver. - Extracts title, content, source link, image, translated title.
- Downloads article images to
/images. - Translates Spanish titles to English via
translatepackage. - Runs sentiment analysis, keyword extraction, and word-frequency analytics.
- Stores article records in MongoDB with Mongoose.
- Exposes REST APIs using Express + MVC.
- React dashboard with article cards and Chart.js analytics views.
- BrowserStack test matrix for desktop and mobile browsers.
- Scheduler via node-cron (every 24 hours by default).
- Winston logging to
/logs.
GET /api/articlesGET /api/articles/:idGET /api/articles/search?q=keywordGET /api/analytics/word-frequencyGET /api/analytics/sentiment-distribution
- Install dependencies:
npm install
- Review and update
.envif needed. - Start MongoDB locally (or set remote URI in
.env). - Run API only:
npm run start:api
- Run scheduler (scrape now + every 24h):
npm run start:scheduler
- Run both API and scheduler:
npm run start:all
- Run one-time scrape:
npm run scrape
cd dashboard
npm install
npm run devSet VITE_API_BASE_URL if API is not running on http://localhost:5000/api.
- Configure
BROWSERSTACK_USERNAME,BROWSERSTACK_ACCESS_KEY, andMONGODB_URI. - In WSL/Linux you can export BrowserStack credentials with:
export BROWSERSTACK_USERNAME=your_username export BROWSERSTACK_ACCESS_KEY=your_access_key
- Run:
npm run test:browserstack
Browsers/devices covered:
- Chrome (Windows)
- Firefox (Windows)
- Safari (Mac)
- iPhone Safari
- Android Chrome
Build and run:
docker build -f docker/Dockerfile -t elpais-platform .
docker run --env-file .env -p 5000:5000 elpais-platformContainer runs API server and scraper scheduler together.
See .env for the environment variables, including:
MONGODB_URIPORTSCRAPER_CRONUSE_BROWSERSTACKBROWSERSTACK_USERNAMEBROWSERSTACK_ACCESS_KEYTRANSLATE_ENGINETRANSLATE_API_URL
- Node.js, Express, Mongoose
- Selenium WebDriver, Axios, Cheerio
- sentiment, natural
- Winston, node-cron
- React, Vite, Chart.js
- BrowserStack Automate
- Docker