Branchwell

Docley / app

Latest: App source: CI workflows by Branchwell, 44 min ago

📁 .github
📁 Apps
📁 migrations
📁 src
📁 test
📁 tools
📄 .gitignore67 B
📄 LICENSE1.2 KB
📄 package-lock.json78.5 KB
📄 package.json368 B
📄 project.yml1.8 KB
📄 README.md3.9 KB
📄 wrangler.jsonc562 B

Docley

Every licensed doctor in America, in one free, publicly owned registry, rated by the people. Live at https://doctors.projectatom.ai. A Project ATOM project.

  • Every doctor. Loaded from the CMS NPPES NPI Registry (individual MD and DO physicians), refreshed monthly.
  • The record follows them. Official public records sit at the top of each doctor's page, tied to the
    doctor's NPI so they follow the doctor to any hospital or state: federal exclusions from the HHS-OIG LEIE
    list today, with state medical board actions and malpractice court cases (with status: filed, settled,
    dismissed or judgment) added state by state. Every entry links to its official source, and the doctor can reply.
  • One person, one rating. Passkeys only: no passwords, email links, texted codes or third-party sign-in.
    One person, one account, and new accounts are limited per network per day (we keep only an HMAC of the IP).
    The way back in after losing a device is a second passkey, added from /account. Patients answer five
    questions; doctors who claim their page can rate colleagues and reply. A score appears after 5 ratings,
    as a weighted average.
  • Fair. Comments get an automatic first check (health details, accusations, insults, contact details) and
    doubtful ones wait for a person in the review queue at /admin (signed-in admins only). See the rating rules.

Stack

Cloudflare Worker (src/), D1 with FTS5 search (migrations/), Workers AI for the first comment check. Passkeys use @simplewebauthn/server in src/passkeys.js, with single-use challenges in D1 and a small same-origin script at /assets/passkey.js. iPhone and iPad app in Apps/iOS (SwiftUI, native search and doctor pages over the JSON API; sign-in and rating open the website in the app). Apps/iOS/Docley.entitlements adds the webcredentials:doctors.projectatom.ai associated domain, and the site serves /.well-known/apple-app-site-association, so passkeys work in the app's web view. There is no Mac app: Mac users use the website.

Run it

npm install
npx wrangler d1 migrations apply docley-db --local
node tools/import-nppes.mjs --nppes test/fixtures/npidata.csv --nucc test/fixtures/nucc.csv --out out
node tools/import-leie.mjs --leie test/fixtures/leie.csv --out out
tools/load-d1.sh out --local
npx wrangler dev        # put SITE_URL="http://localhost:8787" and RATINGS_OPEN="true" in .dev.vars to test passkeys
npm test

Full data: tools/refresh.sh /path/to/work --remote downloads the newest NPPES, NUCC and LEIE files and reloads the database.

Secrets (production)

  • SESSION_SECRET: signs session cookies.
  • DOCLEY_ADMIN_SETUP_SECRET: at least 32 characters. Guards POST /api/admin-setup; without it that route is a 404.
openssl rand -base64 48 | npx wrangler secret put SESSION_SECRET
openssl rand -base64 48 | npx wrangler secret put DOCLEY_ADMIN_SETUP_SECRET
npm run migrate         # applies migrations/0003_passkeys.sql

Ratings stay closed until RATINGS_OPEN is "true". Signing in works either way, so admins can reach /admin.

The first admin

Admins are people with is_admin set; there is no admin password or token. Make a one-time link:

curl -X POST https://doctors.projectatom.ai/api/admin-setup \
  -H "x-setup-secret: $DOCLEY_ADMIN_SETUP_SECRET" \
  -H "content-type: application/json" -d '{"label":"first admin"}'
# {"url":"https://doctors.projectatom.ai/admin/setup?token=...","expires":"..."}

Open the link within 15 minutes. Signed out, it creates a new admin account with a passkey on that device. Signed in, it makes the current account an admin. Each link works once. Then add a second passkey on another device from /account.

JSON API

  • GET /api/search?q=cardiology&state=FL&page=1
  • GET /api/doctor/{NPI}

License

Public domain (The Unlicense).