Back to Portfolio
2023Featured

SaaS Analytics Platform

A multi-tenant analytics platform processing billions of events per month, giving SaaS companies real-time product usage insights, funnel analysis, and retention cohorts at enterprise scale.

Next.jsPythonRedisKubernetes

Challenge

A B2B SaaS company had outgrown Mixpanel. Their product had grown to 600+ customers, generating over 4 billion events per month, and the off-the-shelf analytics tools they relied on were too slow, too expensive at scale, and unable to model the customer-specific dimensions their sales and success teams needed. They wanted to own their analytics stack — not to save money on tooling, but to make it a competitive moat.

The ask was a self-hosted, multi-tenant platform that could ingest events in real time, power live dashboards for their internal teams, and expose a white-labelled analytics view for their own customers.

Solution

We designed a streaming ingest pipeline backed by a columnar query engine, all deployed on Kubernetes so the team could scale individual components independently. The frontend was a Next.js application with a server-side rendering strategy that balanced dashboard interactivity with fast initial load times — important given that some dashboards queried across billions of rows.

The architecture was designed for observability from the start: every component emitted structured logs and metrics, and the client's SRE team was included in design reviews so the system was operable from day one.

Technical Approach

Events were ingested via a Python FastAPI service, validated, enriched with server-side properties, and written to Apache Kafka. A Python consumer fleet read from Kafka and wrote to ClickHouse — a columnar OLAP database that executes aggregation queries across billions of rows in under two seconds.

The query layer was a Python GraphQL API. Complex queries — retention cohorts, multi-step funnels, property breakdowns — were compiled to ClickHouse SQL at query time. Query results were cached aggressively in Redis with cache invalidation tied to ingest batches, so dashboards felt instant for common queries.

The frontend was Next.js with React Query for data fetching. Charts were built on Recharts with custom renderers for large datasets. The multi-tenancy model gave each customer an isolated data namespace in ClickHouse, enforced at the query layer, with a per-tenant feature flag system controlling access to dashboard modules.

The whole stack ran on Kubernetes (EKS), with Helm charts for each service. Horizontal pod autoscaling handled ingest spikes. We used Argo CD for GitOps-based deployments, meaning every environment — staging, production — was declared in version-controlled Helm values.

Results

  • 4.2 billion events processed per month at steady state, with ingest latency under 800ms P99
  • Dashboard query response time under 1.8 seconds for P95 across all dashboard types, including retention cohorts
  • Infrastructure cost 60% lower than equivalent Mixpanel enterprise tier at the same event volume
  • White-labelled analytics shipped to 340 of their customers within four months of platform launch, becoming a cited differentiator in sales calls
  • Zero data incidents in the first 12 months of production operation
  • The client's engineering team scaled the platform from 600 to 1,400 customers without architectural changes

Want results like these?

Tell us about your project and we'll be in touch within 24 hours.