How HairPath is built
HairPath is an AI-native project twice over: AI is in the product, and AI built most of the product — directed, reviewed, and corrected by a human. This page is the honest engineering story, for anyone who wants to look under the hood.
Built with AI, accountable to a human
The codebase is developed in close collaboration with Claude: the founder sets direction, makes the product and compliance calls, and reviews every change; the AI writes, tests, and debugs the implementation. Features on this site — the assessment funnel, the research pipeline, the observability layer — went from idea to tested, committed code in hours, not weeks. The same accountability rule that governs the product governs the process: AI proposes, a human approves.
AI in the product: two bounded features, not an agent
There are exactly two AI call sites, and both are single structured calls — a deliberate architecture choice. No agent loops, no framework, no AI deciding what to do next. In a medical-adjacent product, bounded and auditable beats autonomous:
- Vision assessment — Claude's vision model reads intake answers plus four photos and must respond through a strict JSON schema (candidacy enum, graft range, observations, confidence). The schema is enforced by the API, then re-validated in code with zod. The prompt is engineered to be conservative: bad photos return "insufficient photos", young patients get "medication first" — the model is rewarded for honesty, not for selling surgery.
- Clinic research synthesis — a retrieval pipeline (news, YouTube, Reddit via a licensed search index, permissioned forums) feeds public sources into a summarizer bound by hard rules: attribute every statement, quote verbatim with source links, negative themes need two independent sources, never judge in its own voice. Grounded generation over our own corpus — RAG without the vector database a corpus this size doesn't need. Code then mechanically enforces what prompts can't guarantee: quote lengths clipped, source IDs validated, theme counts capped.
A third, quieter AI pass extracts structured facts (graft counts, techniques, follow-up months) from patient-posted threads — instructed to return null over guessing — powering attribute-matched "similar cases" on assessment results. Attribute matching, never image similarity: face embeddings are biometric data, and we simply refuse to process any.
Humans gate every exit
- Assessments ship as educational estimates; treatment decisions require a licensed physician.
- Research summaries generate as drafts; a human reviews and approves each one before it publishes.
- Leads are never forwarded to any clinic without the patient's separate, explicit consent.
- The AI never ranks clinics, scores patients, or publishes unreviewed.
Observability, built in-house on purpose
Every AI call is traced — model, prompt version, token usage, cost, latency, stop reason, and the full raw response — into our own database rather than a third-party observability SaaS, because traces contain health data and health data does not leave our infrastructure. Prompt versions are recorded with every output, so any published summary is traceable to the exact prompt that produced it. The trace log has already paid for itself: it diagnosed a token-budget truncation bug in two queries. Next on the roadmap it becomes the substrate for a doctor-labeled eval set.
Compliance as architecture, not paperwork
The legal posture is designed into the system: educational-estimate framing keeps the product out of diagnosis territory; consent for clinic sharing is a separate, optional checkbox whose absence hard-blocks forwarding; photos are stripped of EXIF on-device and stored outside the web root; clinic pages state facts only as sourced claims ("as stated by the clinic") or attributed community discussion, with a verbatim right of reply. Built to the strictest state health-data standard rather than the loosest.
The stack, plainly
Next.js 15 + TypeScript + Tailwind, SQLite behind a thin DAO layer, photos on disk behind a storage interface — deliberately boring, with each piece chosen so the production swap (Postgres, object storage) touches three files, not thirty. The Anthropic SDK is called directly: with two call sites, a framework would add abstraction without adding value.
Questions about the engineering: feedback@hairpath.io · About the project · Research methodology