# ifpen/chalk-it architecture

> Architecture diagram of the GitHub repository ifpen/chalk-it, 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/ifpen/chalk-it
- Repository: https://github.com/ifpen/chalk-it

## Overview

##### Main System Components

The system architecture should be divided into these major components:

a) Front-end Layer:
- Dashboard Editor UI (Angular-based)
- Widget System
- Datanode Management
- Runtime Environment

b) Back-end Layer:
- Python Server
- File Synchronization System
- Middleware API

c) External Integration Layer:
- Pyodide Integration
- Web Services Support
- Export System

##### Key Architectural Elements

a) Core Components:
**Frontend (Angular)**
- Editor Module
- Dashboard Runtime
- Widget System
- Datanode Engine

**Backend (Python)**
- Server Core
- File Sync Service
- Middleware API

**Integration Layer**
- Pyodide Bridge
- External Services
- Export System

b) Data Flow Directions:
- User Interface → Dashboard Editor
- Editor → Datanode Engine
- Datanode Engine → Widget System
- Backend ↔ Frontend Communication
- Pyodide ↔ Python Code Execution

##### Specific Implementation Details

a) Widget System Architecture:
- Plugin-based architecture (shown in /front-end/source/kernel/dashboard/plugins/)
- Widget factory pattern
- Component lifecycle management

b) Datanode System:
- Execution engine
- Dependency management
- Formula interpreter
- Time management

c) Integration Points:
- Python/JavaScript bridge
- External service connectors
- File system integration

##### Key Interactions to Highlight

- Dashboard editing workflow
- Runtime execution flow
- Data synchronization process
- Export/deployment process
- Python/JavaScript interop

##### Deployment Aspects

Deployment options:
- Standalone HTML export
- Docker deployment
- Python package installation
- Development environment

##### Business Logic Layer (Middle)
- Datanode Processing
- Code Execution
- State Management

##### Integration Layer (Bottom)
- File System
- External Services
- Deployment Options

This architecture represents a modern web application with a focus on extensibility (plugin system), interoperability (Python/JavaScript bridge), and deployment flexibility (standalone HTML, Docker, pip package).

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef integration fill:#e67e22,stroke:#d35400,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Frontend Layer
    subgraph Frontend
        Editor["Dashboard Editor UI"]
        WidgetSys["Widget System"]
        DataNode["Datanode Management"]
        Runtime["Runtime Environment"]
        
        %% Widget System Components
        WidgetFactory["Widget Factory"]
        PluginSystem["Plugin System"]
        
        %% Datanode Components
        ExecEngine["Execution Engine"]
        FormulaInt["Formula Interpreter"]
        TimeManager["Time Management"]
    end

    %% Backend Layer
    subgraph Backend
        PyServer["Python Server"]
        FileSync["File Sync System"]
        MiddlewareAPI["Middleware API"]
    end

    %% Integration Layer
    subgraph Integration
        Pyodide["Pyodide Bridge"]
        WebServices["Web Services"]
        Export["Export System"]
    end

    %% Relationships
    Editor --> WidgetSys
    Editor --> DataNode
    WidgetSys --> WidgetFactory
    WidgetSys --> PluginSystem
    DataNode --> ExecEngine
    ExecEngine --> FormulaInt
    ExecEngine --> TimeManager
    Runtime --> DataNode
    
    DataNode --> PyServer
    PyServer --> FileSync
    PyServer --> MiddlewareAPI
    
    Runtime --> Pyodide
    Pyodide --> WebServices
    Editor --> Export

    %% Click Events
    click Editor "https://github.com/ifpen/chalk-it/tree/main/front-end/source/angular/modules/dashboard/"
    click WidgetSys "https://github.com/ifpen/chalk-it/tree/main/front-end/source/kernel/dashboard/plugins/"
    click DataNode "https://github.com/ifpen/chalk-it/tree/main/front-end/source/kernel/datanodes/"
    click Runtime "https://github.com/ifpen/chalk-it/tree/main/front-end/source/kernel/runtime/"
    click PyServer "https://github.com/ifpen/chalk-it/blob/main/back_end/app/server.py"
    click FileSync "https://github.com/ifpen/chalk-it/blob/main/back_end/app/server_file_sync.py"
    click MiddlewareAPI "https://github.com/ifpen/chalk-it/tree/main/back_end/middleware/src/chalkit_python_api/"
    click Pyodide "https://github.com/ifpen/chalk-it/blob/main/front-end/source/kernel/base/pyodide-def.js"
    click Export "https://github.com/ifpen/chalk-it/tree/main/front-end/source/kernel/general/export/"
    click ExecEngine "https://github.com/ifpen/chalk-it/tree/main/front-end/source/kernel/datanodes/execution-engine/"
    click WidgetFactory "https://github.com/ifpen/chalk-it/blob/main/front-end/source/kernel/dashboard/widget/widget-factory.js"
    click PluginSystem "https://github.com/ifpen/chalk-it/blob/main/front-end/source/kernel/dashboard/plugins/plugin-base.js"
    click FormulaInt "https://github.com/ifpen/chalk-it/blob/main/front-end/source/kernel/datanodes/execution-engine/FormulaInterpreter.js"
    click TimeManager "https://github.com/ifpen/chalk-it/blob/main/front-end/source/kernel/datanodes/execution-engine/TimeManager.js"

    %% Style Applications
    class Editor,WidgetSys,DataNode,Runtime,WidgetFactory,PluginSystem,ExecEngine,FormulaInt,TimeManager frontend
    class PyServer,FileSync,MiddlewareAPI backend
    class Pyodide,WebServices,Export integration
```
