Back To Projects

MindMirror Conversational AI Agent

Rather than building a general chatbot, this service was intentionally constrained around psychology interpretation. That tradeoff improves relevance, trust, and production safety.

Default portfolio cover image for the MindMirror Conversational AI Agent case study.

Project Overview

What I built, the problem, and the solution

Built a memory-aware AI service that turns structured MindMirror predictions into grounded conversational explanations using user-specific retrieval, cache reuse, and corrective web search with explicit domain restrictions.

Challenge Framing

MindMirror predictions and scores were useful but difficult to interpret conversationally, while unconstrained assistants would introduce hallucination and out-of-scope risk in a sensitive domain.

Solution Strategy

I designed a LangGraph-based orchestration flow with domain routing, user-scoped retrieval, hybrid memory, semantic cache reuse, and corrective search rules that stay inside psychology.

Project Highlights

Five-route guarded router for direct, RAG, memory, web-search, or reject decisions.Hybrid memory design with short-term turns and distilled long-term facts.CAG semantic cache plus weak-context corrective search.SSE graph streaming for stage-level execution visibility.

Tech Stack

Built with tools chosen for reliability and iteration speed

Agent orchestration, guarded retrieval, personalized memory, domain safety, and operational observability for AI-backed products.

Backend

  • FastAPI

AI / ML

  • Python 3.10
  • LangGraph
  • LangChain
  • OpenAI

Data

  • Supabase
  • Chroma

DevOps

  • Tavily

Key Features

Guarded routing

The router enforces domain restriction before retrieval or generation begins.

User-scoped retrieval

Prediction data is resolved against canonical user identity before context assembly.

Personalized memory

Short-term conversation state and long-term facts are recalled under a strict token budget.

Operational transparency

SSE streaming and observability hooks expose graph progress, latency, and debugging context.

Architecture

System architecture designed as a readable engineering story

Each layer stays explicit so reviewers can quickly understand where interface, orchestration, persistence, and service responsibilities live.

01

API Surface

Chat, streaming, health, graph, and memory endpoints expose the service to MindMirror clients and developers.

FastAPISSEPydantic
02

Agent Orchestration

LangGraph coordinates recall, routing, cache, retrieval, synthesis, and memory write-back.

LangGraphLangChainOpenAI
03

Persistence + Retrieval

Supabase stores operational memory and user data while Chroma supports semantic cache lookup.

SupabaseChromaTavily

System Flow

Key stages broken down as a readable execution path

The pipeline section keeps the most important engineering steps visible without collapsing them into generic bullet lists.

01

Recall

Load recent turns and long-term facts under a bounded context budget.

Supabasetoken budgeting
02

Route

Classify the query into a safe execution path and reject non-psychology requests.

OpenAILangGraph
03

Retrieve

Resolve user identity, fetch prediction context, or expand into corrective search when internal evidence is weak.

SupabaseTavilyChroma
04

Synthesize

Generate grounded explanations, then persist cache hits and memory-worthy facts for future turns.

OpenAILangGraph

Timeline

A case-study flow that explains how the system took shape

This timeline keeps the implementation story concise: what was framed first, what was hardened next, and what ultimately made the project production-ready.

01
Phase 01

Domain-bounded assistant design

Constrained the assistant to psychology and MindMirror contexts before retrieval logic was added.

02
Phase 02

Memory and cache personalization

Introduced short-term recall, long-term fact distillation, and semantic cache reuse for repeated queries.

03
Phase 03

Operational instrumentation

Added streaming graph visibility and observability hooks to support debugging and cost inspection.

Challenges

Technical constraints, decisions, and the reasoning behind them

Each challenge is tied to a concrete design choice and a specific outcome.

Solution

Added layered routing constraints, a fixed safe route set, and reject paths before retrieval and synthesis.

Outcome

Improved trust and reduced generic-chatbot drift.

Solution

Separated short-term memory from distilled long-term facts and enforced a strict recall budget.

Outcome

Maintained personalization without degrading answer quality.

Solution

Combined exact cache keys with semantic similarity matching scoped by user, route, and context hash.

Outcome

Improved repeat-query efficiency while staying personalized.

Results

Metrics and outcomes presented for quick technical review

The emphasis here is signal, not decoration: key numbers, verifiable outcomes, and the context needed to interpret them responsibly.

7nodes

Execution Graph

Recall through memory write-back in a reusable LangGraph flow.

5

Route Types

Direct, RAG, memory, web search, and reject.

500tokens

Recall Budget

Memory context stays constrained and intentional.

30 / 90d

Memory Policy

Short-term turns plus 90-day long-term fact retention.

Key Results

  • Built a guarded conversational layer over structured MindMirror prediction outputs.
  • Implemented a 7-node LangGraph workflow with routing, memory, cache, retrieval, and write-back stages.
  • Enabled user-scoped explanations through Supabase-backed retrieval and hybrid memory.
  • Improved repeat-query efficiency with cache reuse and weak-context correction paths.

Business Impact

Product value

Turns raw behavioral inference tables into an explainable conversational experience that feels more useful to end users.

Engineering value

Shows a mature AI system design mindset: scoped behavior, explicit routing, memory policy, observability, and fallback control.