Copy of README.md from unicorn_aggregator
Generated from unicorn_aggregator/README.md at commit 5f56169c. Edit the source file, not this copy.
Remote Jobs Aggregator (FastAPI)¶
FastAPI project that aggregates remote jobs via the Fantastic Jobs API and SimpleApply Jobs sources into MongoDB, with REST endpoints and optional hourly background scheduling.
Provider¶
fantastic— ATS career sites + job boards (viaPOST /api/aggregateor CLI)simpleapply-jobs— simpleapply.ai, hiring.cafe, and builtin.com fetchers normalized into MongoDB jobs
Job model (shared with Smart Apply backend)¶
Aggregated jobs are stored in the same MongoDB database/collection the backend uses (smart-apply.jobs by default). Core fields match backend JobBase:s
class JobBase(BaseModel):
url: str # final URL after redirects
sourceURL: Optional[str] = None # original listing URL from the provider
title: Optional[str] = None
locations: Optional[list[str]] = None
companyName: Optional[str] = None
source: Optional[str] = None # job platform (linkedin, indeed, greenhouse, …)
aggregator: Optional[str] = None # fetcher (fantastic, …)
salary: Optional[str] = None
description: Optional[str] = None
stack: Optional[list[str]] = None
remote: Optional[bool] = None
workplaceType: Optional[str] = None
On insert, the aggregator also initializes backend-compatible fields:
createdAtassignees: []applications: []favorited_by: []
Existing backend workflow data is preserved on re-aggregation (upsert matches by final or original URL).
Easy Apply: EXCLUDE_EASY_APPLY=true (default) drops LinkedIn/Indeed/Glassdoor/Wellfound listings that use in-platform apply (direct_apply) or have no external company apply URL.
Redirect resolution: RESOLVE_JOB_URLS=false by default — each job was doing a sequential HTTP request (up to 30s), which made aggregation very slow. Set RESOLVE_JOB_URLS=true to resolve ATS/apply links to their final URL; job-board URLs (LinkedIn, Indeed, etc.) are skipped automatically.
Project Structure¶
app/
main.py # FastAPI app + optional scheduler
config.py # Settings from .env
database.py # MongoDB persistence
schemas.py # JobBase and API schemas
aggregator/ # Provider fetch logic
fantastic_jobs.py # Fantastic Jobs API + standalone CLI
simpleapply_jobs.py # SimpleApply Jobs provider (no sheet/Excel output)
service.py # Provider registry
routers/ # API routes
aggregate_jobs.py # CLI wrapper
run_project.ps1 # One command to start API server
Quick Start (One Command)¶
- Start MongoDB locally (default:
mongodb://localhost:27017) - Create env file:
Copy-Item .env.example .env
-
Edit
.envand set: -
FANTASTIC_JOBS_API_KEY SIMPLEAPPLY_EMAIL/SIMPLEAPPLY_PASSWORDif enablingsimpleapply-jobs-
MONGODB_URI(if not using local default) -
Start the API:
.\run_project.ps1
Server defaults:
- URL:
http://127.0.0.1:5000 - Docs:
http://127.0.0.1:5000/docs
API Endpoints¶
GET /health— health checkGET /api/jobs— list stored remote jobs (source,aggregator,search,limit,offset)GET /api/jobs/{job_id}— get one job by MongoDB idPOST /api/aggregate— fetch from configured providers and save to DBGET /api/providers— list available providers
Examples¶
Trigger aggregation:
Invoke-RestMethod -Method Post -Uri "http://127.0.0.1:5000/api/aggregate" -ContentType "application/json" -Body '{}'
List jobs:
Invoke-RestMethod -Uri "http://127.0.0.1:5000/api/jobs?limit=20"
List Fantastic jobs only:
Invoke-RestMethod -Uri "http://127.0.0.1:5000/api/jobs?aggregator=fantastic&limit=20"
Run SimpleApply Jobs only:
Invoke-RestMethod -Method Post -Uri "http://127.0.0.1:5000/api/aggregate" -ContentType "application/json" -Body '{"providers":"simpleapply-jobs"}'
Scheduled Aggregation¶
run_project.ps1 enables the in-app background scheduler by default with two separate jobs:
fantasticruns every 1 hour.simpleapply-jobsruns once at startup, then every 24 hours, and uses thesimpleapply,builtin, andhiringcafesources by default.
.\run_project.ps1
Use different intervals when needed:
.\run_project.ps1 -FantasticSchedulerIntervalHours 2 -SimpleApplySchedulerIntervalHours 12
Disable background aggregation for a local API-only run:
.\run_project.ps1 -DisableScheduler
You can also control the scheduler from .env:
ENABLE_SCHEDULER=true
FANTASTIC_SCHEDULER_INTERVAL_HOURS=1
SIMPLEAPPLY_SCHEDULER_INTERVAL_HOURS=24
Or register a Windows scheduled task:
.\schedule_hourly_task.ps1
Railway¶
This service is independent of job-aggregator. Deploy it as its own Railway service with root directory Aggregator. Keep one replica so the in-app scheduler does not double-run.
Required variables:
MONGODB_URIFANTASTIC_JOBS_API_KEYSIMPLEAPPLY_EMAIL/SIMPLEAPPLY_PASSWORDifsimpleapply-jobsis enabledTELEGRAM_BOT_TOKEN+TELEGRAM_CHAT_ID(optional;TELEGRAM_THREAD_IDfor a forum topic)
Scheduler turns on automatically on Railway. Override with ENABLE_SCHEDULER=false if you only want the API. Health check is GET /health. Dashboard is GET /admin/dashboard.
Do not turn on app sleeping. The hourly Fantastic and daily SimpleApply jobs need a process that stays up.
CLI (without API)¶
.\.venv\Scripts\python.exe .\aggregate_jobs.py
Or use the Fantastic Jobs module directly:
.\.venv\Scripts\python.exe -m app.aggregator.fantastic_jobs
Fantastic Jobs¶
Standalone module at app/aggregator/fantastic_jobs.py that fetches from the Fantastic Jobs API v1 (ATS career sites + job boards). It uses a count-first flow (active-*-count, then paginated active-*) and applies these default filters:
- Non-onsite US jobs (
Hybrid,Remote OK,Remote Solely) - Server-side
title_advanced/organization_advancedare built from globalBLOCKED_JOB_TITLE_KEYWORDS/BLOCKED_COMPANY_NAME_KEYWORDS(local trailing*becomes API:*) - Local second pass uses the same global lists after normalize (whole-word titles; trailing
*= prefix; companies matched by normalized exact name) - Excludes LinkedIn Easy Apply listings from the job-board feed
Fetch and save to MongoDB¶
.\.venv\Scripts\python.exe -m app.aggregator.fantastic_jobs
Fetch only (no DB write):
.\.venv\Scripts\python.exe -m app.aggregator.fantastic_jobs --dry-run
Saved jobs use aggregator=fantastic and source set to the listing platform (e.g. linkedin, greenhouse). Filter with GET /api/jobs?aggregator=fantastic or ?source=linkedin.
SimpleApply Jobs¶
The simpleapply-jobs provider ports the fetchers from the sibling simpleapply-jobs project and saves normalized jobs directly to MongoDB via the shared upsert path. It does not include the Excel or Google Sheets output functions.
Enable it by adding the provider to .env:
JOB_PROVIDERS=fantastic,simpleapply-jobs
Search defaults and source selection live in app/config.py, mirroring the original simpleapply-jobs/config.py. By default, SIMPLEAPPLY_JOBS_SOURCES is simpleapply,builtin,hiringcafe; it also accepts both (simpleapply + hiringcafe) or all.
SimpleApply Jobs env vars¶
SIMPLEAPPLY_EMAIL,SIMPLEAPPLY_PASSWORD
Optional hiring.cafe source:
HIRINGCAFE_SESSIONorHIRINGCAFE_EMAIL/HIRINGCAFE_PASSWORDHIRINGCAFE_CF_CLEARANCE
Optional builtin.com source:
BUILTIN_COOKIESBUILTIN_CF_CLEARANCE
SimpleApply Jobs config.py settings¶
SIMPLEAPPLY_JOBS_SOURCESSIMPLEAPPLY_DEFAULT_SEARCH_PARAMSSIMPLEAPPLY_MAX_PAGESHIRINGCAFE_SEARCH_STATEHIRINGCAFE_MAX_PAGESBUILTIN_SEARCH_PARAMSBUILTIN_MAX_PAGES
Fantastic Jobs env vars¶
FANTASTIC_JOBS_API_KEY(required)FANTASTIC_JOBS_FEEDS(default:ats,jb)FANTASTIC_JOBS_TIME_FRAME(default:1h)FANTASTIC_JOBS_LOCATION(default:United States)FANTASTIC_JOBS_EXCLUDE_DIRECT_APPLY(default:true— skips LinkedIn Easy Apply)FANTASTIC_JOBS_EXCLUDE_ATS_DUPLICATES(default:true)FANTASTIC_JOBS_MAX_PAGESorJOB_PAGES(optional page cap per feed)- Uses global
BLOCKED_JOB_TITLE_KEYWORDS/BLOCKED_COMPANY_NAME_KEYWORDSto build API filters and the local second pass
.env Settings¶
Core:
JOB_PROVIDERS(default:fantastic; usefantastic,simpleapply-jobsto enable both)EXCLUDE_EASY_APPLYRESOLVE_JOB_URLSDEDUPE_LOOKBACK_DAYS(default:10; only dedupe against recent jobs)BLOCKED_JOB_TITLE_KEYWORDS(CSV; trailing*= prefix; whole-word title match at save time; Fantastic also buildstitle_advancedfrom this)BLOCKED_COMPANY_NAME_KEYWORDS(CSV; normalized exact company match at save time; Fantastic also buildsorganization_advancedfrom this)
MongoDB (shared with Smart Apply backend):
MONGODB_URIMONGODB_DB(default:smart-apply)MONGODB_COLLECTION(default:jobs)
FastAPI:
API_HOSTAPI_PORTENABLE_SCHEDULERFANTASTIC_SCHEDULER_INTERVAL_HOURSSIMPLEAPPLY_SCHEDULER_INTERVAL_HOURSTELEGRAM_BOT_TOKEN,TELEGRAM_CHAT_ID,TELEGRAM_THREAD_ID(optional status alerts)`
Fantastic Jobs:
FANTASTIC_JOBS_API_KEYFANTASTIC_JOBS_BASE_URLFANTASTIC_JOBS_FEEDSFANTASTIC_JOBS_TIME_FRAMEFANTASTIC_JOBS_WORK_ARRANGEMENTFANTASTIC_JOBS_LOCATIONFANTASTIC_JOBS_LIMITFANTASTIC_JOBS_EXCLUDE_ATS_DUPLICATESFANTASTIC_JOBS_EXCLUDE_DIRECT_APPLYFANTASTIC_JOBS_MAX_PAGES
SimpleApply Jobs:
SIMPLEAPPLY_EMAILSIMPLEAPPLY_PASSWORDHIRINGCAFE_SESSIONHIRINGCAFE_EMAILHIRINGCAFE_PASSWORDHIRINGCAFE_CF_CLEARANCEBUILTIN_COOKIESBUILTIN_CF_CLEARANCE
Add Another Job Site¶
- Add provider env vars in
.env.example - Create fetch function in
app/aggregator/ - Register it in
PROVIDER_FETCHERSinapp/aggregator/service.py - Add provider name to
JOB_PROVIDERS
Troubleshooting¶
- Fantastic skipped or config error: set a valid
FANTASTIC_JOBS_API_KEYin.env - SimpleApply Jobs skipped or config error: set
SIMPLEAPPLY_EMAILandSIMPLEAPPLY_PASSWORD; forhiringcafe/builtin, refresh browser cookie env vars after 403s - Empty job list: run
POST /api/aggregatefirst - MongoDB connection error: verify
MONGODB_URIand that MongoDB is running - Port in use: start with
.\run_project.ps1 -Port 5001