Personalized Cohort Learning

Build a cohort-based learning system using Resources API, Library API, and Outline API. There are two user roles: Instructor (designs a course / library) and Learner (requests a personalized learning path from that library).

End to end diagram flow
Instructor
   |
   |--(1) Uses Resources API → searches web +/or uploads own resources → receives streamed “resources + key topics”
   |        ↓
   |--(2) Creates a Library / Adds resources to it / Manages resources
   |        ↓
Learner (or Instructor preview)
   |
   |--(3) Learner supplies input (what they want to learn, how, in how much time, what format, etc.) + optional key topics
   |        ↓
   |--(4) Uses Outline API to generate a personalized outline (streamed SSE)
   |        ↓
   |--(5) Learner follows modules / lessons drawn from selected resources in the library
API
Purpose
Key Parameters
Response Type

Resources (GET /get_resource)

Search the web for resources based on input + optionally add custom resource links. Streams SSE events: start, web_search (with create_resource & key_topic actions), resource_done, complete. (docs.compasai.com)

input_str (string, required), content (list of custom resource URLs, optional), strict (boolean, optional) (docs.compasai.com)

SSE stream of incremental resource + topic info (docs.compasai.com)

Library

Create/fetch/delete a library; add/delete resources; update resources in library. Holds resource objects (with topics etc.). (docs.compasai.com)

For creating: name (required), tag (optional), description (opt) (docs.compasai.com); For adding resources: resource data including resource metadata + topics etc. (docs.compasai.com)

JSON confirming success / returning library with resources etc. (docs.compasai.com)

Outline (POST /get_outline or SSE /create_outline)

Generate a personalized outline for a learner based on library + learner’s input + optional key topics. Streams SSE: start, outline (with actions like create_section, create_module, create_lesson), complete. (docs.compasai.com)

input_str (string, required), library_id (int, required), key_topics (optional list), strict (boolean, optional) (docs.compasai.com)

SSE stream of outline sections/modules/lessons (docs.compasai.com)

Step-by-Step Implementation (TypeScript + Browser Fallback + UI/UX)

Here is a concrete tutorial for building the feature in a web app.


1. Instructor: Search / Add Resources via Resources API

UI Sketch / UX Suggestions

  • A form where the instructor enters:

    What they want to teach (topic / proficiency / material types / hours)

  • Optionally: a field to paste custom resource links / upload content.

  • A “Search + Process” button.

  • Show a loading / streaming state: as results come in, display resources and extracted key topics incrementally so instructor can preview and accept or remove.

Browser Fallback / Proxy Because the standard EventSource in browsers does not allow setting custom authorization headers, you’ll need a fallback:

  • Either proxy the SSE request via your backend, which adds the Authorization header.

  • Or use fetch + stream if SSE not possible, although that’s less standard.

Your frontend then connects to /api/proxy/get_resource?... without needing custom headers.


2. Instructor: Create / Manage Library

Once the instructor is satisfied with resources & topics, they create a Library, and add the processed resources into it.

UI Sketch / UX Suggestions

  • After resources have been collected & previewed, show a button: “Save as Library / Create Library”.

  • Form to name the library, optionally tag it, give description.

  • Afterwards, show listing of resources in library; allow editing: update resource metadata, remove resources.

API Details from Docs

  • Create a Library: POST /library with JSON body: name (string, required), tag (string, optional). Responds with { id: number, name, tag }. docs.compasai.com

  • Fetch a Library: GET /library/<id> returns library including resources array. docs.compasai.com

  • Delete Library: DELETE /library/<id> docs.compasai.com

  • Add Resources: POST /resources (with library_id + list of ResourceObject) docs.compasai.com

  • Update Resource in Library: PATCH /resources/<id> with updated resource object docs.compasai.com

  • Delete Resource from Library: DELETE /resources/<id> docs.compasai.com


3. Learner: Generate a Personalized Outline via Outline API

Once the library is ready, the learner (or instructor previewing for a learner) can input their learning preferences and generate a custom outline.

UI Sketch / UX Suggestions

  • Learner form with fields:

    Field
    Description

    What you want to learn (topic + proficiency etc.)

    e.g. “Cloud computing basics, beginner, slides + videos, ~10 hours”

    Prefered material types (videos, articles, slides etc.)

    checkboxes / tags

    Key topics you want included (optional, from library’s key topics)

    multi-select from previewed key topics

    Strictness: whether to only include those key topics or allow flexibility

    toggle

  • On submit, show streaming outline being built: show sections appearing, modules, lessons, durations, preview content. Allow learner to cancel / tweak parameters.


Reference Examples

Here are sample payloads / event streams from the docs:

  • Resources SSE sample (excerpt): upon calling /get_resource

  • Outline SSE sample (excerpt): upon calling /create_outline


Putting It All Together: Sample End-to-End Code

Below is a minimal end-to-end flow in TypeScript (simplified) to illustrate how an application could wire this up.


UI / UX Best Practices & Considerations

  • Incremental feedback: As SSE events stream in, show parts of the result (resource cards, topics, sections/modules) immediately. Avoid leaving learners or instructors staring at loading spinner with no visible output.

  • Preview content: For each resource & key topic, allow instructor / learner to preview (e.g. snippet, first few lines, video link) so they understand what is included.

  • Selective editing: Instructor should be able to prune resources, deselect key topics, adjust order, etc., before finalizing library or outline.

  • Time & effort estimation: Show durations (for resources, lessons) to help learner estimate total time needed; allow learner to adjust “hours” parameter to scale outline.

  • Strict vs flexible: When learner picks key topics + strict = true, enforce that those are included; else allow the system more flexibility to include supplementary topics.

  • Fallback & error handling: If SSE fails, show retry / fallback; handle network issues; show error states clearly.

  • Permissions / roles: Ensure the UI separates instructor workflows (resource/library creation) vs learner workflows (selecting library / generating outline).

FAQ / Edge Cases

Question
Notes / Solutions

What if a learner picks a key topic not present in the library's resources?

The API may still attempt to include it, but it's better UX to only allow picking from available key topics; or warn about missing coverage.

Can library be updated over time?

Yes: using PATCH /resources/<id>, DELETE /resources/<id>, POST /resources to add new ones. After updates, learners may regenerate outlines to reflect new content. docs.compasai.com

How do you handle content types (video vs article vs slides)?

In input_str the learner can specify preferences; topics / resources include resource_type so you can filter / highlight accordingly.


Summary

This tutorial has walked you through:

  1. Using the Resources API to fetch and/or upload learning resources + key topics in a streamed way.

  2. Organizing those into a Library via the Library API.

  3. Generating a Personalized Outline for learners via Outline API, with control over preferences and key topics.

  4. UI/UX suggestions to make the process smooth for both instructors and learners.

Last updated