An open-source AI chat interface for PostHog analytics — query your product data using natural language, powered by the PostHog MCP server and your choice of LLM provider.
Ask questions like "How many unique users visited yesterday?" or "Show me the most common paths to conversion" and get answers backed by real PostHog data, rendered as interactive charts, tables, mermaid diagrams, and HogQL queries.
- Multi-provider AI — OpenAI, Anthropic (Claude), Google (Gemini), and OpenRouter all supported out of the box
- PostHog MCP integration — direct access to insights, events, persons, dashboards, experiments, feature flags, surveys, error tracking, and HogQL via the official PostHog MCP server
- Interactive charts — model outputs are rendered as live
rechartsbar/line/area/pie visualizations - HogQL query support — the model can craft and execute precise HogQL queries against your data
- Mermaid diagrams — funnels, paths, and feature-flag logic rendered visually
- Streaming reasoning — collapsible thinking indicators for models that support reasoning tokens (Claude extended thinking, DeepSeek R1, etc.)
- Per-conversation persistence — chats saved locally in IndexedDB
- Light/dark/system themes — built on shadcn/ui + Tailwind v4
- Bring your own keys — no backend account required. API keys stored locally in your browser
- Framework — Next.js 16 (App Router) + React 19
- AI — Vercel AI SDK v6 with
@ai-sdk/openai,@ai-sdk/anthropic,@ai-sdk/google - MCP —
@modelcontextprotocol/sdktalking to PostHog MCP over Streamable HTTP - UI — shadcn/ui + AI Elements + Tailwind v4
- Charts — recharts
- Markdown — streamdown with code/math/mermaid/cjk plugins
- Storage — IndexedDB for conversations, localStorage for settings
- Node.js 18+
- A PostHog account with a Personal API Key
- An AI provider API key (OpenAI, Anthropic, Google AI Studio, or OpenRouter)
git clone https://github.com/tryrelia/Relia-Analytics.git
cd Relia-Analytics
npm install
npm run devOpen http://localhost:3000.
All configuration happens in-app via the Settings dialog (gear icon in the sidebar). No .env file required.
- AI Provider — pick OpenAI / Anthropic / Google / OpenRouter and paste your API key
- Model — choose from the predefined list or enter a custom model ID
- PostHog MCP API Key — your PostHog personal API key
- PostHog Project ID (optional) — restricts queries to a single project
Settings are persisted in localStorage only — they never leave your browser.
| Provider | Link |
|---|---|
| OpenAI | https://platform.openai.com/api-keys |
| Anthropic | https://console.anthropic.com/settings/keys |
| Google AI Studio | https://aistudio.google.com/app/apikey |
| OpenRouter | https://openrouter.ai/settings/keys |
| PostHog | https://app.posthog.com/settings/user-api-keys |
OpenRouter note: Some free models (like
owl-alpha) require provider logging to be enabled in your privacy settings.
┌──────────────┐ headers ┌────────────────────┐ MCP/HTTP ┌──────────────┐
│ Browser │ ─────────────► │ /api/chat route │ ──────────────► │ PostHog MCP │
│ (useChat) │ │ (AI SDK stream) │ ◄────────────── │ Server │
└──────────────┘ ◄───────────── └────────────────────┘ └──────────────┘
▲ SSE │
│ ▼
│ ┌────────────────────┐
│ │ LLM Provider │
│ │ OpenAI / Anthropic │
│ │ Google / OR │
│ └────────────────────┘
│
InteractiveChart, Reasoning, Mermaid, Task indicators…
- The chat UI sends a message via AI SDK's
useChat, passing API keys as request headers - The Next.js route opens an MCP session against
mcp.posthog.com, lists available tools, and exposes them to the LLM - The LLM calls tools (e.g.
query-run,insights-get-all) — results stream back as part of the response - The response is parsed for
```rechartsJSON blocks (rendered asrechartscharts) and```mermaidblocks (rendered as diagrams) - Reasoning tokens (where supported) stream into a collapsible thinking panel
app/
api/chat/route.ts # AI SDK streaming route + MCP session wiring
[id]/page.tsx # individual conversation page
page.tsx # landing
components/
chat-interface.tsx # core chat UI (useChat, reasoning, tool indicators)
chat-chart.tsx # recharts renderer + recharts/json block parsing
sidebar.tsx # conversation list + settings dialog
ai-elements/ # shadcn-style AI Elements primitives
ui/ # shadcn primitives
lib/
posthog-mcp.ts # MCP client + tool adapter
chat-context.ts # React context for settings + conversations
db.ts # IndexedDB persistence layer
npm run dev # start dev server on 0.0.0.0:3000
npm run build # production build
npm run start # serve production build
npm run lint # eslint- API keys are stored only in
localStorageon your device - Conversations are stored only in IndexedDB on your device
- The Next.js API route is a stateless proxy — it does not log, persist, or forward anything beyond the LLM and MCP calls
- If you self-host, your data flows directly between your browser → your server → the LLM provider + PostHog MCP
A security scan report for this project is available here:
This project currently stores certain client-side data using browser storage mechanisms such as IndexedDB and localStorage.
Because browser storage is accessible from client-side JavaScript, sensitive data may be exposed in the event of XSS (Cross-Site Scripting) vulnerabilities or compromised browser environments.
The current implementation is primarily intended for development, experimentation, and demo usage.
PRs welcome. Please:
- Open an issue first for non-trivial changes
- Follow the existing code style (TypeScript strict, no comments unless the why is non-obvious)
- Test against at least one LLM provider end-to-end
MIT — see LICENSE.
- PostHog for the analytics platform and MCP server
- Vercel AI SDK and AI Elements
- shadcn/ui for the component foundation
- Model Context Protocol for the tool-calling standard