Skip to main content

Overview

:::info Source Sourced from services/delivery-service/SERVICE_OVERVIEW.md in the documentation repo. :::

Companion: 03 delivery-service · 02 DDD · 11 LMS Runtime Player · 13 Security

1. Purpose

The delivery-service is the runtime learner experience engine for the Ghasi-edTech platform. It owns the full lifecycle of PlaySession aggregates — from start through navigation, AI tutor interaction, offline mount/unmount, pause, completion, and abandonment. It is the server-side counterpart of the LMS runtime player defined in doc 11.

2. Bounded Context

Delivery — classified as Core (competitive differentiator). The Delivery context is where the platform's offline-first, AI-first promise materializes for learners. It consumes PlayPackage projections from Content-Packaging, validates enrollment eligibility, orchestrates the AI tutor, and manages the offline bundle lifecycle.

3. Responsibilities

AreaWhat Delivery Owns
PlaySession lifecycleStart, resume, navigate, pause, complete, abandon transitions on the PlaySession state machine
NavigationCursor management through module/lesson/block trees; branch-path decisions (quiz-gated advancement delegated to assessment-service)
AI Tutor orchestrationStreaming SSE-based AI tutor interactions scoped to the current lesson context; RAG over course content
Offline mount/unmountLicense envelope validation, device binding checks, bundle integrity verification, mount/unmount lifecycle
Session telemetryEmitting navigation and session lifecycle events consumed by progress-service
SCORM 2004 runtimeRuntime adapter for SCORM 2004 sequencing (S4 slice)

4. Non-Responsibilities

AreaOwnerWhy Not Delivery
Statement storage (LRS)progress-serviceDelivery emits intents; Progress is the authoritative record store
Quiz scoringassessment-serviceDelivery delegates quiz presentation and scoring; it only receives pass/fail gates
PlayPackage buildingcontent-serviceContent-Packaging owns the manifest and bundle creation pipeline
Enrollment eligibilityenrollment-serviceDelivery checks enrollment status but does not own enrollment records
Certificate issuancecertification-serviceTriggered downstream from progress completion events
AI model managementai-gateway-serviceDelivery calls the AIClient port; model selection and routing are gateway concerns

5. Dependencies

5.1 Upstream Dependencies

DependencyPatternPurpose
content-servicePL (Published Language)Consumes content.play_package.built.v1 and content.play_package.bundle.published.v1 for PlayPackage manifests and bundles
enrollment-serviceCS (Customer/Supplier)Validates enrollment eligibility before session start; consumes enrollment.created.v1
assessment-serviceCSDelegates quiz serving and scoring; consumes assessment.attempt_result.scored.v1 for gated navigation
ai-gateway-serviceOHS (Open Host Service)AI tutor inference — cloud for online, local model for offline
identity-serviceCF (Conformist)JWT validation and device binding verification

5.2 Downstream Consumers

ConsumerPatternWhat They Consume
progress-serviceCSConsumes delivery.play_session.started.v1, .completed.v1, .navigated.v1 to open attempts and record progress
analytics-serviceEvent consumerConsumes all delivery events for learning analytics dashboards
sync-serviceEvent consumerConsumes offline mount/unmount events for sync registration
notification-serviceEvent consumerConsumes session abandonment events for re-engagement notifications

5.3 Events Consumed by Delivery

EventProducerPurpose
content.play_package.built.v1content-serviceCache the PlayPackage manifest for runtime navigation
enrollment.created.v1enrollment-serviceAllow session creation for newly enrolled learners
content.play_package.bundle.published.v1content-serviceMark bundles available for offline mount
content.bundle.tamper_detected.v1content-serviceForce-unmount tampered bundles; invalidate sessions

6. Slice Involvement

SliceScopeMilestone
S1 — Player MVP + AI tutor + offlinePlaySession CRUD, basic navigation, AI tutor (SSE streaming), offline mount/unmount, bundle validationM1
S4 — SCORM 2004 runtimeSCORM 2004 sequencing adapter, runtime data model mapping, SCO launch and communicationM3
S5 — Enhanced navigationBranching paths, prerequisite-gated lessons, adaptive sequencing, bookmarksM3

7. Architectural Freeze Points

FreezeWhat Is FrozenFrozen By
F15PlayPackage manifest schema — the contract between content-service and delivery-service defining the structure of course runtime dataEnd of M1
F01EventEnvelope schema — all events conform to the envelope in 04 Event-DrivenEnd of M0

After freeze, changes require architectural review and a new version with dual-publish window.

8. Service Readiness Levels

LevelDescriptionTarget Milestone
L3PlaySession lifecycle operational, AI tutor streaming, offline mount/unmount, contract tests, basic SLO trackingM1
L4SCORM 2004 runtime, enhanced navigation, chaos-tested, full observability, production-gradeM3

9. Architecture Diagram

┌───────────────────────────────────────────────┐
│ API Gateway / Edge │
└──────────────────┬────────────────────────────┘

┌──────────────────▼────────────────────────────┐
│ delivery-service (NestJS) │
│ │
│ ┌──────────┐ ┌──────────┐ ┌────────────┐ │
│ │PlaySess │ │ AI Tutor │ │ Offline │ │
│ │ Module │ │ Module │ │ Module │ │
│ └────┬─────┘ └────┬─────┘ └─────┬──────┘ │
│ │ │ │ │
│ ┌────▼─────────────▼──────────────▼──────┐ │
│ │ Domain Layer (pure TS) │ │
│ │ PlaySession · NavigationCursor │ │
│ │ AssistantTurn · OfflineMount │ │
│ └────────────────┬───────────────────────┘ │
│ │ │
│ ┌────────────────▼───────────────────────┐ │
│ │ Infrastructure Layer │ │
│ │ Postgres (RLS) · NATS · Redis │ │
│ │ AIClient · EnrollmentClient · SSE │ │
│ │ ContentClient · OutboxRelay │ │
│ └────────────────────────────────────────┘ │
└──────────────────────────────────────────────┘

┌──────────────────────────┼──────────────────────────┐
│ │ │
┌──────▼──────┐ ┌───────▼───────┐ ┌──────▼──────┐
│ content- │ │ ai-gateway- │ │ enrollment- │
│ service │ │ service │ │ service │
└─────────────┘ └───────────────┘ └─────────────┘

10. Key Design Decisions

DecisionRationale
SSE for AI tutor (not WebSocket)Simpler, unidirectional streaming; aligns with platform API surface conventions; works through CDN/proxies without upgrade negotiation
PlaySession as aggregate rootAll navigation, tutor interactions, and offline mounts are clustered under session; provides a single consistency boundary for concurrent operations
Event-driven progress reportingDelivery does not write to progress-service directly; emits events consumed asynchronously. This decouples the runtime path from LRS write latency
License envelope validation on mountPrevents unauthorized offline access; device binding ensures content cannot be sideloaded to unregistered devices
Local AI inference for offlineLearners in offline mode get AI tutor via on-device model; this fulfills the "AI-first even offline" platform promise