motherduck-build-cfa-app

Designs MotherDuck-backed customer-facing analytics architectures with per-customer isolation and read scaling.

Updated Oct 15, 2019
One-click install
npx skills add https://github.com/kkkaoru/dotfiles --skill motherduck-build-cfa-app-kkkaoru
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: motherduck-build-cfa-app
Source: https://github.com/kkkaoru/dotfiles/tree/main/.agents/skills-stroage/motherduck-build-cfa-app
Command: npx skills add https://github.com/kkkaoru/dotfiles --skill motherduck-build-cfa-app-kkkaoru

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires duckdb, and includes references (resource) components.

What problem does it solve? Building embedded analytics for external customers requires strict per-tenant data isolation, sub-second query latency, and high read concurrency, and choosing the wrong serving architecture can leak data across tenants or collapse under load. ## Core Features & Use Cases - Serving Architecture Selection: Chooses between a 3-tier app (browser to backend API to MotherDuck), embedded Dives, or DuckDB-Wasm based on isolation, latency, and security requirements. - Isolation and Connection Design: Defines per-customer databases, service-account boundaries, Read Scaling versus Read/Write token usage, and PG endpoint versus native DuckDB connection paths. - Runnable Routing Artifacts: Ships Python and TypeScript examples demonstrating per-customer database routing that can be validated against temporary MotherDuck databases. - Use Case: A SaaS team embedding dashboards into their product uses this Skill to produce an API contract, tenant isolation model, and rollout plan where each customer queries only their own MotherDuck database through a backend-held token. ## Quick Start Ask the assistant to design a customer-facing analytics architecture on MotherDuck for your product, specifying your expected tenant count and concurrency.

Frequently Asked Questions about motherduck-build-cfa-app

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build customer-facing analytics on MotherDuck?

Use a 3-tier architecture where the browser talks to your backend API and the backend queries per-customer MotherDuck databases. The backend authenticates each request, routes it to the correct customer database, and keeps all tokens server-side.

Should I use one database per customer or tenant_id filtering for multi-tenant analytics?

Use one database per customer for customer-facing analytics because isolation is structural and cannot be bypassed by a query bug. A shared database with tenant_id filtering risks cross-tenant data leakage from a single missing WHERE clause.

When should I use Read Scaling tokens versus Read/Write tokens in MotherDuck?

Use Read Scaling tokens for concurrent read-heavy CFA query endpoints, since they distribute load across replicas starting at a default pool of 4. Reserve Read/Write tokens for data ingestion, schema changes, and other writer workflows.

Can I use DuckDB-Wasm for browser-based customer analytics?

DuckDB-Wasm suits only small read-only workloads under 1GB per user where token exposure in the browser is acceptable. For production CFA with sensitive data, use the 3-tier pattern so tokens stay on the server.

Why do read replicas show stale data after a write in MotherDuck?

Read Scaling replicas are eventually consistent and sync from the primary with some delay. Run CREATE SNAPSHOT on the writer connection and REFRESH DATABASE on the reader when strict consistency is required after a load.