# academeio/academe-h5p architecture

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

- Interactive diagram: https://gitdiagram.com/academeio/academe-h5p
- Repository: https://github.com/academeio/academe-h5p

## Overview

1. **What this repo is**
   - This is a **content repository plus lightweight H5P runtime** for medical education.
   - It is not primarily an application with dynamic business logic; most of the “product” is **packaged H5P activities** and the scripts that generate and serve them.

2. **Primary domain boundary: activity packages**
   - The `activities/` tree is the main payload.
   - Each activity folder is a self-contained H5P package with:
     - `h5p.json` for the package manifest
     - `content.json` for activity data
     - `content/` for nested H5P content when needed
   - The folders are organized by subject/topic and by H5P type, for example `*-blanks`, `*-crossword`, `*-summary`, `*-branching`, `*-flashcards`, `*-drag-text`.

3. **Content model and tiering**
   - The repository’s content is intentionally stratified into tiers:
     - **Tier 1**: text-centric activities such as Blanks, Crossword, Flashcards, SortParagraphs, MarkTheWords, Summary
     - **Tier 2**: image-driven activities such as ImageSequencing, ImageJuxtaposition, Timeline, MemoryGame
     - **Tier 3/4**: planned vision-heavy and complex interactive types
   - This tiering is important because it separates **template-based text generation** from **image/interaction generation** and from more complex scenario/video experiences.

4. **Reusable H5P library layer**
   - `libs/` contains the reusable H5P content-type libraries and core UI dependencies.
   - This is the execution substrate for everything in `activities/`: it includes the actual H5P runtimes for content types like Blanks, DragText, Crossword, Flashcards, Summary, InteractiveVideo, BranchingScenario, etc.
   - Many libraries are versioned side by side, which means the repo can preserve compatibility across activity generations.

5. **Core runtime and player boundary**
   - `server/h5p-core/` is a vendored H5P core runtime, not just a thin app dependency.
   - It supplies the player, embedding logic, resizer, xAPI plumbing, library listing, content upgrade support, and styling assets needed to render H5P packages.
   - The runtime boundary is: **activity package in `activities/` + libraries in `libs/` + core player in `server/h5p-core/`**.

6. **Local serving subsystem**
   - `server/server.mjs` is the local application entrypoint that serves activities through the H5P runtime.
   - The README indicates URLs like `/play/{activity-slug}`, so the server exposes per-activity playback routes.
   - This server is the main execution boundary between the static content repository and browser-based consumption.

7. **Preview subsystem**
   - `preview/h5p-host.mjs` is a separate preview host.
   - It likely exists to render or embed packaged H5P content in a lightweight local/preview context without going through the full server path.
   - Architecturally, this is a **preview/testing boundary**, distinct from the main serving path used for production-like playback.

8. **Generation and transformation pipeline**
   - `scripts/` contains automation for producing and reshaping content packages:
     - type selection
     - tier 1 generation
     - applying generated outputs
     - content placement and precis generation
     - embryo sequence and tier-2 batch workflows
   - These scripts are the bridge between **medical source material / competency mapping** and the final `activities/` packages.

9. **Competency-driven content selection**
   - The README states that NMC CBME competencies are mapped to the best H5P type.
   - That means the pipeline has an upstream decision layer: **competency verb → recommended H5P content type → generated activity package**.
   - This is a key architectural boundary because it determines what gets generated before any H5P content is authored.

10. **AI-assisted image/content production**
   - The repo also supports AI-assisted generation, including a custom image pipeline where Gemini produces purpose-built medical diagrams.
   - In architecture terms, this is an external content-generation dependency feeding the package-generation scripts, not the runtime player itself.

11. **Consumption model and LMS integration**
   - The intended downstream consumer is **Canvas LMS**.
   - The README calls out two embedding modes:
     - **iframe embed** for simpler activities
     - **ExternalUrl** for more complex ones
   - So the repo’s output is designed to be consumed as embedded interactive content rather than as a standalone full-stack app.

12. **Documentation and governance**
   - `docs/` contains the repository’s architecture, roadmap, content-type reference, progress reporting, and competency mapping documentation.
   - This is useful for diagramming because it reflects the project’s internal decomposition: content types, competencies, and implementation status are explicitly tracked.

13. **Packaging and deployment wrapper**
   - `Dockerfile`, `.dockerignore`, and the Node-based server imply containerized deployment support.
   - The container boundary wraps the static H5P assets, the runtime server, and the preview/hosting scripts into a reproducible environment.

14. **How data flows through the system**
   - Source medical topics/competencies are mapped by scripts into H5P-specific structures.
   - Generated outputs are written into `activities/`.
   - The H5P runtime in `server/h5p-core/` resolves the required libraries from `libs/` and serves the activity.
   - Browser users access the activity through the H5P player, often embedded into Canvas.

15. **What to show in an architecture diagram**
   - A good diagram should separate:
     - **content sources and generation tooling**
     - **static activity packages**
     - **shared H5P libraries/core runtime**
     - **serving/preview hosts**
     - **external consumers and AI/image services**
   - The dominant architectural pattern here is **generated content packages served by a shared H5P runtime**.

Main entry points: [`libs`](https://github.com/academeio/academe-h5p/tree/main/libs) (Libraries), [`activities`](https://github.com/academeio/academe-h5p/tree/main/activities) (Activities), [`server/server.mjs`](https://github.com/academeio/academe-h5p/blob/main/server/server.mjs) (Server), [`scripts`](https://github.com/academeio/academe-h5p/tree/main/scripts) (Generators)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_content["Content packages"]
  node_activities_root["Activities<br/>package repository"]
  node_tier1_text["Text tier<br/>activity family"]
  node_tier2_image["Image tier<br/>activity family"]
  node_topic_packages["Topic sets<br/>topic bundles"]
  node_activity_manifest["h5p.json<br/>package manifest<br/>[h5p.json]"]
  node_activity_content["content.json<br/>activity data<br/>[content.json]"]
  node_nested_content["Nested content<br/>embedded payload<br/>[content.json]"]
end

subgraph group_runtime["H5P runtime"]
  node_libs_root["Libraries"]
  node_blanks_lib["Blanks<br/>content type<br/>[H5P.Blanks-1.14]"]
  node_dragtext_lib["Drag text<br/>content type<br/>[H5P.DragText-1.10]"]
  node_crossword_lib["Crossword<br/>content type<br/>[H5P.Crossword-0.5]"]
  node_flashcards_lib["Flashcards<br/>content type<br/>[H5P.Flashcards-1.7]"]
  node_summary_lib["Summary<br/>content type<br/>[H5P.Summary-1.10]"]
  node_branching_lib["Branching<br/>scenario type"]
  node_video_lib["Interactive video<br/>media type"]
  node_core_runtime["H5P core<br/>player runtime"]
end

subgraph group_delivery["Serving"]
  node_server_entry["Server<br/>local host<br/>[server.mjs]"]
  node_preview_host["Preview host<br/>[h5p-host.mjs]"]
end

subgraph group_tooling["Generation"]
  node_generation_scripts["Generators<br/>pipeline scripts"]
  node_type_selector["Type select<br/>pipeline stage"]
  node_tier1_generator["Tier 1 gen<br/>pipeline stage"]
  node_tier2_batch["Tier 2 batch<br/>pipeline stage"]
end

subgraph group_docs["Docs"]
  node_docs_arch["Architecture<br/>docs<br/>[02-architecture.md]"]
  node_docs_competency["Competency map<br/>docs"]
end

node_activities_root -->|"contains"| node_tier1_text
node_activities_root -->|"contains"| node_tier2_image
node_activities_root -->|"organized as"| node_topic_packages
node_activity_manifest -->|"describes"| node_activity_content
node_activity_content -.->|"may include"| node_nested_content
node_generation_scripts -->|"routes via"| node_type_selector
node_type_selector -->|"guided by"| node_docs_competency
node_generation_scripts -->|"builds"| node_tier1_generator
node_generation_scripts -->|"builds"| node_tier2_batch
node_tier1_generator -->|"writes"| node_activities_root
node_tier2_batch -->|"writes"| node_activities_root
node_libs_root -->|"includes"| node_blanks_lib
node_libs_root -->|"includes"| node_dragtext_lib
node_libs_root -->|"includes"| node_crossword_lib
node_libs_root -->|"includes"| node_flashcards_lib
node_libs_root -->|"includes"| node_summary_lib
node_libs_root -->|"includes"| node_branching_lib
node_libs_root -->|"includes"| node_video_lib
node_server_entry -->|"uses"| node_core_runtime
node_server_entry -->|"serves"| node_activities_root
node_server_entry -->|"resolves"| node_libs_root
node_preview_host -->|"uses"| node_core_runtime
node_preview_host -->|"loads"| node_activities_root
node_core_runtime -->|"depends on"| node_libs_root
node_docs_arch -.->|"documents"| node_server_entry
node_docs_arch -.->|"documents"| node_generation_scripts

click node_activities_root "https://github.com/academeio/academe-h5p/tree/main/activities"
click node_tier1_text "https://github.com/academeio/academe-h5p/tree/main/activities"
click node_tier2_image "https://github.com/academeio/academe-h5p/tree/main/activities"
click node_topic_packages "https://github.com/academeio/academe-h5p/tree/main/activities"
click node_activity_manifest "https://github.com/academeio/academe-h5p/blob/main/activities/abdominal-cavity-blanks/h5p.json"
click node_activity_content "https://github.com/academeio/academe-h5p/blob/main/activities/abdominal-cavity-blanks/content.json"
click node_nested_content "https://github.com/academeio/academe-h5p/blob/main/activities/abdominal-cavity-blanks/content/content.json"
click node_libs_root "https://github.com/academeio/academe-h5p/tree/main/libs"
click node_blanks_lib "https://github.com/academeio/academe-h5p/blob/main/libs/H5P.Blanks-1.14"
click node_dragtext_lib "https://github.com/academeio/academe-h5p/blob/main/libs/H5P.DragText-1.10"
click node_crossword_lib "https://github.com/academeio/academe-h5p/blob/main/libs/H5P.Crossword-0.5"
click node_flashcards_lib "https://github.com/academeio/academe-h5p/blob/main/libs/H5P.Flashcards-1.7"
click node_summary_lib "https://github.com/academeio/academe-h5p/blob/main/libs/H5P.Summary-1.10"
click node_branching_lib "https://github.com/academeio/academe-h5p/blob/main/libs/H5P.BranchingScenario-1.8"
click node_video_lib "https://github.com/academeio/academe-h5p/blob/main/libs/H5P.InteractiveVideo-1.27"
click node_core_runtime "https://github.com/academeio/academe-h5p/tree/main/server/h5p-core"
click node_server_entry "https://github.com/academeio/academe-h5p/blob/main/server/server.mjs"
click node_preview_host "https://github.com/academeio/academe-h5p/blob/main/preview/h5p-host.mjs"
click node_generation_scripts "https://github.com/academeio/academe-h5p/tree/main/scripts"
click node_type_selector "https://github.com/academeio/academe-h5p/blob/main/scripts/h5p-type-selector.mjs"
click node_tier1_generator "https://github.com/academeio/academe-h5p/blob/main/scripts/h5p-generate-tier1.mjs"
click node_tier2_batch "https://github.com/academeio/academe-h5p/blob/main/scripts/gen-tier2-batch.mjs"
click node_docs_arch "https://github.com/academeio/academe-h5p/blob/main/docs/02-architecture.md"
click node_docs_competency "https://github.com/academeio/academe-h5p/blob/main/docs/05-competency-mapping.md"

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_activities_root,node_tier1_text,node_tier2_image,node_topic_packages,node_activity_manifest,node_activity_content,node_nested_content toneBlue
class node_libs_root,node_blanks_lib,node_dragtext_lib,node_crossword_lib,node_flashcards_lib,node_summary_lib,node_branching_lib,node_video_lib,node_core_runtime toneAmber
class node_server_entry,node_preview_host toneMint
class node_generation_scripts,node_type_selector,node_tier1_generator,node_tier2_batch toneRose
class node_docs_arch,node_docs_competency toneIndigo
```

## Components

### Content packages

Self-contained H5P activities organized by topic and content type

- [Activities](https://github.com/academeio/academe-h5p/tree/main/activities): package repository · Top-level library of generated H5P activity packages · `activities`
- [Text tier](https://github.com/academeio/academe-h5p/tree/main/activities): activity family · Text-centric activities such as blanks, crossword, drag text, mark words, summary, and branching · `activities`
- [Image tier](https://github.com/academeio/academe-h5p/tree/main/activities): activity family · Image-driven and sequencing-style activities used for richer visual interactions · `activities`
- [Topic sets](https://github.com/academeio/academe-h5p/tree/main/activities): topic bundles · Subject-specific activity bundles repeated across anatomy, physiology, biochemistry, and related domains · `activities`
- [h5p.json](https://github.com/academeio/academe-h5p/blob/main/activities/abdominal-cavity-blanks/h5p.json): package manifest · Per-activity H5P manifest defining package metadata and dependencies · `activities/abdominal-cavity-blanks/h5p.json`
- [content.json](https://github.com/academeio/academe-h5p/blob/main/activities/abdominal-cavity-blanks/content.json): activity data · Per-activity content model and authored exercise data · `activities/abdominal-cavity-blanks/content.json`
- [Nested content](https://github.com/academeio/academe-h5p/blob/main/activities/abdominal-cavity-blanks/content/content.json): embedded payload · Inner content.json used by package-internal content trees when needed · `activities/abdominal-cavity-blanks/content/content.json`

### H5P runtime

Reusable libraries and vendored core player assets

- [Libraries](https://github.com/academeio/academe-h5p/tree/main/libs): H5P libraries · Shared content-type libraries and UI dependencies used by all activities · `libs`
- [Blanks](https://github.com/academeio/academe-h5p/blob/main/libs/H5P.Blanks-1.14): content type · Cloze-style text gap interaction runtime · `libs/H5P.Blanks-1.14`
- [Drag text](https://github.com/academeio/academe-h5p/blob/main/libs/H5P.DragText-1.10): content type · Text drag-and-drop interaction runtime · `libs/H5P.DragText-1.10`
- [Crossword](https://github.com/academeio/academe-h5p/blob/main/libs/H5P.Crossword-0.5): content type · Crossword interaction runtime · `libs/H5P.Crossword-0.5`
- [Flashcards](https://github.com/academeio/academe-h5p/blob/main/libs/H5P.Flashcards-1.7): content type · Flashcard interaction runtime · `libs/H5P.Flashcards-1.7`
- [Summary](https://github.com/academeio/academe-h5p/blob/main/libs/H5P.Summary-1.10): content type · Summary/question-set style runtime for text comprehension · `libs/H5P.Summary-1.10`
- [Branching](https://github.com/academeio/academe-h5p/blob/main/libs/H5P.BranchingScenario-1.8): scenario type · Branching scenario / decision-tree runtime for guided cases · `libs/H5P.BranchingScenario-1.8`
- [Interactive video](https://github.com/academeio/academe-h5p/blob/main/libs/H5P.InteractiveVideo-1.27): media type · Interactive video runtime for complex, timed interactions · `libs/H5P.InteractiveVideo-1.27`
- [H5P core](https://github.com/academeio/academe-h5p/tree/main/server/h5p-core): player runtime · Vendored H5P core player, embedding, resizer, xAPI, and upgrade support · `server/h5p-core`

### Serving

Local playback and preview hosts

- [Server](https://github.com/academeio/academe-h5p/blob/main/server/server.mjs): local host · Main Node-based application entrypoint that serves activities through the H5P runtime · `server/server.mjs`
- [Preview host](https://github.com/academeio/academe-h5p/blob/main/preview/h5p-host.mjs): preview host · Lightweight preview boundary for rendering and embedding packaged H5P content · `preview/h5p-host.mjs`

### Generation

Scripts that map source material into packaged activities

- [Generators](https://github.com/academeio/academe-h5p/tree/main/scripts): pipeline scripts · Content-generation and transformation scripts for building activity packages · `scripts`
- [Type select](https://github.com/academeio/academe-h5p/blob/main/scripts/h5p-type-selector.mjs): pipeline stage · Chooses the best H5P activity type for a competency or source item · `scripts/h5p-type-selector.mjs`
- [Tier 1 gen](https://github.com/academeio/academe-h5p/blob/main/scripts/h5p-generate-tier1.mjs): pipeline stage · Generates text-centric activity packages from source material · `scripts/h5p-generate-tier1.mjs`
- [Tier 2 batch](https://github.com/academeio/academe-h5p/blob/main/scripts/gen-tier2-batch.mjs): pipeline stage · Batch workflow for image-driven or more complex activity generation · `scripts/gen-tier2-batch.mjs`

### Docs

Architecture and content-type reference material

- [Architecture](https://github.com/academeio/academe-h5p/blob/main/docs/02-architecture.md): docs · Repository architecture overview and implementation boundaries · `docs/02-architecture.md`
- [Competency map](https://github.com/academeio/academe-h5p/blob/main/docs/05-competency-mapping.md): docs · Mapping from competencies to recommended H5P content types · `docs/05-competency-mapping.md`

## Connections

- Activities → Text tier: contains · Most packages are text-first activities
- Activities → Image tier: contains · Some packages are image-driven or more visual
- Activities → Topic sets: organized as · Packages are grouped by medical topic and learning goal
- h5p.json → content.json: describes · Manifest binds package metadata to authored content
- content.json → Nested content: may include · Some activities embed nested package content
- Generators → Type select: routes via · Scripts first choose the most suitable activity type
- Type select → Competency map: guided by · Competency mapping informs content-type selection
- Generators → Tier 1 gen: builds · Tier 1 scripts generate text-centric packages
- Generators → Tier 2 batch: builds · Batch scripts handle the richer visual/complex tiers
- Tier 1 gen → Activities: writes · Generated outputs are placed into the activities tree
- Tier 2 batch → Activities: writes · Batch workflows also materialize packages into activities
- Libraries → Blanks: includes · Shared runtime library for blanks activities
- Libraries → Drag text: includes · Shared runtime library for drag-text activities
- Libraries → Crossword: includes · Shared runtime library for crossword activities
- Libraries → Flashcards: includes · Shared runtime library for flashcard activities
- Libraries → Summary: includes · Shared runtime library for summary activities
- Libraries → Branching: includes · Shared runtime library for branching scenarios
- Libraries → Interactive video: includes · Shared runtime library for interactive video
- Server → H5P core: uses · Server delegates player and embed behavior to the H5P core runtime
- Server → Activities: serves · Playback routes expose packaged activities
- Server → Libraries: resolves · Server loads the activity libraries needed for rendering
- Preview host → H5P core: uses · Preview host renders content through the same core player boundary
- Preview host → Activities: loads · Preview host consumes packaged activities directly
- H5P core → Libraries: depends on · Player resolves content-type libraries and UI dependencies
- Architecture → Server: documents · Architecture docs explain the serving boundary
- Architecture → Generators: documents · Architecture docs explain the generation pipeline
