Copy of README.md from aggregator-2
Generated from aggregator-2/README.md at commit e26d5055. Edit the source file, not this copy.
Smart Bid¶
A job aggregation platform that crawls multiple job boards, normalizes listings into MongoDB, and can dual-write to PostgreSQL. Runs entirely in Docker Compose.
Architecture¶
backend (Express, port 7001)
-> MongoDB (port 27017)
-> PostgreSQL (optional via POSTGRES_URL)
-> Redis (port 6379) ← BullMQ job queue
-> python-scraper (FastAPI, port 9000)
-> chrome (Selenium Grid, port 4444)
Crawler Queue System¶
Crawlers run on a BullMQ queue backed by Redis with three concurrent worker pools:
| Queue | Crawlers | Concurrency | Schedule |
|---|---|---|---|
selenium-crawlers |
22 Selenium-based site crawlers | 5 at a time | Every hour |
api-crawlers |
Remotive, JSJobs, Workable | 3 at a time | Every hour |
jobspy-crawlers |
11 job title searches via python-scraper | 2 at a time (rate-limited) | Every hour |
Monitoring dashboard: http://localhost:7001/admin/queues
Failed jobs are automatically retried up to 3 times with exponential backoff (30s → 60s → 120s).
Setup & Run¶
Prerequisites¶
Set Up Google Sheets API¶
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Sheets API (search for it under APIs & Services)
- Create a Service Account:
- Go to APIs & Services → Credentials
- Click Create Credentials → Service Account
- In the "Keys" section, click Add Key → JSON and download the file to
backend/config/ - Update
backend/utils/saveDataToSheet.jswith the filename and yourSHEET_ID - Share your Google Sheet with the service account email (Editor permissions)
Start¶
make up
Stop¶
make down
Railway¶
Deploy this stack as its own Railway project, separate from the FastAPI Aggregator service. Create these services from this repo:
| Service | Root directory | Image / start |
|---|---|---|
job-aggregator |
job-aggregator/backend |
Node API + BullMQ workers |
python-scraper |
job-aggregator/python-scraper |
JobSpy FastAPI |
chrome |
job-aggregator/chrome |
Selenium standalone Chrome |
| Redis | Railway Redis plugin | used by BullMQ |
| MongoDB | Atlas or Railway plugin | MONGODB_URI + MONGODB_DB_NAME |
Keep one replica on job-aggregator and chrome. Give chrome plenty of RAM (8 GB+). Disable app sleeping so hourly crawlers keep running.
Backend variables:
PORT=7001
MONGODB_URI=mongodb+srv://...
MONGODB_DB_NAME=smartBid
REDIS_URL=${{Redis.REDIS_URL}}
SELENIUM_REMOTE_URL=http://chrome.railway.internal:${{chrome.PORT}}
PYTHON_SCRAPER_URL=http://python-scraper.railway.internal:${{python-scraper.PORT}}
CORS_ORIGIN=*
TELEGRAM_BOT_TOKEN=
TELEGRAM_CHAT_ID=
TELEGRAM_THREAD_ID=
# TELEGRAM_NOTIFY_SUCCESS=false
Health checks:
- backend:
GET /health - python-scraper:
GET /health - chrome:
GET /status
Local Docker Compose is unchanged (make up).
Crawler Telegram alerts use the same bot/chat vars as Aggregator. Unset token = no-op. Failures send after the last retry. Resolve-URL and enrich jobs stay quiet (too many). Set TELEGRAM_NOTIFY_SUCCESS=false if hourly crawler success floods the topic.
Development¶
This Docker setup does not use source bind mounts for backend or python-scraper, so code changes are applied only after rebuilding images.
Apply local code changes:
docker compose up -d --build backend python-scraper
Enter the backend container:
docker exec -it smart-bid-backend bash
View backend logs:
docker logs smart-bid-backend -f
Crawler Management¶
Add a new crawler¶
- Create your crawler in
backend/crawlers/mycrawler.jsfollowing the existing pattern - Register it in
backend/workers/queue/crawlers.js:
// Selenium-based:
const SELENIUM_CRAWLERS = {
mycrawler: require("../../crawlers/mycrawler"),
// ...
};
// Or API-based:
const API_CRAWLERS = {
mycrawler: require("../../crawlers/lib/mycrawler").fetchMyCrawler,
// ...
};
That's all — the crawler automatically gets a repeatable job, concurrency management, retry logic, and appears in the monitoring dashboard.
Test a crawler¶
Run a crawler directly without going through the queue or waiting for cron:
docker exec -it smart-bid-backend bash
# List all available crawlers
npm run crawl -- --list
# Run a Selenium crawler
npm run crawl -- remoteok
# Run an API crawler
npm run crawl -- remotive
# Run a jobspy search
npm run crawl -- jobspy "Software Engineer"
The script runs the full pipeline — crawl → normalize → upsert to MongoDB — and logs results to stdout in real time.
PostgreSQL dual-write and backfill¶
- Set
POSTGRES_URLinbackend/.envto enable PostgreSQL writes. - New crawls continue writing to MongoDB and also upsert into PostgreSQL table
jobs.
Manually trigger crawlers¶
# Trigger all crawlers
curl -X POST http://localhost:7001/api/crawlers/trigger \
-H "Content-Type: application/json" \
-d '{"type": "all"}'
# Trigger only Selenium crawlers
curl -X POST http://localhost:7001/api/crawlers/trigger \
-d '{"type": "selenium"}' -H "Content-Type: application/json"
# Trigger a single crawler
curl -X POST http://localhost:7001/api/crawlers/trigger \
-d '{"type": "selenium", "name": "remoteok"}' -H "Content-Type: application/json"
# List all available crawlers
curl http://localhost:7001/api/crawlers/list
Key URLs¶
| URL | Description |
|---|---|
http://localhost:7001/api/jobs/all |
Jobs API |
http://localhost:7001/admin/queues |
Bull Board queue monitor |
http://localhost:4444 |
Selenium Grid |
http://localhost:7900 |
Selenium VNC viewer (live browser view) |