# zenika/sensei architecture

> Architecture diagram of the GitHub repository zenika/sensei, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zenika/sensei
- Repository: https://github.com/zenika/sensei

## Overview

##### Main Components

a) CLI Layer
- Entry point for user interactions
- Handles commands like 'serve' and 'pdf'

b) Build System
- Webpack configuration and custom loaders
- Transforms training materials into web-ready content
- In the middle layer

c) Output Applications
- Web Application (Slides & Labs)
- PDF Generator
- As parallel end products

d) Source Content Handlers
- Markdown processors
- JSON configuration parsers
- As input handlers

##### Key Relationships to Highlight

- Data flow from source content through loaders to final outputs
- Webpack build pipeline flow
- Relationship between served content and browser

##### Specific Implementation Details

- RevealJS integration (for slides)
- Puppeteer (for PDF generation)
- Webpack Dev Server (for serving content)
- Custom loaders (json-parts, main-title, revealjs, workbook-toc)

**[Input Layer]**
**Training Materials (MD/JSON) → Custom Loaders**

**[Processing Layer]**
**Webpack Build System**
- ↓
**[Output Layer]**
**Web App (Slides/Labs) | PDF Generator**

##### Important Elements

- Docker container boundary (as this is a primary deployment method)
- Port mapping (8080 default)
- Volume mounting points
- Watch/Hot Reload mechanism
- Browser interaction points

##### Technical Details to Note

- Separation between development and production flows
- Hot reload capabilities
- PDF generation requirements (especially for M1/M2 Macs)
- Configuration points (SENSEI_PORT, SENSEI_WATCH_POLL)

- Container boundaries
- Configuration points

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        MD[Training Materials MD]
        JSON[Training Materials JSON]
    end

    subgraph CLI
        CLIE["CLI Entry"]:::cli
    end

    subgraph BuildSystem
        WPC["Webpack Config"]:::build
        subgraph Loaders
            JPL["JSON Parts Loader"]:::loader
            MTL["Main Title Loader"]:::loader
            RJL["RevealJS Loader"]:::loader
            WTL["Workbook TOC Loader"]:::loader
        end
    end

    subgraph WebApp
        WDS["Webpack Dev Server"]:::server
        subgraph Apps
            SA["Slides Application"]:::app
            LA["Labs Application"]:::app
        end
        RJS["RevealJS Integration"]:::external
    end

    subgraph PDFGen
        PDF["PDF Generator"]:::pdf
        PUP["Puppeteer"]:::external
    end

    subgraph Container
        PORT["Port 8080"]:::config
        WATCH["Watch/Hot Reload"]:::config
    end

    MD --> Loaders
    JSON --> Loaders
    CLIE --> WPC
    CLIE --> PDF
    Loaders --> WPC
    WPC --> WDS
    WDS --> Apps
    Apps --> RJS
    WDS --> Container
    PDF --> PUP

    %% Click Events
    click CLIE "https://github.com/Zenika/sensei/blob/main/src/cli/cli.js"
    click WPC "https://github.com/Zenika/sensei/blob/main/src/build/webpack.config.js"
    click JPL "https://github.com/Zenika/sensei/blob/main/src/build/loaders/json-parts-loader.js"
    click MTL "https://github.com/Zenika/sensei/blob/main/src/build/loaders/main-title-loader.js"
    click RJL "https://github.com/Zenika/sensei/blob/main/src/build/loaders/revealjs-loader.js"
    click WTL "https://github.com/Zenika/sensei/blob/main/src/build/loaders/workbook-toc-loader.js"
    click SA "https://github.com/Zenika/sensei/tree/main/src/app/slides"
    click LA "https://github.com/Zenika/sensei/tree/main/src/app/labs"
    click PDF "https://github.com/Zenika/sensei/blob/main/src/pdf/pdf.js"

    %% Styles
    classDef cli fill:#2196F3,stroke:#1565C0,color:white
    classDef build fill:#1976D2,stroke:#0D47A1,color:white
    classDef loader fill:#4CAF50,stroke:#2E7D32,color:white
    classDef server fill:#FFA000,stroke:#FF6F00,color:white
    classDef app fill:#FF5722,stroke:#D84315,color:white
    classDef external fill:#9E9E9E,stroke:#616161,color:white
    classDef pdf fill:#E91E63,stroke:#C2185B,color:white
    classDef config fill:#795548,stroke:#5D4037,color:white

    %% Legend
    subgraph Legend
        L1["CLI Component"]:::cli
        L2["Build System"]:::build
        L3["Loaders"]:::loader
        L4["Server"]:::server
        L5["Applications"]:::app
        L6["External Tools"]:::external
        L7["PDF Generation"]:::pdf
        L8["Configuration"]:::config
    end
```
