# officedev/script-lab architecture

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

- Interactive diagram: https://gitdiagram.com/officedev/script-lab
- Repository: https://github.com/officedev/script-lab

## Overview

##### Main Components Structure

a) Client Applications (Top Level)
- Excel, Word, PowerPoint, and Outlook integration points
- How Script Lab integrates as an Add-in within these applications

b) Core Application Components (Middle Layer)
- Editor Package
- Runner Package
- Common Package

##### Key Architectural Elements

a) Editor Component (/packages/editor):
- Redux store architecture
- Main subsystems:
- Code Editor (Monaco)
- Backstage System
- Custom Functions Dashboard
- Solution Management

b) Runner Component (/packages/runner):
- Snippet Container
- Custom Functions Runner
- Message Communication System

c) Common Components (/packages/common):
- Shared UI Components
- Utilities
- Interfaces
- Theme System

##### Data Flow and Integration

- Communication between Editor and Runner
- Office JS API interactions
- GitHub Gist integration
- Local storage management
- Custom Functions execution flow

##### External Services Integration

Connections to:
- Monaco Editor
- GitHub Gists
- Office JS APIs
- Custom Functions Runtime

##### Specific Implementation Details

Create subsections showing:
**┌─ Script Lab Add-in ─────────────────────┐**

- ┌─ Editor ─────┐    ┌─ Runner ───────┐ │
- Monaco     │    │ - Snippet      │ │
- Solutions  │━━━▶│   Execution    │ │
- UI Store   │    │ - Console      │ │
- ┘    └───────────────┘ │
- ▲                  ▲          │

- ┌─ Common Package ──────────┐      │
- Shared Components      │      │
- Utilities             │      │
- ┘      │
- ┘

##### Technical Details to Highlight

- React/Redux architecture
- TypeScript implementation
- Office JS API integration
- Custom Functions support
- Authentication flows
- Storage mechanisms

##### Deployment View

How the system operates in:
- Office Desktop
- Office Online
- Different host applications

- High-level architecture visibility
- Detailed component relationships
- Clear data/control flows
- Integration points with Office platform

Remember to include version/environment-specific variations and maintain visual clarity while showing the complex interactions between components.

This system design should help developers understand both the macro-architecture and the detailed component interactions within Script Lab.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Office Applications"
        Excel["Excel"]
        Word["Word"]
        PowerPoint["PowerPoint"]
        Outlook["Outlook"]
    end

    subgraph "Script Lab Add-in"
        Manifest["Office Add-in Integration"]:::manifest
        click Manifest "https://github.com/OfficeDev/script-lab/tree/main/manifests/"

        subgraph "Editor Package"
            Editor["Editor Core"]:::editor
            click Editor "https://github.com/OfficeDev/script-lab/tree/main/packages/editor/"
            MonacoEditor["Monaco Editor"]:::editor
            click MonacoEditor "https://github.com/OfficeDev/script-lab/tree/main/packages/editor/src/pages/Editor/components/Main/Editor/"
            ReduxStore["Redux Store"]:::store
            click ReduxStore "https://github.com/OfficeDev/script-lab/tree/main/packages/editor/src/pages/Editor/store/"
            SolutionMgmt["Solution Management"]:::editor
            click SolutionMgmt "https://github.com/OfficeDev/script-lab/tree/main/packages/editor/src/pages/Editor/store/solutions/"
            CustomFunctions["Custom Functions Dashboard"]:::editor
            click CustomFunctions "https://github.com/OfficeDev/script-lab/tree/main/packages/editor/src/pages/CustomFunctions/"
        end

        subgraph "Runner Package"
            Runner["Runner Core"]:::runner
            click Runner "https://github.com/OfficeDev/script-lab/tree/main/packages/runner/"
            SnippetContainer["Snippet Container"]:::runner
            click SnippetContainer "https://github.com/OfficeDev/script-lab/tree/main/packages/runner/src/pages/Runner/components/SnippetContainer/"
            CFRunner["Custom Functions Runner"]:::runner
            click CFRunner "https://github.com/OfficeDev/script-lab/tree/main/packages/runner/src/pages/CustomFunctionsRunner/"
        end

        subgraph "Common Package"
            Common["Common Core"]:::common
            click Common "https://github.com/OfficeDev/script-lab/tree/main/packages/common/"
            SharedUI["Shared UI Components"]:::common
            click SharedUI "https://github.com/OfficeDev/script-lab/tree/main/packages/common/src/components/"
            MessageSystem["Message Communication"]:::common
            click MessageSystem "https://github.com/OfficeDev/script-lab/blob/main/packages/common/src/interfaces/server.communication.ts"
            ThemeSystem["Theme System"]:::common
            click ThemeSystem "https://github.com/OfficeDev/script-lab/tree/main/packages/common/src/components/Theme/"
            Console["Console"]:::common
            click Console "https://github.com/OfficeDev/script-lab/tree/main/packages/common/src/components/Console/"
        end
    end

    subgraph "External Services"
        GitHub["GitHub Gists"]
        OfficeJS["Office JS APIs"]
        Storage["Local Storage"]
    end

    %% Connections
    Excel & Word & PowerPoint & Outlook --> Manifest
    Manifest --> Editor
    Editor --> Runner
    Editor --> Common
    Runner --> Common
    Editor --> GitHub
    Editor --> OfficeJS
    Runner --> OfficeJS
    Editor --> Storage
    
    %% Component Relationships
    Editor --> MonacoEditor
    Editor --> ReduxStore
    Editor --> SolutionMgmt
    Editor --> CustomFunctions
    Runner --> SnippetContainer
    Runner --> CFRunner
    Common --> SharedUI
    Common --> MessageSystem
    Common --> ThemeSystem
    Common --> Console

    %% Styling
    classDef editor fill:#3498db,stroke:#2980b9,color:white
    classDef runner fill:#2ecc71,stroke:#27ae60,color:white
    classDef common fill:#9b59b6,stroke:#8e44ad,color:white
    classDef manifest fill:#e67e22,stroke:#d35400,color:white
    classDef store fill:#f1c40f,stroke:#f39c12,color:black
    
    %% Legend
    subgraph Legend
        L1["Editor Components"]:::editor
        L2["Runner Components"]:::runner
        L3["Common Components"]:::common
        L4["Manifest"]:::manifest
        L5["Store"]:::store
    end
```
