Copy of CLAUDE.md from aggregator-2
Generated from aggregator-2/CLAUDE.md at commit e26d5055. Edit the source file, not this copy.
CLAUDE.md¶
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview¶
Smart Bid is a job aggregation platform that crawls ~45 job boards and normalizes listings into MongoDB. Runs entirely in Docker Compose.
Monorepo structure:
- backend/ — Node.js/Express API server (CommonJS, no TypeScript)
- python-scraper/ — FastAPI microservice using python-jobspy
Architecture¶
backend (Express, port 7001)
-> MongoDB (port 27017)
-> Redis (port 6379) <- BullMQ job queue
-> python-scraper (FastAPI, port 9000)
-> chrome (Selenium Grid, port 4444)
Four BullMQ worker pools process crawlers on cron schedules. All config in backend/config/queue.js, crawler registry in backend/workers/queue/crawlers.js. All crawled jobs pass through backend/workers/normalize.js (dedup by URL, title filter, skill extraction, redirect resolution, upsert to local + cloud MongoDB).
Build / Run Commands¶
Docker (primary workflow)¶
make up # docker compose up -d
make down # docker compose down
Backend (inside container: docker exec -it smart-bid-backend bash)¶
npm run dev # Nodemon (auto-reload)
npm start # Production
npm run lint # Prettier check
npm run format # Prettier write (run before committing)
npm run crawl -- --list # List all crawlers
npm run crawl -- remoteok # Test Selenium crawler
npm run crawl -- remotive # Test API crawler
npm run crawl -- "fantastic-jobs/advanced-linkedin-job-search-api" # Test Apify crawler
npm run crawl -- jobspy "AI Engineer" # Test jobspy search
Code Style¶
- Prettier is the sole formatter. Double quotes, trailing commas (ES5), 2-space indent.
- Backend: CommonJS (
require/module.exports). - Always run
npm run formatbefore committing.
Import Order (Backend)¶
- Node built-ins → 2. Third-party → 3. Local config/utils → 4. Models → 5. Workers/crawlers
Crawler Conventions¶
Design rules: One page load, one executeScript batch extraction, normalize(), done. Use setPageLoadStrategy("none") + driver.wait() instead of sleeps. Never open extra tabs unless necessary. Paginate conservatively (3-10 pages max).
Required fields: title and url. All others optional with try/catch. source must be bare hostname (e.g. "remoteok.com").
Crawler shape:
{ title, url, companyName, source, companyLogo?, companySize?, locations?, description?, salary?, stack?, keyword?, remote?, meta? }
Always return await normalize(result, options, job) — returns { raw, afterFilter, afterDedup, inserted, skipped }.
Logging in Crawlers¶
Never use console.log in backend/crawlers/. Use job_logger:
const { createJobLogger } = require("../../utils/job_logger");
const jl = createJobLogger(job);
await jl.log("milestone"); // Logs tab
await jl.error("recoverable error"); // Logs tab, does not throw
await jl.fatal("unrecoverable"); // Logs + throws → marks job failed
await jl.progress({ raw, inserted });// Progress tab
Adding a New Crawler¶
Selenium or API: Create file in backend/crawlers/selenium/ or backend/crawlers/api/, add one line to the registry in backend/workers/queue/crawlers.js, test with npm run crawl -- <name>.
Apify: Create file named after actor slug in backend/crawlers/apify/, add to APIFY_CRAWLERS with key author/actor-name, call normalize(result, { skipTitleFilter: true }, job).
Key Files¶
| Path | Purpose |
|---|---|
backend/server.js |
Express entry point, queue init, Bull Board mount |
backend/config/queue.js |
Redis, queue names, concurrency, cron schedules |
backend/workers/queue/crawlers.js |
Crawler registry — add new crawlers here |
backend/workers/normalize.js |
Dedup, title filter, skill extraction, DB upsert |
backend/models/jobs/job.js |
Job Mongoose schema |
backend/utils/job_logger.js |
Bull Dashboard logger |
backend/bin/crawl.js |
CLI tool to test individual crawlers |
| ## Monitoring |
- Bull Board:
http://localhost:7001/admin/queues - Selenium Grid:
http://localhost:4444 - Selenium VNC:
http://localhost:7900 - Python scraper docs:
http://localhost:9000/docs