jupyter/notebook

Jupyter Interactive Notebook

13,097 stars Jupyter Notebook 8 components

Bundles JupyterLab components into Jupyter Notebook v7's web interface

The system starts with rspack scanning package.json files to discover extensions, then uses module federation to bundle them into a single application. During runtime, the NotebookApp instance loads and activates plugins, which register services and UI components. When users interact with the interface, routing logic determines how to handle different document types - notebooks open in the notebook interface while other files open in appropriate editors. Extensions communicate through JupyterLab's plugin system using dependency injection.

Under the hood, the system uses 2 feedback loops, 3 data pools, 3 control points to manage its runtime behavior.

A 8-component fullstack. 85 files analyzed. Data flows through 5 distinct pipeline stages.

How Data Flows Through the System

The system starts with rspack scanning package.json files to discover extensions, then uses module federation to bundle them into a single application. During runtime, the NotebookApp instance loads and activates plugins, which register services and UI components. When users interact with the interface, routing logic determines how to handle different document types - notebooks open in the notebook interface while other files open in appropriate editors. Extensions communicate through JupyterLab's plugin system using dependency injection.

  1. Package discovery and bundling — rspack.config.js scans the workspace to find all packages with JupyterLab extensions, reads their plugin definitions from package.json metadata, and uses module federation to create a single bundle with dynamic imports [PackageData → Application bundle] (config: LabApp.expose_app_in_browser)
  2. Application initialization — NotebookApp constructor creates the main application instance, sets up the custom NotebookShell, registers base model factories, and loads MIME renderer extensions [NotebookApp.IOptions → Application instance] (config: JupyterNotebookApp.expose_app_in_browser)
  3. Plugin registration and activation — The application discovers all JupyterFrontEndPlugin instances from the bundled extensions, resolves their dependencies, and activates them in dependency order [JupyterFrontEndPlugin → Active services]
  4. Document routing and opening — When users click on files or URLs, the IDocumentWidgetOpener service examines the file extension and factory preferences - .ipynb files route to the notebook interface while other files open in text editors or appropriate viewers [File paths and factory options → Document opening actions]
  5. Interface rendering and interaction — The NotebookShell manages widget placement and layout while individual extensions provide specific functionality like search, help menus, console access, and kernel status indicators [Widget instances → User interface]

Data Models

The data structures that flow between stages — the contracts that hold the system together.

JupyterFrontEndPlugin @jupyterlab/application
TypeScript interface with id: string, activate: function, requires?: token[], optional?: token[], provides?: token, autoStart?: boolean, description?: string
Extensions define plugins that get registered with the application during startup and activated when their dependencies are available
PackageData buildutils/src/utils.ts
TypeScript type with name: string, private?: boolean, version?: string, plus arbitrary package.json fields
Created by reading package.json files, used to manage dependencies and workspace operations
WorkspacePackage buildutils/src/utils.ts
TypeScript type with data: PackageData, name: string, packageJsonPath: string, packagePath: string, private: boolean
Generated during workspace analysis, used throughout build and development tools to represent each package in the monorepo
NotebookApp.IOptions packages/application/src/app.ts
TypeScript interface extending JupyterFrontEnd options with shell?: INotebookShell, mimeExtensions?: IRenderMime.IExtensionModule[]
Passed to NotebookApp constructor to configure the application instance with custom shell and MIME extensions

Hidden Assumptions

Things this code relies on but never validates. These are the things that cause silent failures when the system changes.

critical Ordering unguarded

Expects mimeExtensions array from package.json to be processed sequentially and assumes each extension object has the required structure for createRendermimePlugins() but only checks if the field exists

If this fails: If a MIME extension has malformed structure or missing required fields, createRendermimePlugins() will fail at runtime with cryptic errors, potentially breaking the entire application startup

app/rspack.config.js:mimeExtensions
critical Shape weakly guarded

Assumes options.mimeExtensions is an array of IRenderMime.IExtensionModule objects but only checks if the field exists, not its shape or contents

If this fails: If mimeExtensions contains objects missing required fields like 'id' or 'rendererFactory', createRendermimePlugins() will throw during plugin creation, causing application initialization to fail

packages/application/src/app.ts:NotebookApp.constructor
critical Contract unguarded

Assumes widget.context.path is always a valid file path and that PathExt.extname() will return a meaningful extension, but never validates the path format or handles edge cases like empty paths or paths without extensions

If this fails: If a widget has an invalid or empty context.path, the route determination logic fails silently, potentially opening documents in the wrong interface (notebook vs editor) or generating malformed URLs

packages/docmanager-extension/src/index.ts:opener.open
warning Temporal unguarded

Assumes widget.context.save() will complete successfully before opening in new tab, but doesn't handle save failures or timeouts

If this fails: If save fails due to network issues or permission problems, the new tab opens with stale notebook data, potentially losing kernel info or recent changes without user awareness

packages/docmanager-extension/src/index.ts:opener.open
critical Shape weakly guarded

Expects plugins[page] structure to contain either boolean true or arrays, but template helper list_plugins() will generate malformed JavaScript if plugins contain other data types like objects or strings

If this fails: If package.json has malformed plugin metadata (e.g., plugins.notebook['@some/extension'] = 'config'), the generated template produces invalid JavaScript, breaking application startup with syntax errors

app/rspack.config.js:plugins object parsing
warning Resource unguarded

Assumes filesystem write operations are atomic and that concurrent writes to the same package.json won't corrupt the file

If this fails: In parallel build scenarios or with file watchers, multiple processes writing the same package.json simultaneously can result in truncated or corrupted JSON files, breaking subsequent builds

buildutils/src/utils.ts:writePackageJson
warning Environment unguarded

Assumes all dependency packages have readable package.json files in their root directories and that Node.js module resolution will find them correctly

If this fails: If a dependency is symlinked, has non-standard structure, or package.json is missing, the build fails with ENOENT errors that don't clearly indicate which package caused the problem

app/rspack.config.js:require(path.join(name, 'package.json'))
warning Domain weakly guarded

Hardcodes that .ipynb files always use 'notebooks' route and other files use 'edit' route, but doesn't account for custom factory preferences or server configuration that might override this routing

If this fails: Users with custom document factories or server configurations may find their files consistently opening in the wrong interface, with no clear way to fix the routing mismatch

packages/docmanager-extension/src/index.ts:route determination
info Scale unguarded

Assumes workspace contains a reasonable number of packages and that getLernaPaths() can read all package.json files in memory without performance issues

If this fails: In very large monorepos with hundreds of packages, this synchronous file reading approach can cause build tools to hang or run out of memory during workspace scanning

buildutils/src/utils.ts:getWorkspacePackages
info Contract weakly guarded

Assumes notebookShell.currentWidget is always either null or a valid Widget instance, and that addClass/removeClass operations are safe to call repeatedly

If this fails: If currentWidget becomes a proxy object or widget in an invalid state, addClass/removeClass could throw errors, breaking the search functionality UI feedback

packages/documentsearch-extension/src/index.ts:transformWidgetSearchability

System Behavior

How the system operates at runtime — where data accumulates, what loops, what waits, and what controls what.

Data Pools

Document Registry (registry)
Maps file types to widget factories and model factories, stores available document types and their handlers
Plugin Registry (registry)
Stores all registered plugins with their dependencies and activation status, manages plugin lifecycle
Bundle Cache (cache)
Webpack/rspack generated bundles and assets that are served to the browser, includes federated modules

Feedback Loops

Delays

Control Points

Technology Stack

rspack (build)
Main build tool that bundles TypeScript and assets using webpack-compatible configuration with module federation support
@jupyterlab/application (framework)
Provides the core JupyterFrontEnd class and plugin system that this notebook application extends
TypeScript (runtime)
Primary language for all application logic, extension definitions, and type safety across the plugin system
Handlebars (build)
Template engine for generating JavaScript entry points that dynamically load plugins based on configuration
@lumino/widgets (framework)
Widget toolkit providing the DOM abstraction and layout system for all UI components
Module Federation (build)
Webpack feature used to create federated modules that can be dynamically loaded and composed at runtime

Key Components

Package Structure

app (app)
Main build system that bundles all extension packages into the final notebook application using rspack and module federation.
buildutils (tooling)
Development utilities for managing the monorepo workspace, including package synchronization and development setup.
metapackage (config)
Barrel package that imports all notebook extensions to ensure they're bundled together.
application (app)
Core notebook application class extending JupyterFrontEnd with a custom shell for the notebook interface.
application-extension (library)
Extension providing application-level services like routing, splash screen, and shell configuration.
console-extension (library)
Extension adding console functionality with routing support for opening consoles in new tabs.
docmanager-extension (library)
Extension handling document opening logic, routing notebook files to the notebook interface and other files to editors.
documentsearch-extension (library)
Extension enabling search functionality within notebooks and documents by managing searchable widget classes.
help-extension (library)
Extension providing help menu with links to documentation and Jupyter resources.
lab-extension (library)
Extension adding interface switcher toolbar buttons to navigate between Notebook, JupyterLab, and NbClassic interfaces.
notebook-extension (library)
Extension providing notebook-specific functionality like kernel status display, trusted document handling, and cell execution features.
terminal-extension (library)
Extension adding terminal functionality with routing support for opening terminals in new tabs.
tree (library)
Core file browser tree functionality for navigating the notebook file system.
tree-extension (library)
Extension integrating the file browser tree into the notebook interface.
ui-components (shared)
Shared UI components and icons specific to the Jupyter Notebook interface.

Explore the interactive analysis

See the full architecture map, data flow, and code patterns visualization.

Analyze on CodeSea

Related Fullstack Repositories

Frequently Asked Questions

What is notebook used for?

Bundles JupyterLab components into Jupyter Notebook v7's web interface jupyter/notebook is a 8-component fullstack written in Jupyter Notebook. Data flows through 5 distinct pipeline stages. The codebase contains 85 files.

How is notebook architected?

notebook is organized into 4 architecture layers: Build System, Core Application, Extension Services, UI Components. Data flows through 5 distinct pipeline stages. This layered structure keeps concerns separated and modules independent.

How does data flow through notebook?

Data moves through 5 stages: Package discovery and bundling → Application initialization → Plugin registration and activation → Document routing and opening → Interface rendering and interaction. The system starts with rspack scanning package.json files to discover extensions, then uses module federation to bundle them into a single application. During runtime, the NotebookApp instance loads and activates plugins, which register services and UI components. When users interact with the interface, routing logic determines how to handle different document types - notebooks open in the notebook interface while other files open in appropriate editors. Extensions communicate through JupyterLab's plugin system using dependency injection. This pipeline design reflects a complex multi-stage processing system.

What technologies does notebook use?

The core stack includes rspack (Main build tool that bundles TypeScript and assets using webpack-compatible configuration with module federation support), @jupyterlab/application (Provides the core JupyterFrontEnd class and plugin system that this notebook application extends), TypeScript (Primary language for all application logic, extension definitions, and type safety across the plugin system), Handlebars (Template engine for generating JavaScript entry points that dynamically load plugins based on configuration), @lumino/widgets (Widget toolkit providing the DOM abstraction and layout system for all UI components), Module Federation (Webpack feature used to create federated modules that can be dynamically loaded and composed at runtime). A focused set of dependencies that keeps the build manageable.

What system dynamics does notebook have?

notebook exhibits 3 data pools (Document Registry, Plugin Registry), 2 feedback loops, 3 control points, 2 delays. The feedback loops handle auto-scale and convergence. These runtime behaviors shape how the system responds to load, failures, and configuration changes.

What design patterns does notebook use?

4 design patterns detected: Plugin Architecture, Module Federation, Template Generation, Workspace Monorepo.

Analyzed on April 20, 2026 by CodeSea. Written by .