A minimal demo of a chat assistant that remembers users across sessions with Cria.
- Single-page App Router UI
- Streaming chat API route
- SQLite-backed summaries + vector recall
- Explicit Save session step so memory boundaries are visible
![]() |
![]() |
![]() |
![]() |
npm install
cp .env.example .envAdd your key in .env:
OPENAI_API_KEY=your_key_hereRun:
npm run devOpen http://localhost:3000.
- Send a personal message, e.g.
Hi, I'm Alex. I work as a data scientist and I love TensorFlow.
- Ask one more related question.
- Click Save session.
- Ask:
What do you remember about me?
You should see recall from the saved session.
On each chat request, the prompt is composed from:
- App system prompt
- Long-term user summary
- Vector recall from prior saved sessions
- Session summary for older turns (when needed)
- Recent messages verbatim
When you click Save session, we:
- summarize the current session,
- update the rolling user summary,
- index the session summary in the vector store,
- clear in-memory session state.
SQLite file: data/cria.sqlite
src/lib/memory.ts— memory composition + persistenceapp/api/chat/route.ts— prompt rendering + streaming responseapp/api/reset/route.ts— explicit session finalizationapp/page.tsx— minimal demo UI
| Variable | Default | Purpose |
|---|---|---|
OPENAI_API_KEY |
required | OpenAI auth |
LLM_MODEL |
gpt-5-nano |
Chat model |
TOKEN_BUDGET |
40000 |
Prompt render budget |
MAX_RESPONSE_TOKENS |
700 |
Max output tokens |
MEMORY_VECTOR_LIMIT |
4 |
Max recalled vector hits |
MEMORY_DB_PATH |
./data/cria.sqlite |
SQLite path |
npm run dev # start dev server
npm run build # production build
npm run test # run tests
npm run check # lint/format checks (Ultracite)
npm run fix # auto-fix lint/format issues



