Skip to content

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)

Explore in graph

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 (via POST /api/aggregate or 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:

  • createdAt
  • assignees: []
  • 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)

  1. Start MongoDB locally (default: mongodb://localhost:27017)
  2. Create env file:
Copy-Item .env.example .env
  1. Edit .env and set:

  2. FANTASTIC_JOBS_API_KEY

  3. SIMPLEAPPLY_EMAIL / SIMPLEAPPLY_PASSWORD if enabling simpleapply-jobs
  4. MONGODB_URI (if not using local default)

  5. 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 check
  • GET /api/jobs — list stored remote jobs (source, aggregator, search, limit, offset)
  • GET /api/jobs/{job_id} — get one job by MongoDB id
  • POST /api/aggregate — fetch from configured providers and save to DB
  • GET /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:

  • fantastic runs every 1 hour.
  • simpleapply-jobs runs once at startup, then every 24 hours, and uses the simpleapply, builtin, and hiringcafe sources 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_URI
  • FANTASTIC_JOBS_API_KEY
  • SIMPLEAPPLY_EMAIL / SIMPLEAPPLY_PASSWORD if simpleapply-jobs is enabled
  • TELEGRAM_BOT_TOKEN + TELEGRAM_CHAT_ID (optional; TELEGRAM_THREAD_ID for 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_advanced are built from global BLOCKED_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_SESSION or HIRINGCAFE_EMAIL / HIRINGCAFE_PASSWORD
  • HIRINGCAFE_CF_CLEARANCE

Optional builtin.com source:

  • BUILTIN_COOKIES
  • BUILTIN_CF_CLEARANCE

SimpleApply Jobs config.py settings

  • SIMPLEAPPLY_JOBS_SOURCES
  • SIMPLEAPPLY_DEFAULT_SEARCH_PARAMS
  • SIMPLEAPPLY_MAX_PAGES
  • HIRINGCAFE_SEARCH_STATE
  • HIRINGCAFE_MAX_PAGES
  • BUILTIN_SEARCH_PARAMS
  • BUILTIN_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_PAGES or JOB_PAGES (optional page cap per feed)
  • Uses global BLOCKED_JOB_TITLE_KEYWORDS / BLOCKED_COMPANY_NAME_KEYWORDS to build API filters and the local second pass

.env Settings

Core:

  • JOB_PROVIDERS (default: fantastic; use fantastic,simpleapply-jobs to enable both)
  • EXCLUDE_EASY_APPLY
  • RESOLVE_JOB_URLS
  • DEDUPE_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 builds title_advanced from this)
  • BLOCKED_COMPANY_NAME_KEYWORDS (CSV; normalized exact company match at save time; Fantastic also builds organization_advanced from this)

MongoDB (shared with Smart Apply backend):

  • MONGODB_URI
  • MONGODB_DB (default: smart-apply)
  • MONGODB_COLLECTION (default: jobs)

FastAPI:

  • API_HOST
  • API_PORT
  • ENABLE_SCHEDULER
  • FANTASTIC_SCHEDULER_INTERVAL_HOURS
  • SIMPLEAPPLY_SCHEDULER_INTERVAL_HOURS
  • TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID, TELEGRAM_THREAD_ID (optional status alerts)`

Fantastic Jobs:

  • FANTASTIC_JOBS_API_KEY
  • FANTASTIC_JOBS_BASE_URL
  • FANTASTIC_JOBS_FEEDS
  • FANTASTIC_JOBS_TIME_FRAME
  • FANTASTIC_JOBS_WORK_ARRANGEMENT
  • FANTASTIC_JOBS_LOCATION
  • FANTASTIC_JOBS_LIMIT
  • FANTASTIC_JOBS_EXCLUDE_ATS_DUPLICATES
  • FANTASTIC_JOBS_EXCLUDE_DIRECT_APPLY
  • FANTASTIC_JOBS_MAX_PAGES

SimpleApply Jobs:

  • SIMPLEAPPLY_EMAIL
  • SIMPLEAPPLY_PASSWORD
  • HIRINGCAFE_SESSION
  • HIRINGCAFE_EMAIL
  • HIRINGCAFE_PASSWORD
  • HIRINGCAFE_CF_CLEARANCE
  • BUILTIN_COOKIES
  • BUILTIN_CF_CLEARANCE

Add Another Job Site

  1. Add provider env vars in .env.example
  2. Create fetch function in app/aggregator/
  3. Register it in PROVIDER_FETCHERS in app/aggregator/service.py
  4. Add provider name to JOB_PROVIDERS

Troubleshooting

  • Fantastic skipped or config error: set a valid FANTASTIC_JOBS_API_KEY in .env
  • SimpleApply Jobs skipped or config error: set SIMPLEAPPLY_EMAIL and SIMPLEAPPLY_PASSWORD; for hiringcafe/builtin, refresh browser cookie env vars after 403s
  • Empty job list: run POST /api/aggregate first
  • MongoDB connection error: verify MONGODB_URI and that MongoDB is running
  • Port in use: start with .\run_project.ps1 -Port 5001