Ellerin setup stage 1

Ellerin

Skip to technical description

What

A learning platform where AI builds and teaches personalised lectures.

Focus

Managing the context window and dynamic system prompts.

Role

Technical lead, with responsibility for the system architecture and the AI system.

Stack

React and React Router on the front end, a Node.js and Express REST API, and MongoDB for storage.

Shows

A layered REST API, dynamic system prompts assembled per request, and progression controlled by the API instead of the model.

About the project

What it is

Ellerin is a digital learning platform that uses artificial intelligence, with the aim of maximizing the positive effects and minimizing potential negative cognitive impacts of AI use. This is done by structuring and coordinating how the AI model operates.

Setup page part 1 for Ellerin - ask questions

How a lecture is built

The model identifies the concepts behind what the user wants to learn, assesses what relevant knowledge the user already has, and builds a curriculum consisting of several lectures. Complexity, progression and approach are adapted to each individual user.

Context and prompting

Much of the work behind Ellerin is about managing the context window and using dynamic system prompts, to ensure that each lecture is tailored to the individual user and their needs.

Roles and contributions

  • Technical lead
  • Backend development
  • Frontend development
  • Contributed to design
  • Designed and implemented system architecture
  • Designed and implemented AI system
  • Database design
  • Context management
  • Dynamic system prompting
Setup page part 1 for Ellerin - ask questions
Setup page part 2 for Ellerin - set context
Setup page part 3 for Ellerin - set learning objectives
Setup page part 3 for Ellerin - evaluation questions
The chat page of Ellerin
Request an explanation of a concept
Pop-up window with explanation

1 / 7

Languages and technologies

A JavaScript stack end to end: React on the front end, and a Node.js and Express REST API with MongoDB behind it.

Javascript

The language of both the front end and the API.

React

The front end, together with React Router V7.

Node.js

Runs the REST API.

Express.js

The API framework, with controllers, service functions and middleware.

MongoDB

Stores users, sessions and the context for each lecture sequence.

HTML

The markup of the interface.

SCSS

The styling of the interface.

Technical

API - General signal flow

Ellerin uses a REST API, written in Node.js with Express.js, and follows a layer-based structure with controllers, service functions and utility functions.

Controllers, services and middleware

The controller acts as an orchestrator and delegates business logic to the relevant service functions. Each route uses rate limiting, and other relevant middleware such as sanitization and validation as needed.

Authentication

Authentication is handled via JWT access tokens, where routes that require login verify that the token matches a user and an active session stored in the database.

The AI model

The API also handles all communication with the AI model, including management of system prompts and the contents of the context window.

Dynamic system prompts

Here is a simplified explanation of how dynamic system prompts and interaction with the AI model are handled during a digital lecture.

Assembling the prompt

Before each request to the AI model API, the system prompt is assembled dynamically by fetching static instructions from a JSON file, and contextual information from the database. The static part defines role, task and rules, while the dynamic part contains information specific to the current user and the current sequence in the lecture. It is formatted as Markdown before being sent to the model.

The response

The response from the AI model contains a text response, a boolean indicating whether the user has broken the guidelines, and a boolean indicating whether the user has met the criterion for the current sequence. The response and the indicator for met criteria are saved in the database before the answer is sent back to the client.

Progression

When progression is indicated, the current sequence is updated in the database, which means the next request automatically fetches contextual information for the next sequence. This limits the information in the context window to only what is relevant for the current sequence, while progression is handled automatically by the API. Responsibility for structure and coordination lies with the API, not the model, to guarantee that the correct structure is followed.

Front-end

The frontend is built with React and React Router V7.

Authentication

Authentication is handled via an AuthContext provider that makes the access token available globally in the application, and it is used as a Bearer token in requests to the API. Routes that require login are protected via protected routes, which verify the presence of a valid access token.

Layout

The layout component is imported per page rather than wrapping the entire application, since not all pages use the same layout.

Requests and state

Requests to the API are handled via composable functions. Each page is responsible for its own state and uses shared, reusable components.