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.