How Saathi works
A private chat becomes a two-person compatibility map. This page shows what runs under the surface: the architecture, how privacy is enforced, how the score is computed, and the machine learning that decides what to ask.
Architecture
Browser
Chat, map, survey. Holds no secrets and no model weights.
Next.js server (Vercel)
Server actions re-check the session on every call; scoring and ML inference run here.
Supabase Postgres
Row-level security on every table; migrations run on each deploy.
Offline: saathi-ml (Python)
Trains and evaluates four predictors, exports the in-app model as JSON weights, and serves a FastAPI service for experiments.
- Web app: Next.js 16 (App Router, React 19, server actions) on Vercel
- Database and auth: Supabase Postgres with row-level security; email one-time codes
- Email: Brevo SMTP with branded templates
- Machine learning: Python: scikit-learn, XGBoost, SHAP, FastAPI (saathi-ml)
- In-app inference: Logistic-regression weights exported to TypeScript
Privacy by design
Answers never leave their owner
Database policies let each person read only their own rows, even if the app had a bug.
Maps computed on the server
The server reads both people’s answers and returns only scores and topics, never raw answers.
Secret dealbreakers
A dealbreaker clash quietly caps that area’s score; nobody, including the owner’s match, can see it.
Anonymous research
The survey stores no names or contacts and validates every answer against the question bank.
The scoring engine
Each question gives a similarity from 0 to 1, chosen by the kind of question:
- Scales: Neighbouring answers are close: 1 − distance ÷ (options − 1).
- Categories: Same answer = 1, different = 0.
- “Mostly me / my partner”: Mirror pairs: opposite picks match (1), the same pick clashes (0).
- Flexible answers: “Happy to go with my partner” counts as a mostly-match (0.75).
- Habit vs preference: Your preference is checked against their habit, both ways; the weaker side counts.
- Non-negotiables: Areas either person marked count double in the overall score.
Machine learning
1
Ask
50 questions across 8 areas, asked privately
2
Predict
One classifier per question estimates unanswered answers
3
Choose
Entropy picks the next most informative question
4
Score
Deterministic rules turn two people’s answers into a map
Models are trained with randomly hidden answers, so they predict well from the partial answers they see mid-chat. In the chat, the model suggests the likeliest options when it's unsure, and explains which of your earlier answers drove the suggestion.
Predicting an unanswered question (held-out accuracy)
Exact answer out of 4–5 options. Top-2: the true answer is among the model's two suggestions, which is how the chat uses it. A wrong guess never changes a score: the map uses only real answers.
Questions needed for a close-enough map
Per person, until area scores are within 12 points of the full 50-question map.
- Fixed round-robin (current)25
- Coverage-adjusted entropy30
- Coverage, then information gain30
- Pure entropy30
- Information gain30
- Random order30
How close is a 25-question map to the full map?
±3.1
points on the overall score (0–100)
±10.7
points per area, on average
Unanswered questions filled by the model, compared with all 50 answered.
Most informative questions (SHAP)
- 1. Moving for a partner's career
- 2. Religion & community
- 3. Life priorities
- 4. Working hours
- 5. Cooking
- 6. Household chores
- 7. Wanting children
- 8. Income difference
How close is a short map to the full map?

On mock data the fixed round-robin order beats adaptive strategies: with one hidden trait per area, even coverage is near-optimal. The same pipeline reruns on real survey responses to test whether adaptive questioning helps on real people.
Engineering quality
42 automated tests
23 in the app, 19 in the ML project.
Exact parity
Python scoring matches the app on 30 example pairs; in-app inference matches scikit-learn to 6 decimals.
Typed end to end
Strict TypeScript, validated inputs, linted Python and TypeScript.
Try it: the demo chat, example matches, or the research survey.