# ltilibrary/ltiadvantagetool architecture

> Architecture diagram of the GitHub repository ltilibrary/ltiadvantagetool, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ltilibrary/ltiadvantagetool
- Repository: https://github.com/ltilibrary/ltiadvantagetool

## Overview

AdvantageTool is a sample ASP.NET Core LTI 1.3 / LTI Advantage tool. An LMS initiates OIDC login, then launches the tool with an id_token; the tool validates the launch and either dispatches deep-link requests or renders a resource-link experience. From there, the tool demonstrates deep-link responses, AGS line-item and score actions, and AGS results plus NRPS membership reads. Platform registration and tool-signed JWT verification are supporting capabilities. README documents several handlers whose source was not sampled, so their internal wiring is shown only where documented.

Main entry points: [`src/AdvantageTool/Pages/Tool.cshtml.cs`](https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Pages/Tool.cshtml.cs) (Launch handler), [`src/AdvantageTool/Pages/Components/LineItems/LineItemsViewComponent.cs`](https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Pages/Components/LineItems/LineItemsViewComponent.cs) (AGS and NRPS viewer), [`src/AdvantageTool/Services/AccessTokenService.cs`](https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Services/AccessTokenService.cs) (Access-token service), [`src/AdvantageTool/Utility/PemHelper.cs`](https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Utility/PemHelper.cs) (PEM key utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Platform setup"]
  node_platform_pages["Platform management"]
  node_platform_input["Platform input model"]
end

subgraph group_launch["Login and launch"]
  node_oidc["OIDC initiation"]
  node_tool["Launch handler<br/>[Tool.cshtml.cs]"]
end

subgraph group_lti["LTI capabilities"]
  node_catalog["Deep-link response<br/>[Catalog.cshtml.cs]"]
  node_lineitems["AGS and NRPS viewer"]
  node_lineitem_model["Line-item view model<br/>[LineItemsModel.cs]"]
end

subgraph group_security["Tokens and keys"]
  node_token_service["Access-token service"]
  node_jwks_endpoint["Tool JWKS endpoint<br/>[Program.cs]"]
  node_jwks_service["JWKS service<br/>[JwksService.cs]"]
  node_pem["PEM key utilities<br/>[PemHelper.cs]"]
end

subgraph group_data["Persistence"]
  node_state_db[("Launch state<br/>[StateDbContext.cs]")]
  node_platform_db[("Platform and identity data")]
end

node_admin(("Tool administrator"))
node_lms["LMS platform"]
node_ags["AGS services"]
node_nrps["NRPS service"]
node_auth_endpoint["Platform authorization"]
node_token_endpoint["Platform token endpoint"]

node_admin -->|"manages platforms"| node_platform_pages
node_platform_pages -->|"builds configuration"| node_platform_input
node_platform_input -->|"generates keys"| node_pem
node_platform_pages -->|"persists platforms"| node_platform_db
node_lms -->|"starts login"| node_oidc
node_oidc -->|"stores state"| node_state_db
node_oidc -->|"redirects login"| node_auth_endpoint
node_lms -->|"posts launch"| node_tool
node_tool -->|"checks nonce"| node_state_db
node_tool -->|"loads platform"| node_platform_db
node_tool -->|"fetches platform JWKS"| node_lms
node_tool -->|"dispatches deep link"| node_catalog
node_catalog -->|"signs response"| node_pem
node_catalog -->|"posts deep link"| node_lms
node_tool -->|"renders LTI data"| node_lineitems
node_lineitems -->|"builds view model"| node_lineitem_model
node_lineitems -->|"requests token"| node_token_service
node_tool -->|"requests token"| node_token_service
node_token_service -->|"loads credentials"| node_platform_db
node_token_service -->|"signs client assertion"| node_pem
node_token_service -->|"exchanges assertion"| node_token_endpoint
node_lineitems -->|"reads line items and results"| node_ags
node_lineitems -->|"reads memberships"| node_nrps
node_tool -->|"manages line items and scores"| node_ags
node_jwks_endpoint -->|"dispatches request"| node_jwks_service
node_jwks_service -->|"loads public key"| node_platform_db
node_jwks_service -->|"converts public key"| node_pem
node_lms -->|"fetches tool JWKS"| node_jwks_endpoint

click node_platform_pages "https://github.com/ltilibrary/ltiadvantagetool/tree/master/src/AdvantageTool/Pages/Platforms"
click node_platform_input "https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Pages/Platforms/PlatformInputModel.cs"
click node_oidc "https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Pages/OidcLogin.cshtml.cs"
click node_tool "https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Pages/Tool.cshtml.cs"
click node_state_db "https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Data/StateDbContext.cs"
click node_catalog "https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Pages/Catalog.cshtml.cs"
click node_lineitems "https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Pages/Components/LineItems/LineItemsViewComponent.cs"
click node_lineitem_model "https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Pages/Components/LineItems/LineItemsModel.cs"
click node_token_service "https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Services/AccessTokenService.cs"
click node_jwks_endpoint "https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Program.cs"
click node_jwks_service "https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Services/JwksService.cs"
click node_pem "https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Utility/PemHelper.cs"
click node_platform_db "https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Data/ApplicationDbContext.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_platform_pages,node_platform_input toneBlue
class node_oidc,node_tool toneAmber
class node_catalog,node_lineitems,node_lineitem_model toneMint
class node_token_service,node_jwks_endpoint,node_jwks_service,node_pem toneRose
class node_state_db,node_platform_db,node_admin,node_lms,node_ags,node_nrps,node_auth_endpoint,node_token_endpoint toneIndigo
```

## Components

### Platform setup

- [Platform management](https://github.com/ltilibrary/ltiadvantagetool/tree/master/src/AdvantageTool/Pages/Platforms): `src/AdvantageTool/Pages/Platforms`
- [Platform input model](https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Pages/Platforms/PlatformInputModel.cs): `src/AdvantageTool/Pages/Platforms/PlatformInputModel.cs`

### Login and launch

- [OIDC initiation](https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Pages/OidcLogin.cshtml.cs): `src/AdvantageTool/Pages/OidcLogin.cshtml.cs`
- [Launch handler](https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Pages/Tool.cshtml.cs): `src/AdvantageTool/Pages/Tool.cshtml.cs`

### LTI capabilities

- [Deep-link response](https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Pages/Catalog.cshtml.cs): `src/AdvantageTool/Pages/Catalog.cshtml.cs`
- [AGS and NRPS viewer](https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Pages/Components/LineItems/LineItemsViewComponent.cs): `src/AdvantageTool/Pages/Components/LineItems/LineItemsViewComponent.cs`
- [Line-item view model](https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Pages/Components/LineItems/LineItemsModel.cs): `src/AdvantageTool/Pages/Components/LineItems/LineItemsModel.cs`

### Tokens and keys

- [Access-token service](https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Services/AccessTokenService.cs): `src/AdvantageTool/Services/AccessTokenService.cs`
- [Tool JWKS endpoint](https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Program.cs): `src/AdvantageTool/Program.cs`
- [JWKS service](https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Services/JwksService.cs): `src/AdvantageTool/Services/JwksService.cs`
- [PEM key utilities](https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Utility/PemHelper.cs): `src/AdvantageTool/Utility/PemHelper.cs`

### Persistence

- [Launch state](https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Data/StateDbContext.cs): `src/AdvantageTool/Data/StateDbContext.cs`
- [Platform and identity data](https://github.com/ltilibrary/ltiadvantagetool/blob/master/src/AdvantageTool/Data/ApplicationDbContext.cs): `src/AdvantageTool/Data/ApplicationDbContext.cs`

### Other components

- **Tool administrator**
- **LMS platform**
- **AGS services**
- **NRPS service**
- **Platform authorization**
- **Platform token endpoint**

## Connections

- Tool administrator → Platform management: manages platforms
- Platform management → Platform input model: builds configuration
- Platform input model → PEM key utilities: generates keys
- Platform management → Platform and identity data: persists platforms
- LMS platform → OIDC initiation: starts login
- OIDC initiation → Launch state: stores state
- OIDC initiation → Platform authorization: redirects login
- LMS platform → Launch handler: posts launch
- Launch handler → Launch state: checks nonce
- Launch handler → Platform and identity data: loads platform
- Launch handler → LMS platform: fetches platform JWKS
- Launch handler → Deep-link response: dispatches deep link
- Deep-link response → PEM key utilities: signs response
- Deep-link response → LMS platform: posts deep link
- Launch handler → AGS and NRPS viewer: renders LTI data
- AGS and NRPS viewer → Line-item view model: builds view model
- AGS and NRPS viewer → Access-token service: requests token
- Launch handler → Access-token service: requests token
- Access-token service → Platform and identity data: loads credentials
- Access-token service → PEM key utilities: signs client assertion
- Access-token service → Platform token endpoint: exchanges assertion
- AGS and NRPS viewer → AGS services: reads line items and results
- AGS and NRPS viewer → NRPS service: reads memberships
- Launch handler → AGS services: manages line items and scores
- Tool JWKS endpoint → JWKS service: dispatches request
- JWKS service → Platform and identity data: loads public key
- JWKS service → PEM key utilities: converts public key
- LMS platform → Tool JWKS endpoint: fetches tool JWKS
