How kaiofelps/lti-consumer-poc works
Purpose and Runtime
A TypeScript/NestJS server-side PoC acting as an LTI 1.3 platform (consumer): it registers and deploys learning tools such as Moodle, receives LTI launches, exposes resource links and emerging Assignment & Grade Services (AGS), and also operates an OIDC authorization provider. It renders EJS MVC pages rather than a separate frontend. Startup composition is at src/main.ts, src/app.module.ts, and route registration at src/routes.ts.
Application Composition and Cross-Cutting Boundary
Nest modules organize domain use cases; controllers accept HTTP/MVC requests, DTO validation and global guards/interceptors normalize them, and exception adapters convert domain, LTI-library, OIDC, and validation failures into HTTP/rendered responses. Core infrastructure is concentrated in src/lib/globals/exception-filters.module.ts, src/lib/core-validation/interceptor.ts, and src/lib/exceptions/ltilib/exception-filter.ts. Portuguese-Brazil localization is provided through src/message-string/message-string.module.ts.
Identity, Session Authentication, and OIDC
The identity/auth domains manage people, users, password authentication, and browser sessions. OIDC is a first-class authorization-server integration with provider construction, persisted clients/accounts, login, and consent views. Main boundaries: src/modules/auth/auth.module.ts, src/modules/oidc/provider.factory.ts, and src/modules/oidc/oidc.controller.ts. LTI tools authenticate separately using JWT-based protected-route strategies in src/modules/auth/protected-routes/strategies/lti-tools-jwt.strategy.ts.
LTI Platform Integration
src/modules/lti/lti.module.ts adapts generic protocol logic into Nest controllers and application persistence. Tool registration/configuration and deployment establish which external tools can operate in which contexts: src/modules/lti/tools/tools.controller.ts, src/modules/lti/deployments/deployments.controller.ts, and src/modules/lti/platform.factory.ts. Dynamic registration and security protocol primitives live in the independently packaged workspace ltilib/src/registration/dynamic/tool-configuration.ts and ltilib/src/security/validate-authentication-request.ts.
Launch and Resource-Link Flow
An LMS/tool launch enters LTI launch endpoints, is prepared and security-validated, then launch state is persisted for later resource-link operations. The Nest adapter is src/modules/lti/launches/launches.controller.ts; protocol orchestration is ltilib/src/core/services/launch/initiate-launch.service.ts; transient launch storage maps to Redis via src/external/data-store/redis/repositories/lti-launches.repository.ts. Resource links are then created, queried, or deleted through src/modules/lti/resource-links/resource-links.controller.ts.
Courses, Assignments, and AGS
The application owns courses/enrollments and native assignments/grades, with controllers driving domain services and repository interfaces: src/modules/courses-and-enrollments/courses.module.ts, src/modules/assignments-and-grades/assignments-and-grades.module.ts, and src/modules/assignments-and-grades/services/grade-an-assignment.service.ts. LTI AGS maps external tool assignments and line items into those contexts through src/modules/lti/ags/controllers/lti-line-items.controller.ts and library AGS services in ltilib/src/assignment-and-grade/services/line-item/create-line-item.service.ts.
Persistence and External Dependencies
PostgreSQL is the durable system of record, modeled in drizzle/schema.ts, migrated under drizzle/, and accessed through Drizzle repository implementations such as src/external/data-store/drizzle/repositories/lti-tools.repository.ts. Redis supports transient LTI launch/OIDC state via src/external/data-store/redis/client.ts. Password hashing is delegated to the Argon Rust integration (src/external/argon-rs/argon-rs.module.ts); JOSE/JWT handling supports LTI and OIDC cryptography. Local orchestration and required services are defined in compose.yaml.
Main entry points: lti.module.ts LTI Nest adapter · main.ts Startup & routes · schema.ts PostgreSQL · lti-launches.repository.ts Redis launch state
Components 21
Nest application
- Startup & routes · Composes modules and registers application routes.
src/main.ts - Validation & exceptions · Normalizes requests and converts failures into HTTP or rendered responses.
src/lib/globals/exception-filters.module.ts - pt-BR messages
src/message-string/message-string.module.ts
Identity & OIDC
- Auth & sessions · Manages people, users, passwords, and browser sessions.
src/modules/auth/auth.module.ts - OIDC provider · Serves persisted clients/accounts plus login and consent flows.
src/modules/oidc/provider.factory.ts - Tool JWT protection
src/modules/auth/protected-routes/strategies/lti-tools-jwt.strategy.ts
LTI platform
- LTI Nest adapter · Adapts LTI protocol capabilities to Nest controllers and persistence.
src/modules/lti/lti.module.ts - Tool registration · Registers and configures external learning tools.
src/modules/lti/tools/tools.controller.ts - Tool deployments · Associates tools with operating contexts.
src/modules/lti/deployments/deployments.controller.ts - Launch endpoints
src/modules/lti/launches/launches.controller.ts - LTI protocol library · Provides dynamic registration, security, and launch orchestration.
ltilib/src/core/services/launch/initiate-launch.service.ts - Resource links · Creates, queries, and deletes launch-linked resources.
src/modules/lti/resource-links/resource-links.controller.ts
Learning & AGS
- Courses & enrollments · Owns course and enrollment contexts.
src/modules/courses-and-enrollments/courses.module.ts - Assignments & grades · Owns native assignments and grading use cases.
src/modules/assignments-and-grades/assignments-and-grades.module.ts - AGS line items · Maps external tool assignments and line items into platform contexts.
src/modules/lti/ags/controllers/lti-line-items.controller.ts - AGS service library
ltilib/src/assignment-and-grade/services/line-item/create-line-item.service.ts
Persistence & dependencies
- PostgreSQL · System of record for application and LTI entities.
drizzle/schema.ts - Drizzle repositories
src/external/data-store/drizzle/repositories/lti-tools.repository.ts - Redis launch state · Stores transient LTI launch and OIDC state.
src/external/data-store/redis/repositories/lti-launches.repository.ts - Argon password hashing
src/external/argon-rs/argon-rs.module.ts - Local service orchestration · Defines required local infrastructure services.
compose.yaml
Connections 27
- Startup & routes → Validation & exceptions: installs
- Startup & routes → Auth & sessions: composes
- Startup & routes → LTI Nest adapter: composes
- Startup & routes → Courses & enrollments: composes
- Startup & routes → Assignments & grades: composes
- Validation & exceptions → pt-BR messages: localizes responses
- Auth & sessions → Argon password hashing: hashes passwords
- Auth & sessions → OIDC provider: accounts and sessions
- OIDC provider → Redis launch state: transient state
- LTI Nest adapter → Tool registration: exposes
- LTI Nest adapter → Tool deployments: exposes
- LTI Nest adapter → Launch endpoints: exposes
- LTI Nest adapter → Resource links: exposes
- Tool registration → LTI protocol library: registration
- Tool deployments → Drizzle repositories: persists
- Launch endpoints → LTI protocol library: initiates
- LTI protocol library → Redis launch state: stores launch state
- Tool JWT protection → LTI Nest adapter: protects routes
- Resource links → Redis launch state: uses launch state
- AGS line items → AGS service library: delegates line items
- AGS line items → Courses & enrollments: maps contexts
- AGS line items → Assignments & grades: maps assignments
- Assignments & grades → PostgreSQL: persists
- Courses & enrollments → PostgreSQL: persists
- Drizzle repositories → PostgreSQL: accesses
- Local service orchestration → PostgreSQL: runs
- Local service orchestration → Redis launch state: runs