Data flow
1. Capture in Moodle
Section titled “1. Capture in Moodle”The local_ssea plugin tracks activity (JS + PHP observers) and runs sync tasks (users, courses, enrollments, grades). Payloads are sent to the ingest worker with tenant credentials.
2. Ingest and queue
Section titled “2. Ingest and queue”ssea-ingest validates the tenant and enqueues messages. ssea-processor consumes the queue, deduplicates, and upserts into D1 (events, dimensions, light aggregates).
3. OLTP in D1
Section titled “3. OLTP in D1”D1 holds the relational model: events, users, courses, enrollments, grades, alerts, etc. Every API query is scoped by tenant_id and, depending on role, by moodle_user_id or teacher course_ids from the JWT (typically derived from teaching enrollments in D1).
4. Async reports
Section titled “4. Async reports”A scheduled job enqueues report types (retention_cohort, activity_funnel, …). The worker writes JSON/CSV rows to R2 and publishes a KV snapshot (snap:v1:{tenant}:{type}) for fast reads.
5. Consumption
Section titled “5. Consumption”- Dashboard:
GET .../reports/:type/latest(KV → R2 fallback), exports role-gated. - Plugin: embedded views calling the same API with scoped JWTs.