Skip to content

Components — OL Analytics API

Generated 2026-10-14 15:27 UTC · c4gen dev

The innermost view: the components inside containers that have been expanded to C4 Component level — the major code groupings within a deployable unit and how they collaborate and reach out to adjacent containers and systems.

How to read these diagrams

These are C4 model diagrams (C4-PlantUML). Read them top-down: System Context (the whole SOA) → Container (one system's runtime units) → Dynamic (a single data flow, step by step).

  • People are rounded boxes; systems and containers are rectangles; databases and queues have distinct shapes.
  • Each arrow is a data flow labelled with what moves.
  • Solid arrows are synchronous (request/response, caller blocks).
  • Amber dashed arrows are asynchronous (queued, scheduled, or event-driven — caller does not block).
  • Drag to pan, scroll to zoom. Boxes with a link drill into the next level.

Analytics API (FastAPI)

Root ASGI app mounting the b2b_dashboard tenant at /api/v1/analytics and b2b_learner_records at /api/v1/learner-records. Owns the shared aiomysql StarRocks pool, refreshes its Vault-issued StarRocks credentials at 80% of the lease, and exposes /health/{startup,readiness,liveness}/ plus per-tenant /health/readiness/{tenant}/. Stateless apart from in-process TTL caches (org-manager check 60s, MV freshness, JWKS 1h).

Component Technology Responsibility
b2b_dashboard tenant FastAPI sub-app (/api/v1/analytics) Org and contract aggregates under a k-anonymity floor (default 5), a consent-gated learner-progress view (fails open in QA and Production until a consent field exists), and the MIT-admin contract-health view. Gates every org route on X-Userinfo org membership plus a MITx Online manager check, and contract routes on contract ownership.
b2b_learner_records tenant FastAPI sub-app (/api/v1/learner-records) Identifiable learner, enrollment and course records for partner integrations. Verifies the bearer JWT itself (RS256, issuer, audience, token class, lifetime), requires learner-records:read and the path org in learner_records_organizations, and ignores X-Userinfo.
Shared StarRocks access aiomysql pool + query chokepoint One connection pool for every tenant, schema identifiers validated before splicing, per-statement query_timeout, and the anonymization chokepoint (fetch_and_suppress) that applies each model's CohortPolicy.
Observability & health structlog, OpenTelemetry SDK, sentry-sdk JSON logs with trace/pod fields, one access-log line per request on the root app, OTLP/HTTP trace export, Sentry errors, and tiered K8s probes.