Zhang Han
All work

Personal project · In development

Cattt

An iOS companion app

Tuanzi lives in a 3D felt yard, where it can chat, sit with the user and remember earlier conversations. Requests to work through ideas continue in the background, with results brought back into the conversation.

GitHub repository (opens in a new tab)
On this page
Built
iOS app · 3D world · Agent backend
Stack
SwiftUI Three.js Hono PostgreSQL Redis

Product film

Local integration recording · iOS Simulator, Cattt backend and DeepSeek
Read the video description

The film opens in Tuanzi’s 3D yard. In chat, the user asks Tuanzi to plan a relaxed half day with a walk and some time to draw. Tuanzi acknowledges the request. A worker drafts the plan, saves three checkpoints, and submits a report. The router checks consent and conversation context, then sends a chat message letting the user know a letter is ready. The user returns to the yard and opens the letter to read the plan and its rainy-day alternative.

More demos

Walk to the pond

Ask Tuanzi to wait by the pond. Tuanzi walks there through the yard, and the app reports its arrival to the backend.

Sit with me

An invitation starts a sit-together action. The yard chooses a seat, and the app confirms that Tuanzi has settled beside the pond.

Remember a preference

Ask Tuanzi to remember that turquoise is your favorite color. Open Long-term Memory to see the saved preference and its original message.

The yard, chat and diary

Tuanzi follows its own routines in the yard. The yard is the home screen, chat opens over the scene, and the mailbox leads to the diary. The project includes SwiftUI screens, Three.js scenes and character actions, and a backend for chat, memories, agreements and delegated requests.

Keeping chat and background work separate

The user can keep chatting after asking Tuanzi to work through an idea. A separate Worker process handles that work. The Router stays in the API process with chat, receives the report and decides when and how to respond.

Router · Responses
Uses recent chat, background reports and current permissions to compose and publish replies. The Router also handles follow-ups when agreements become due.
Worker · Execution
Receives memory extraction, diary and delegated tasks through pg-boss. It saves a checkpoint after each tool step and submits a structured report for the Router to respond to.
iOS client
SwiftUI hosts chat, diary and memory controls, with replies received over SSE. The yard and chat share a single 3D world embedded in a WKWebView.
3D world
Three.js handles pathfinding, poses and scene interactions. A two-way bridge carries state, commands and action results.

PostgreSQL stores conversations, memories, agreements and execution records, with Drizzle for data access. Redis Streams temporarily stores response events; conversation locks coordinate concurrent work.

From an invitation to a seat nearby

When the user asks Tuanzi to sit with them, the agent calls a sitting tool. iOS chooses a seat based on the cat’s temperament and the yard state, then the 3D world moves the cat there. Accepted, running and arrived are tracked separately. A reply says Tuanzi has sat down only after an arrival receipt.

Memory with traceable sources

Each long-term memory links to the user’s original words. The model can also search messages outside its current context. Retrieval checks permissions, excluded topics and source status. Withdrawing a source removes related memories and derived content from future conversation context.

Bringing results back into chat

A shared command entry point saves the request and passes it to the Worker. The report and pending Router job are stored in one transaction. Before replying, the Router rereads the conversation and checks cancellations, source permissions and quiet hours. New information sends the work back for reassessment. Once ready to publish, the full result goes to the mailbox and the Router picks up the conversation. Delegated work currently uses existing chat and permitted memories and diary entries.

Resuming after interruption

Redis Streams stores chat events so a disconnected client can resume by event ID; expired events fall back to database results. Background agents save a checkpoint after each step. Leases and recovery scans resume unfinished work within step, time and input/output budgets. The yard saves position and camera snapshots separately.

In development. Images are from recorded iPhone checks; the architecture description is based on the current code.