$ show plausible/analytics
Plausible Analytics is a production-grade, privacy-first web analytics platform implemented as a full-stack SaaS application. The backend is built with Elixir/Phoenix (LiveView, Ecto, Oban) and uses ClickHouse as the primary analytics data store alongside PostgreSQL for transactional metadata. The frontend is a React/TypeScript single-page application with Tailwind CSS, and a separate JavaScript tracker script is distributed via npm and self-hosted CDN. The system handles event ingestion, session management, real-time dashboards, goal/funnel tracking, billing/subscriptions via Paddle, team collaboration, SSO/SAML authentication, data imports from Google Analytics, and a public Plugins API. The codebase is dual-licensed (Community Edition and Enterprise Edition) with conditional compilation for EE features like consolidated views, customer support tools, and audit logging. The architecture is modular with clear contexts (stats, ingestion, billing, teams, auth, shields) and extensive use of Oban workers for background jobs, ConCache for distributed caching, and OpenTelemetry for observability. The repository demonstrates high engineering craftsmanship with comprehensive test coverage (ExUnit, Playwright, k6 load tests), well-structured abstractions (cache behaviour, rate limiter, write buffers, session balancer), and a clear separation of concerns between the Phoenix web layer, LiveView components, and the React dashboard.
The LLM identified 5 files worth highlighting for reuse:
Implements a generic caching behaviour (`Plausible.Cache`) with two refresh modes (`:all` and `:updated_recently`), telemetry instrumentation, and automatic fallback to database queries when caching is disabled. Used by multiple domain-specific caches (tracker script, shield rules, consolidated views, sampling). The pattern is cleanly separated from storage details and can be extracted to any Elixir project needing a partitioned, refreshable cache with DB fallback.
A decentralized rate limiter using ETS tables with per-key counters and configurable limits. Supports multiple rate limiters (site-level, API key-level) with automatic cleanup of stale entries. The implementation is self-contained, uses no external dependencies beyond Erlang/OTP, and can be reused in any Elixir application needing lightweight, in-memory rate limiting without a central store.
A collection of reusable ClickHouse SQL fragment macros for analytics queries: sampling, bounce rate calculation, custom property access, time bucketing, and metric aggregation. These fragments are parameterized and composable, enabling consistent SQL generation across the stats query pipeline. The pattern demonstrates deep ClickHouse expertise and can be adapted for any analytics project using ClickHouse as a backend.
A reusable LiveView component implementing an autocomplete combobox with keyboard navigation, debounced search, and integration with Alpine.js for client-side interactivity. Supports both static and dynamic search backends. The component is self-contained, uses Phoenix LiveView's `render` and `handle_event` patterns, and can be extracted for use in any Phoenix project needing a searchable dropdown.
A generic write buffer for batching inserts into ClickHouse. Accumulates rows in memory and flushes them asynchronously via a GenServer, with configurable batch size and flush interval. Used by both event and session ingestion pipelines. The pattern is isolated from domain logic and can be reused in any Elixir application needing buffered writes to ClickHouse or similar append-only stores.