← Back to Projects
Production · Internal

Multi-Tenant Analytics Platform

Enterprise backend powering data analytics, async workflow orchestration, and multi-database querying with database-per-tenant isolation and Keycloak OAuth2 security.

PythonFastAPIPostgreSQLKeycloakMulti-TenancyHatchetDockerOpenTelemetry

What it does

A core backend platform that serves as the data and analytics engine for an enterprise product — handling dynamic query execution, pivot/cube analysis, async workflow orchestration, and multi-tenant data isolation across hundreds of organizations.

Architecture highlights

  • FastAPI backend with Gunicorn + Uvicorn workers for production serving
  • Multi-tenancy via database-per-tenant model — tenant context resolved from request headers, routed to isolated PostgreSQL instances
  • Dynamic query execution engine with configuration-driven SQL generation and stored procedure invocation
  • Pivot/cube data analysis service with session management and pagination
  • Async workflow orchestration using Hatchet SDK for long-running data pipelines and ETL jobs
  • Multi-database support: PostgreSQL (primary), SQL Server, Oracle, DB2 via unified data source abstraction
  • Keycloak OAuth2/OIDC integration with JWT validation, token introspection, and refresh token rotation
  • Financial data integration pulling market data from external APIs
  • Binary caching layer for analytical query results

Backend patterns

  • Clean layered architecture: Routes → Services → Repositories → Data Sources
  • Constructor-based dependency injection via Injector library
  • Repository pattern abstracting data access across multiple database engines
  • Connection pooling with async PostgreSQL driver (asyncpg)
  • Server-Sent Events for real-time streaming responses
  • Rate limiting, CORS protection, Brotli compression middleware
  • OpenTelemetry distributed tracing for observability
  • Docker Compose stack: API + Worker + PostgreSQL with shared volumes