DEV Community

Cover image for I built ChatRel — applying 7 psychology frameworks to your chat history
BerSerCarrrrrrrrrrr
BerSerCarrrrrrrrrrr

Posted on

I built ChatRel — applying 7 psychology frameworks to your chat history

Most chat analyzers give you a word cloud, a sentiment line, and a heatmap.
I wanted something different: a local tool that takes a chat history with
a partner and maps it onto frameworks that relationship scientists have
actually studied for 40+ years.

I spent a weekend building ChatRel.

🚀 Live demo (no install, synthetic data): https://ruanflux.github.io/chatrel/

The 7 frameworks (all with citations)

Framework Measures Source
Sternberg Triangular Intimacy × Passion × Commitment, weekly Sternberg (1986)
Knapp Stages 10-stage relational development Knapp (1978)
ECR-R Attachment Anxiety × Avoidance, Bartholomew 4-category Fraley et al. (2000)
Gottman 5:1 + Four Horsemen Positive-negative ratio, criticism/contempt/defensiveness/stonewalling Gottman (1994)
Social Penetration Self-disclosure depth Altman & Taylor (1973)
Critical Slowing (EWS) Variance + AR(1) as regime-shift warnings Scheffer et al. (2009)
LIWC (Chinese proxy) Function-word / cognitive / affect markers Pennebaker

What you get

Seven interactive HTML reports:

Depth report

  • Weekly IDS (Intimacy Depth Score) with Sternberg components decomposed
  • Attachment 2D scatter placing you and your partner on anxiety × avoidance
  • Conflict-repair events with initiator, peak, apology lag, and resolution
  • External resilience score (how well the relationship handles poaching / ex-mentions)
  • Memory book — auto-curated firsts, sweetest, and deepest moments
  • 12-week forecast (base / optimistic / pessimistic scenarios)

Attachment scatter

Privacy is the architecture, not a feature

  • 100% local. No API calls. No telemetry.
  • Supports Telegram JSON / generic CSV / WeChat (via external decryption)
  • Ships with a synthetic 90-day demo chat — you can evaluate the whole tool without real data
  • .gitignore blocks every pattern that would leak chat content

Known limits (documented honestly)

  • n=1 validation. Nothing calibrated against ECR-R self-report scores. Proxy signals, not diagnoses.
  • Forecasts are damped linear extrapolation with mean reversion, not Bayesian.
  • Contempt detection had to exclude 笑死 (modern Chinese "lmao", not contempt) — similar traps are in-file documented.
  • Lexicons are Chinese-only. PRs for other languages welcome.

Stack

Python 3.10+ · jieba · snownlp · pandas · plotly. MIT licensed.

Try it


bash
git clone https://github.com/ruanflux/chatrel.git
cd chatrel
pip install -e .
chatrel sample --out sample_data/synthetic_couple.json
chatrel analyze sample_data/synthetic_couple.json --out ./output
Enter fullscreen mode Exit fullscreen mode

Top comments (0)