# Architecture

> How Sypnia Learn is built: its parts, how they connect, and why exercises run outside the engine.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://learn.docs.sypnia.com/architecture/

For agents: Learn architecture: one TypeScript service (Node 22; AGPL-3.0) with the API, the MCP server, the lesson renderer (shares @sypnia/learn/format with the CLI: parse, level blocks, slots), the binder (reads the learner's project through Cases, Data, Telemetry, Git APIs with the person's token), the exercise service (branches through Git APIs or the CLI's local git), the check orchestrator (jobs to a runner: Agent sandbox API in Cloud, sypnia-sandbox or a Docker runner self-hosted), the offers listener (events from Cases, Agent, Run, Telemetry, Design), the memory writer (Agent memory API / account); Postgres (schema sypnia_learn) for courses, lessons, exercises, check runs, progress, offers, settings; object storage for course files and videos (Sypnia Files in Cloud); Sypnia AI for explanations and hints. Console learn.app.sypnia.com in @sypnia/ui (private).

**Figure**: Sypnia Learn: the engine renders lessons for you and your project, starts and checks exercises outside itself, and remembers what you learned.

1. You, App, the CLI or your agent call the API or the MCP server.
2. A lesson is rendered for your level and filled with items from your project.
3. Your project is read with your permissions: the map, the tables, the traces, the repository.
4. An exercise becomes a branch; its checks are sent as a job.
5. The runner checks the branch in a sandbox and sends back each result.
6. Explanations and hints come from Sypnia AI, at your level.
7. When a lesson is done, a note is written in your memory.

The engine is one service with the API, the MCP server, the lesson renderer, the binder that reads your project, the exercise service, the check orchestrator, the offers listener and the memory writer. It keeps its state in Postgres and course files and videos in object storage. Exercises never run inside the engine: a runner checks them in a sandbox.

| Part                                                                                   | What it does                                  | Language                                          | Open source   |
| -------------------------------------------------------------------------------------- | --------------------------------------------- | ------------------------------------------------- | ------------- |
| **Learn engine**: API, MCP, renderer, binder, exercises, checks, offers, memory writer | everything in the diagram's frame             | TypeScript (Node 22)                              | yes, AGPL-3.0 |
| **`@sypnia/learn`**: the lesson format, the CLI, the client                            | for learners, authors and their tools         | TypeScript                                        | yes, MIT      |
| **The runner**                                                                         | checks exercises in a sandbox                 | Sypnia Agent's sandbox (Rust), or a Docker runner | yes           |
| **Sypnia's courses**                                                                   | the lessons and videos presented by Santi     | Markdown and video                                | no            |
| **Console** at `learn.app.sypnia.com`                                                  | courses, progress and settings in the browser | TypeScript (React, `@sypnia/ui`)                  | no            |

## Why TypeScript

Learn spends its time rendering Markdown and calling other products, not on a hot path. Writing the engine in the same language as `@sypnia/learn` means the CLI, the console and the engine read lesson files with **the same parser**, so a lesson that passes `learn lint` renders the same everywhere.

## Why exercises run outside

An exercise is someone's code. Running it inside the engine would put every learner's work next to everyone's progress. The runner is a separate sandbox with only the branch, no secrets and no production access.

- [Request paths](/architecture/request-paths/): What happens when you open a lesson, start an exercise, check it, ask for an explanation, and get an offer.
- [Data model](/architecture/data-model/): The tables of the Learn engine and what each one holds.
- [On AWS](/architecture/reference-implementation-aws/): How Sypnia Cloud runs Learn on AWS: the services, where each part runs, and how it scales.
- [Failures and scaling](/architecture/failures-and-scaling/): What happens to a lesson, an exercise or your progress when a part of Learn, or a product it uses, fails.
- [Codebase](/architecture/codebase/): Where Learn's code, the lesson format and the sample project live.
