Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Roots

Find out why you are the way you are.


Experience Roots Live


React TypeScript Node.js MongoDB


Roots is not a chatbot. It is a guided psychological excavation — taking you through four layers of depth to surface the root cause of how you feel, why you behave the way you do, and who you actually are underneath it all.



🌟 What Roots Does

Most apps help you manage how you feel. Roots helps you understand why you feel it.

The experience is built around one structured journey:

  1. ⛏️ Excavation — a 40-question session across four psychological depth layers, each one going deeper than the last
  2. 👁️ Root Reveal — a structured, personalized insight generated from everything you shared
  3. 🧠 Living Memory — your answers, patterns, and profile accumulate across sessions so the app genuinely knows you over time
  4. 🌱 Healing — daily practices, reflections, and a visual self-map that grows as you grow

The organizing question behind every product decision: does this make the app feel like it genuinely knows the user?


🌳 The Concept of "The Root"

The entire premise of the application is that our daily struggles — anxiety, relationship tension, procrastination, or burnout — are merely symptoms. They are the leaves of a tree. To create lasting psychological change, you have to dig up the Root.

In Roots, your Root is a multi-dimensional psychological profile compiled from your answers, consisting of:

  • 🗡️ The Core Wound: The foundational event, environment, or early relationship dynamic that taught you a specific lesson about safety, worth, and survival (represented by Hero Archetypes like Batman's "Abandonment" or Tyler Durden's "False Identity").
  • 🔗 Attachment Style: How that root wound informs your subconscious rules for human connection, intimacy, and trust.
  • Trauma Response: Your default physiological reaction to stress (Fight, Flight, Freeze, or Fawn).
  • 🧩 Core Schema: The deeply ingrained, unconditional belief about yourself and the world (e.g., Defectiveness, Relentless Standards, Subjugation).
  • 🫀 Nervous System Baseline: Your autonomic baseline (Sympathetic hyperarousal vs. Dorsal vagal shutdown) when you feel threatened.

By the end of your initial 40-question Excavation, the AI pipeline analyzes your linguistic patterns, avoidances, and emotional resonances to determine your unique Root Profile. This Profile becomes the lens through which every future interaction in the app happens — from the personalized daily healing practices it creates, to the memory-aware Talk responses it generates.


🏗️ The Excavation

The core of Roots is a single 40-question excavation structured across four layers:

Layer Questions Purpose
The Surface 1 – 10 What you're feeling right now
The Patterns 11 – 20 Recurring behaviors and responses
The Origin 21 – 30 Where those patterns first appeared
The Root 31 – 40 The core belief or wound underneath everything

Each answer generates a micro-insight before the next question arrives. The session ends with a full root reveal streamed directly from your transcript.


🗺️ User Flow

Auth → Welcome → Hero Selection → Excavation → Root Reveal → Main App

Inside the main app:

  • 💬 Talk — open-ended conversation that remembers your history
  • ❤️‍🩹 Healing — daily reflection question + personalized practices + progress tracking
  • 📍 Self Map — a visual map of your patterns, triggers, and healing state
  • 📋 Core Report — your full psychological profile, built from everything you've shared

🏰 Architecture

┌─────────────────────────────────────┐
│         Frontend · Vercel           │
│  React + Vite + TypeScript          │
│  Tailwind · Framer Motion · Zustand │
└────────────────┬────────────────────┘
                 │ HTTPS · JSON · SSE
                 ▼
┌─────────────────────────────────────┐
│          Backend · Render           │
│  Node.js + Express                  │
│  JWT auth · Mongoose · SSE streams  │
│                                     │
│  Services:                          │
│  excavation · talk · healing        │
│  profile · map · session pipeline   │
└──────┬──────────────────────────────┘
       │
       ├──► NVIDIA · Gemma 3 (excavation, profile, schema work)
       ├──► NVIDIA · Gemma 3 (healing generation)
       │
       ▼
┌─────────────────────────────────────┐
│           MongoDB Atlas             │
│  Users · Sessions · Layers          │
│  Profiles · Messages · Map Nodes    │
│  Healing Artifacts · Schema Tracker │
└─────────────────────────────────────┘

💻 Tech Stack

🎨 Frontend

Technology
Framework React 18 + Vite
Language TypeScript
Styling Tailwind CSS + custom CSS variables
Animation Framer Motion
State Zustand
HTTP Axios + fetch SSE
Voice Web Speech API

⚙️ Backend

Technology
Runtime Node.js 18+
Framework Express 4
Auth JWT in httpOnly cookies
Database MongoDB + Mongoose
Streaming Server-Sent Events
Validation express-validator + bcryptjs

🤖 AI

Model Role
Gemma 3 (NVIDIA) Excavation questions, session summaries, schema tracking, profile rewriting
Gemma 3 (NVIDIA) Healing question and practice generation

Both are accessed via a single NVIDIA_API_KEY.


🗄️ Data Models

Model Purpose
User Account, phase, hero, onboarding state
Session Excavation or talk session lifecycle
Layer Individual question/answer + micro-insight
RawMessage Full transcript for every session type
SessionSummary Compressed memory after each session
LivingProfile Evolving internal user model with confidence-gated fields
RootProfile Reveal-oriented root-cause profile
SchemaTracker Long-running psychological schema signals
SelfMapNode Pattern and trigger nodes for the visual map
HealingEvent Breakthroughs, regressions, and healing signals
HealingPractice Personalized practices with streak tracking
DailyPractice Today's reflection question and response
IdentityCard User and AI-generated identity statements

🔁 Memory Pipeline

After every excavation or talk session, the backend runs a full memory enrichment pipeline:

  1. Generate a dense SessionSummary
  2. Classify healing signals and regressions from the transcript
  3. Rewrite the LivingProfile with confidence gating
  4. Detect and resolve conflicts against existing confirmed fields
  5. Merge healing-progress markers
  6. Upsert SelfMapNode entries from new patterns and triggers

This is what makes Talk, Healing, and the Core Report feel connected to who you actually are — not just what you typed today.


📂 Repository Layout

Roots/
├── backend/
│   ├── server.js
│   └── src/
│       ├── config/          db · gemma 3
│       ├── constants/       heroes
│       ├── controllers/     auth · excavation · healing · map · profile · talk
│       ├── middleware/       auth · error · validator
│       ├── models/          all data models
│       ├── routes/          all API routes
│       └── services/        context · excavation prompt & pipeline · session · map · ai
├── frontend/
│   └── src/
│       ├── components/
│       ├── hooks/
│       ├── screens/         Auth · Welcome · HeroSelection · Excavation · RootReveal
│       │                    CoreReport · TalkTab · HealingPage · SelfMap
│       ├── services/        sse · voice · api
│       ├── store/           zustand stores
│       └── utils/
├── render.yaml
└── README.md

📡 API Reference

🔐 Auth

Method Path Purpose
GET /api/auth/lookup Check if email exists and which provider
POST /api/auth/register Create account and set session cookie
POST /api/auth/login Sign in and set session cookie
POST /api/auth/logout Clear session
GET /api/auth/me Return current user
PATCH /api/auth/hero Save hero selection
PATCH /api/auth/onboarding Mark onboarding complete

⛏️ Excavation

Method Path Purpose
POST /api/excavation/start Start or resume excavation
GET /api/excavation/resume Hydrate active session and layers
POST /api/excavation/layer SSE — micro-insight + next question
POST /api/excavation/end Complete session and trigger pipeline
POST /api/excavation/reveal SSE — streamed root reveal
GET /api/excavation/status Progress and reveal readiness

💬 Talk

Method Path Purpose
POST /api/talk/start Create talk session
POST /api/talk/message SSE — streamed reply
POST /api/talk/end Complete session and trigger pipeline

👤 Profile

Method Path Purpose
GET /api/profile Root profile + living profile
GET /api/profile/report Merged data for Core Report
GET /api/profile/identity Identity cards
POST /api/profile/identity Create identity card
GET /api/profile/map Self-map nodes
GET /api/profile/activity Recent healing events

📍 Map

Method Path Purpose
GET /api/map All self-map nodes
PATCH /api/map/:nodeId Update node healing state

❤️‍🩹 Healing

Method Path Purpose
GET /api/healing/today Load or generate today's healing payload
POST /api/healing/practice/complete Toggle practice completion
POST /api/healing/practice/respond Save daily reflection response

🛠️ Local Development

📋 Prerequisites

  • Node.js 18+
  • MongoDB (local or Atlas)
  • NVIDIA_API_KEY

🚀 Setup

# Backend
cd backend
npm install
cp .env.example .env   # fill in your values
npm run dev            # runs on :3001

# Frontend (new terminal)
cd frontend
npm install
npm run dev            # runs on :5173, proxies /api to :3001

🔐 Environment Variables

backend/.env

PORT=3001
NODE_ENV=development
MONGODB_URI=mongodb://localhost:27017/roots
JWT_SECRET=your-long-random-secret
JWT_EXPIRES_IN=30d
NVIDIA_API_KEY=nvapi-your-key
CLIENT_URL=http://localhost:5173

frontend/.env

VITE_API_URL=/api

🚀 Deployment

🌐 Frontend → Vercel

  • Root directory: frontend
  • Build command: npm run build
  • Output directory: dist
VITE_API_URL=https://your-render-backend.onrender.com/api

🖥️ Backend → Render

Uses render.yaml at the repo root. Set all backend env vars in the Render dashboard.

NODE_ENV=production
MONGODB_URI=...
JWT_SECRET=...
NVIDIA_API_KEY=...
CLIENT_URL=https://find-your-root.vercel.app

Deploy backend first. Confirm GET /api/health returns 200. Then deploy frontend.


🍪 Auth & Cookies

Roots uses JWTs in httpOnly cookies. In production, cookies are configured for cross-site use (Secure, SameSite=None, Partitioned) because the frontend (Vercel) and backend (Render) are on different origins.

The frontend sends withCredentials: true on every request.


🌊 Streaming

Excavation, reveal, and talk all use Server-Sent Events — tokens stream as they are generated, not delivered all at once.

Relevant files:

  • frontend/src/services/sse.ts
  • backend/src/services/gemma.service.js

Voice input is available where the Web Speech API is supported. Excavation output is intentionally text-only.


⚠️ Safety

Roots is a psychological companion. It is not a licensed therapist, medical device, or crisis service.

If you are building on this for real users, treat safety, escalation, consent, and crisis-handling as first-class requirements.


About

Roots is an AI-guided psychological excavation app that maps your core wounds and behavioral patterns to provide deeply personalized, memory-aware healing.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages