HomeCase studiesSub-Second Executive BI and Operational Analytics Platform...

Case study · Copenhagen, Denmark

Sub-Second Executive BI and Operational Analytics Platform on FastAPI, React, and ClickHouse

Executive BI & Operational Reporting

We architected an executive BI and operational analytics platform powered by Python, FastAPI, React, ClickHouse, and PostgreSQL. Leadership and operations analysts slice multi-dimensional revenue, fulfillment, and cohort metrics in sub-second interactive dashboards backed by a versioned semantic metric registry. Automated Airflow pipelines, columnar ClickHouse rollups, and strict parameterized query builders prevent contradictory KPI definitions and sluggish reporting timeouts.

Industry
Executive BI & Operational Reporting
Solution
React analytics frontend connected to a Python FastAPI semantic query API, PostgreSQL metadata catalog, ClickHouse OLAP store, and Airflow ingestion pipelines.
Platforms
Web & API
Stack
Python · FastAPI · React · TypeScript · ClickHouse · PostgreSQL
Location
Copenhagen, Denmark · delivered remotely
Role
Engineering, with the team behind for mobile and QA

Delivered remotely for a business based in Copenhagen, Denmark. Names withheld by agreement.

Project Overview

Executive reporting loses credibility the moment two business units present conflicting revenue or margin numbers in the same leadership review. From Copenhagen, we engineered a bespoke business analytics dashboard and semantic reporting engine built on Python, FastAPI, React, ClickHouse, and PostgreSQL. The platform unifies operational metrics across finance, fulfillment, and customer retention inside an interactive web workspace backed by one governed definition layer.

Business Bottleneck

Decision-makers previously depended on weekly static slide decks assembled manually from fragmented SQL scripts, spreadsheet pivot tables, and slow legacy BI embeds that routinely timed out whenever analysts filtered by product category and region simultaneously. Worse, subtle variations in how analysts excluded refunds or converted currencies produced mismatched KPI totals across departments. Leadership needed sub-second interactive slicing across large historical datasets without sacrificing metric governance or regional access control.

Architectural Strategy

We decoupled analytical compute from governance metadata and presentation. PostgreSQL manages user identities, regional scope entitlements, saved dashboard layouts, threshold alert rules, and the canonical semantic metric registry. ClickHouse stores denormalized fact tables and pre-aggregated materialized views optimized for high-cardinality grouping and time-series windowing.

FastAPI sits between React and ClickHouse as a strict query compiler: the frontend declares desired metric keys, date ranges, and breakdown dimensions, and FastAPI validates permissions, generates bound parameterized ClickHouse SQL, checks Redis by dataset watermark, and returns compact typed payloads ready for canvas rendering.

Core Capabilities

  • Governed Semantic Metric Catalog: Central versioned definitions for gross margin, net retention, fulfillment lead time, and cohort metrics with inline formula lineage.
  • Cross-Filtered Interactive Canvases: Clicking any bar, cohort cell, or region in React dynamically updates sibling charts, KPI tiles, and drill-through tables.
  • Drill-Down Transaction Inspection: Seamless transition from executive summaries down to underlying order and invoice rows under role-scoped masking.
  • Automated Threshold Alerts: Scheduled anomaly and target evaluations dispatching Slack or email notifications when core operational ratios drift.
  • Multi-Currency Normalization: Historical daily FX rate joins allowing leadership to toggle seamlessly between local reporting currency and consolidated EUR/DKK views.
  • Streaming Governed Exports: Background generation of audited CSV and Excel workbooks stamped with metric version and extraction timestamp.

Technical Architecture

Flow: React Analytics UI -> FastAPI Semantic Compiler -> Redis (Watermark Cache) / PostgreSQL (Metric Registry & ACLs) -> ClickHouse (Columnar OLAP + Materialized Views) <- Apache Airflow (Validated ETL)

Nightly and intra-day Apache Airflow pipelines extract operational tables from billing, ERP, and logistics systems, normalize timestamps and currencies, and write staged batches into ClickHouse. Once automated reconciliation assertions confirm row counts and ledger totals match source systems, Airflow executes an atomic partition exchange and advances the active dataset watermark in PostgreSQL.

When an executive loads a dashboard, React dispatches parallel metric queries to FastAPI. FastAPI resolves each requested metric ID from PostgreSQL, injects mandatory regional row-level filters from the verified session, checks Redis under (watermark, scope_hash, query_fingerprint), and falls back to ClickHouse vectorized queries only on cache misses. Heavy tabular downloads stream asynchronously to signed temporary files so interactive chart responsiveness never stalls.

Technology Stack

Category Technology detail
Semantic Query API Python and FastAPI compiling governed metric specs into parameterized OLAP queries
Interactive Frontend React and TypeScript dashboard canvas with cross-filtering charts and drill-down tables
Analytical Engine ClickHouse columnar OLAP store with materialized rollups for high-cardinality aggregation
Metadata & Governance PostgreSQL storing metric definitions, saved views, alerts, and user access scopes
Result Caching Redis caching deterministic query fingerprints with dataset-version invalidation
Ingestion & ETL Apache Airflow DAGs transforming ERP, CRM, and billing feeds into star schemas
Data Quality Gates Great Expectations / SQL assertion checks blocking corrupted partitions pre-publish
Export Workers Async FastAPI background tasks streaming large CSV/Excel exports without API timeouts

Engineering Trade-offs & Solutions

Challenge Architectural Solution
Eliminating conflicting KPI formulas across departments Browser sends metric keys only; FastAPI compiles queries strictly from a central PostgreSQL semantic registry
Achieving sub-second slicing across multi-year granular events ClickHouse ReplacingMergeTree / SummingMergeTree tables paired with incremental materialized views
Preventing partial or broken ETL loads from reaching executive screens Airflow stage-and-swap partition publishing gated by automated reconciliation checks
Securing regional slices without maintaining separate physical databases Compiler-enforced row-level predicates injected dynamically into every generated ClickHouse query
Invalidating cached chart results accurately after data refreshes Redis keys bound to dataset watermark IDs updated atomically at the end of each Airflow pipeline run

Security & Reliability

Row-level entitlements map each user's organizational role to allowed country, subsidiary, or cost-center identifiers enforced server-side inside FastAPI's query builder—never via client-side hidden filters. Because all ClickHouse queries compile strictly from allow-listed metric and dimension schemas using bound parameters, arbitrary SQL injection is structurally impossible.

Pipeline observability tracks Airflow task durations, data freshness lag, and assertion outcomes, automatically alerting data engineering teams before stale partitions impact morning executive briefings. Every exported workbook and scheduled report records its exact metric definition version, user identity, and dataset watermark so board packets remain reproducible weeks later.

Performance & Scale

ClickHouse's columnar compression and partition pruning by event month ensure date-bounded executive queries scan only relevant blocks, while materialized views pre-roll daily summaries for the most common KPI combinations. On the frontend, React virtualizes wide drill-down grids and coalesces rapid filter clicks using request cancellation (AbortController) so fast exploration stays fluid even over complex multi-metric views.

Heavy export requests never share database worker pools with interactive dashboard tiles; FastAPI offloads multi-thousand-row CSV and Excel serialization to isolated background workers streaming from ClickHouse directly into temporary object storage.

Operational Outcomes

Leadership and finance teams moved away from static weekly slide reconciliation to live, trustworthy self-service analysis grounded in one shared definition of operational truth. Analysts spend far less time defending spreadsheet discrepancies and more time investigating underlying drivers, while regional managers inspect timely performance metrics scoped cleanly to their areas of responsibility. New operational KPIs can now be defined, peer-reviewed, and rolled out across every executive canvas from a single governed catalog.

01 — Questions

asked about this kind of project

Why introduce ClickHouse alongside PostgreSQL instead of running all analytics directly on PostgreSQL?

PostgreSQL handles relational user permissions, dashboard layouts, and metric governance cleanly, whereas ClickHouse's columnar storage and vectorized execution aggregate hundreds of millions of event rows across arbitrary filter combinations in tens of milliseconds.

How do you guarantee two department heads looking at the same metric see identical numbers?

Charts never send raw SQL from the browser. React requests named metric IDs and dimension filters, and FastAPI compiles those against a single versioned semantic registry in PostgreSQL so formulas, currency rules, and exclusion filters stay uniform everywhere.

How are cross-tenant or regional data access boundaries enforced in OLAP queries?

Every FastAPI query compilation step injects mandatory row-level predicate bindings derived from the authenticated user's regional claims before executing against ClickHouse, preventing filter tampering.

How do you prevent malformed upstream ERP exports from breaking executive dashboards overnight?

Apache Airflow loads incoming batches into staging partitions in ClickHouse, runs schema, null-threshold, and reconciliation checks, and swaps partitions atomically only after assertions pass.

How does caching avoid serving stale figures right after an ETL refresh finishes?

Cache keys in Redis incorporate the semantic metric version, normalized filter hash, user scope, and current dataset watermark timestamp. Updating the watermark upon a successful Airflow partition swap invalidates outdated chart caches instantaneously.

03 — Similar project?

describe what is different about yours

Build yours.

Tell me what exists, what you need and the deadline. Fixed price for a defined scope, or $55/day (8–9 hours work) with a written plan first.

Solitaire Corporate Park, Makarba, Ahmedabad, Gujarat 380015, India · IST (UTC+5:30) · --:-- IST · Mon–Fri 09:00–18:00 IST · US & EU overlap daily

No newsletter, no CRM. Just a reply.