Saathi
Engineering

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.

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:

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.

MOCK DATA300 respondents · 240 train / 60 held out · live model: logreg, trained on mock_responses.csv

Predicting an unanswered question (held-out accuracy)

Most-common answer (baseline)42.6% · top-2 70%
Logistic regression (runs in the app)48.5% · top-2 79.9%
Random forest52.2% · top-2 84.7%
XGBoost50.2% · top-2 82.2%

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. 1. Moving for a partner's career
  2. 2. Religion & community
  3. 3. Life priorities
  4. 4. Working hours
  5. 5. Cooking
  6. 6. Household chores
  7. 7. Wanting children
  8. 8. Income difference

How close is a short map to the full map?

Line chart: error of area scores versus number of questions answered, for six question-ordering strategies

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.