# jupyter/notebook architecture

> Architecture diagram of the GitHub repository jupyter/notebook, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jupyter/notebook
- Repository: https://github.com/jupyter/notebook

## Overview

##### Main Components

a. Frontend Layer:
- JupyterLab-based UI components (packages/ui-components)
- Various extensions (application, console, notebook, terminal, etc.)
- Tree view component for file navigation

b. Backend Layer:
- Jupyter Server as the core server component
- Kernel management system
- File system interaction
- WebSocket communication

c. Extension System:
- Server extensions
- Frontend extensions
- How they integrate with the core system

##### Key Architectural Elements

**[Client Browser]**

- ▼
**[Frontend Layer]**
- UI Components
- Extensions
- Application Extension
- Notebook Extension
- Console Extension
- Terminal Extension
- Tree Extension
- Document Management

- ▼
**[Communication Layer]**
- WebSocket Connections
- HTTP/REST APIs

- ▼
**[Backend Layer]**
- Jupyter Server
- Kernel Management
- Python Kernel
- Other Language Kernels
- File System
- Configuration Management

##### Important Relationships to Highlight

- Bidirectional communication between frontend and backend via WebSocket
- How extensions plug into both frontend and backend
- Demonstrate the relationship between notebooks and kernels
- How the file system integrates with the tree view

##### Technical Details

- That it's built on JupyterLab components
- Relationship with Jupyter Server
- Language-agnostic nature of the notebook
- Packages from the file structure:
- application
- ui-components
- notebook-extension
- terminal-extension
- tree

##### Implementation Notes

- Version information (Notebook v7)
- Notes about backward compatibility

##### Additional Elements

- A small section showing the testing infrastructure
- Configuration flow
- How themes and customization work
- Where documentation fits in

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph FrontendLayer
        UI["UI Components"]:::frontend
        DocMgmt["Document Management"]:::frontend
        Search["Document Search"]:::frontend
        Help["Help System"]:::frontend
        
        subgraph Extensions
            AppExt["Application Extension"]:::frontend
            NotebookExt["Notebook Extension"]:::frontend
            ConsoleExt["Console Extension"]:::frontend
            TerminalExt["Terminal Extension"]:::frontend
            TreeExt["Tree Extension"]:::frontend
            LabExt["Lab Integration"]:::frontend
        end
    end

    subgraph CommunicationLayer
        WS["WebSocket Connections"]:::comm
        REST["HTTP/REST APIs"]:::comm
    end

    subgraph BackendLayer
        Server["Jupyter Server"]:::backend
        Config["Configuration Management"]:::backend
        Templates["Application Templates"]:::backend
        
        subgraph KernelMgmt["Kernel Management"]
            PyKernel["Python Kernel"]:::backend
            OtherKernel["Other Language Kernels"]:::backend
        end
        
        FS["File System"]:::backend
        Tree["Tree Component"]:::backend
    end

    subgraph Testing
        UITests["UI Tests"]:::test
    end

    Browser --> UI
    UI --> WS & REST
    WS & REST --> Server
    Server --> KernelMgmt
    Server --> FS
    Server --> Config
    Tree --> FS
    
    %% Component relationships
    UI --> Extensions
    Extensions --> WS
    Server --> Templates

    %% Click events
    click UI "https://github.com/jupyter/notebook/tree/main/packages/ui-components/"
    click AppExt "https://github.com/jupyter/notebook/tree/main/packages/application/"
    click NotebookExt "https://github.com/jupyter/notebook/tree/main/packages/notebook-extension/"
    click ConsoleExt "https://github.com/jupyter/notebook/tree/main/packages/console-extension/"
    click TerminalExt "https://github.com/jupyter/notebook/tree/main/packages/terminal-extension/"
    click Tree "https://github.com/jupyter/notebook/tree/main/packages/tree/"
    click TreeExt "https://github.com/jupyter/notebook/tree/main/packages/tree-extension/"
    click Config "https://github.com/jupyter/notebook/blob/main/jupyter-config/jupyter_server_config.d/notebook.json"
    click Server "https://github.com/jupyter/notebook/blob/main/notebook/app.py"
    click DocMgmt "https://github.com/jupyter/notebook/tree/main/packages/docmanager-extension/"
    click Templates "https://github.com/jupyter/notebook/tree/main/app/templates/"
    click Help "https://github.com/jupyter/notebook/tree/main/packages/help-extension/"
    click Search "https://github.com/jupyter/notebook/tree/main/packages/documentsearch-extension/"
    click LabExt "https://github.com/jupyter/notebook/tree/main/packages/lab-extension/"
    click UITests "https://github.com/jupyter/notebook/tree/main/ui-tests/test/"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef comm fill:#f1c40f,stroke:#f39c12,color:black
    classDef test fill:#e74c3c,stroke:#c0392b,color:white

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Component"]:::backend
        Communication["Communication Layer"]:::comm
        Testing["Testing Component"]:::test
    end
```
