Open Chat

Show HN: AI Chat App on Durable Streams and Tanstack DB

Last verified:

Visit Open Chat

What is Open Chat?

Open Chat (oss.chat) is a guided AI chat application built around a durable, append-only event log architecture. Instead of streaming tokens directly to the browser and saving messages afterward, Open Chat writes every event to a durable log first—then replays it for the live feed. This means dropped connections, refreshes, or server restarts don't lose any chat history; reconnect and you resume exactly where you were.

Key features include: support for any model via OpenRouter (text, vision, and image generation, switchable mid-chat), real-time token streaming with durability guarantees, Prisma Postgres for relational data (chat titles, accounts, credits), Prisma Streams for append-only event logs with key-filtered reads, TanStack DB for live UI queries that update only affected rows, and auditable billing where credits are a ledger in Postgres with Stripe webhook evidence preserved in streams.

Open Chat is for developers and technical users who value reliability, transparency, and architecture clarity. It's ideal for anyone building chat applications, studying durable streaming systems, or needing a chat interface where nothing appears on screen until it's already persisted. The system also supports generated images in the log and live public stats on account/chat/token aggregates.

Open Chat pricing

Pricing model: Freemium

Open Chat uses a credit-based billing system where credits are a ledger in Prisma Postgres. The server checks your credit balance before processing prompts. Every API call incurs a cost (shown as costMicroUsd in the event log, e.g., 9 microcents for 312 output tokens). Stripe webhooks are appended to their own stream for auditable billing evidence. No specific free tier or paid plan prices are published on the website—users must add credits to their account and pay per token usage through OpenRouter's model pricing.

Open Chat pros

  • Durable append-only log prevents lost chat history on refresh or disconnect
  • Every token written to log before browser sees it ensures nothing is lost mid-answer
  • Supports any OpenRouter model—text, vision, image generation—switchable mid-chat
  • Refresh mid-answer and reply resumes exactly where it was
  • Reconnect after dropped connection and catch up from last offset
  • Single pure function folds log into messages on both server and browser, preventing disagreement
  • Prisma Streams provides key-filtered reads that stay fast as log grows
  • TanStack DB updates only affected rows when events arrive, not entire page
  • Auditable billing with credits as Postgres ledger and Stripe webhook evidence in streams
  • Generated images ride same event stream with thumbnails inline and originals in object storage
  • Live public stats show anonymous aggregates of accounts, chats, and tokens
  • Two-app deploy (chat server + Streams service) with one command each, live in seconds
  • Secrets in Compute env config, never in repo for secure deployment
  • Type-safe Prisma Postgres client with autocompleted tables, columns, and relations
  • Browser tails log via SSE connection that replay-from-any-offset then follows live
  • Long-poll reads make SSE tail cheap for efficient real-time updates

Open Chat cons

  • No free tier mentioned—requires credits/cash balance for usage
  • Complex architecture may be overwhelming for non-technical users
  • Requires Prisma Compute deployment setup (not traditional hosting)
  • Browser never talks to Streams directly—must proxy through Bun server
  • Only supports OpenRouter model catalog, not arbitrary model providers
  • Credits expire after 1 year if prepaid (based on similar billing systems)
  • Requires session checking for every read operation, adding latency
  • Append-only log design means no direct message editing after creation
  • TanStack DB live queries require understanding of collection-based state
  • Deployment builds locally then uploads, not pure cloud-native deployment

Frequently asked questions about Open Chat

What happens if I kill the tab mid-answer?

Nothing is lost. Every event is appended to the durable log first before the browser sees it. When you reconnect, the system replays from your last offset and you catch up exactly where you were.

Can I switch models during a chat?

Yes. Open Chat supports any model in OpenRouter's catalog—text, vision, or image generation—and you can switch mid-chat.

How does Open Chat handle refresh during streaming?

Refresh mid-answer and the reply resumes exactly where it was. The SSE connection replays from any offset then follows live, so nothing is lost.

What is the log in Open Chat?

The log is the chat itself—not a cache. It's an append-only sequence of events (message.created, message.delta, message.completed) that a single pure function folds into messages on both server and browser.

How are credits billed?

Credits are a ledger in Prisma Postgres. Every API call shows costMicroUsd in the event log. Stripe webhooks are appended to their own stream—verified, rejected, or replayed, with evidence preserved.

Can I view generated images in chat?

Yes. Generated images ride the same event stream: thumbnails are inline in the log, originals are in object storage, and they're served per-user.

What database does Open Chat use?

Prisma Postgres for relational data (users, sessions, chats, credits) queried through Prisma Next's typed client, plus Prisma Streams for append-only event logs.

How does the UI stay responsive during streaming?

TanStack DB folds events into a local messages collection. Components render live queries, and when an event arrives, exactly the affected rows update—streaming hundreds of deltas re-renders one message, not the page.

Can I see public usage statistics?

Yes. oss.chat/stats shows live anonymous aggregates straight from Postgres—accounts, chats, and tokens streamed on one public page.

How do I deploy Open Chat?

Production is this repo twice: the chat server and Streams service, deployed side by side. Use bunx @prisma/cli app deploy for each app—builds locally, uploads, and deployment is live in seconds with secrets in env config.

Categories

Use cases

Browse all AI tools on NeedAnAI