M-PowerC Architecture

How the cable, switchgear & SLD tools fit together — pages, backend, workers, deployment

What this tool does

M-PowerC v1.8 is an offline-first electrical design assistant for Munters DH and plus-system units. It turns electrical drawings into structured cable schedules, sizes cables to EN 60204-1, lets engineers draft single-line diagrams, and offers an AI assistant for free-form switchgear & cable questions. All UIs run in the browser — no install for end-users.

Offline-first PDF in → Excel out EN 60204-1 sizing SLD builder AI assistant (LLM via free Cloudflare proxy)
Pages & their roles
Electrical Tools Main Page
Main hub (landing page)
Entry point / Hub

Landing dashboard. Routes the user to every other tool and shows help + datasheets.

  • Buttons to all sub-tools (Cable Selector, Workflow, SLD, AI assistant)
  • Built-in FAQ & help modal
  • Quick links to datasheets (MCB, MCCB, MPCB, contactor)
Offline Open
Auto Cable Schedule
Main → Auto Cable Schedule
Pipeline orchestrator

Drives the end-to-end pipeline: Drawing PDF → Vision → JSON → Rules Engine → Excel.

  • Step-by-step visual progress
  • Upload PDF and run local Python pipeline
  • Download generated Excel / JSON
  • Server-status indicator
Offline + local server Open
E-dwg Extractor
Reached from Auto Cable Schedule
Drawing → Data

In-browser PDF parser for Munters AirC 800 drawings. Extracts cable schedule, BOM and main-power summary.

  • Upload electrical drawing PDFs
  • Extract cable schedule & BOM tables
  • Export results to Excel
  • Uses pdf.js — runs fully in browser
Offline Open
DH & System Component Selection Tool
Main → DH & System Component Selection Tool
Switchgear & cable selection

Interactive table to pick switchgear components and matching cables for DH-unit systems.

  • Live cable sizing per component
  • Filter / search by component type
  • Sticky-header data table
  • Hand-off to Upload page & main hub
Offline Open
Component Selector (Legacy)
Legacy / archived
Legacy / dual-system

Older selector that also handles plus-system units. Kept for reference.

  • Supports both DH & plus systems
  • Component selection table
  • Legacy interface
Offline Open
EN 60204-1 Cable Sizing
Main → EN 60204-1 Cable Sizing
Standards calculator

Multi-cable sizing calculator following EN 60204-1 with full compliance report.

  • Configure multiple cable runs at once
  • Compliance checks against EN 60204-1
  • Generates HTML / printable PDF report
  • Multiple calculation view modes
Offline Open
Cable Sizing — Parallel Runs
EN 60204-1 → Parallel Runs
Extended calculator

Extended EN 60204-1 calculator that supports parallel cable runs and a print-optimised layout.

  • Parallel-run calculations
  • Cable derating factors
  • Print-ready layout
Offline Open
Draw SLD
Main → Draw SLD
Diagram editor

Canvas-based Single Line Diagram builder with an electrical component palette.

  • Drag components from left palette
  • Canvas drawing area
  • Properties panel on right
  • One-click hand-off to M-PowerC AI
Offline Open
M-PowerC AI Assistant
Linked from Auto Cable Schedule & Draw SLD
Hybrid AI chat

Hybrid assistant: deterministic rule-engine for live-calc questions + a hosted LLM (Llama 3.3 70B class) for freeform Q&A.

  • Multi-turn chat with up to 6 turns of memory
  • Attach up to 8 supporting files
  • Pre-configured prompt library
  • Routes through free Cloudflare Worker proxy
Needs Worker + LLM API Open
Maintenance
Served automatically during pause
Paused-state page

Served by the pause worker when the site is taken offline for maintenance.

  • Friendly "back soon" message
  • Activated by pause.bat / resume.bat
Static Open
Architecture (this page)
Help & Datasheets → Architecture (sign-in)
Documentation

Single source of truth describing every page, backend script, worker and deployment path.

  • Page-by-page roles
  • Architecture diagram
  • Backend & worker reference
  • Deployment steps
Offline You are here

How the layers connect

The user always lands on the Electrical Tools Main Page. From there, three flows are possible: (1) use a standalone calculator/selector page, (2) run the Drawing→Excel pipeline via Auto Cable Schedule + local Python server, (3) ask the M-PowerC AI Assistant, which talks to a hosted LLM through a Cloudflare Worker proxy.

User
EngineerBrowser only
Entry / Hub
Electrical Tools Main PageMain dashboard
Tool pages (frontend)
DH & System Component Selection ToolSelector
EN 60204-1 Cable SizingStandards calc
Cable Sizing — Parallel RunsExtended calc
Draw SLDDiagram editor
Auto Cable SchedulePipeline UI
E-dwg ExtractorDrawing → data
M-PowerC AI AssistantAI chat
Local backend (only for workflow)
Python pipeline127.0.0.1:5057
cable schedule.pyDrawing parser
bom download.pyBOM parser
Cloud (only for AI chat)
Cloudflare Workerpilot/cloudflare-worker.js
Hosted LLMLlama 3.3 70B class

The LLM API key lives only as a secret on the Worker — never in the browser.

Typical user journeys

Drawing → Excel

  1. Open the Electrical Tools Main Page
  2. Click Auto Cable Schedule
  3. Upload drawing PDF → local Python server runs
  4. Download cable schedule as .xlsx

Size a cable

  1. Open EN 60204-1 Cable Sizing from the main page
  2. Enter load, length, install method
  3. Review EN 60204-1 compliance
  4. Print or export the report

Ask the AI

  1. Open M-PowerC AI Assistant
  2. Browser → Cloudflare Worker → hosted LLM
  3. Reply streams back into chat

Backend scripts & workers

Frontend pages are self-contained, but two helper layers exist: Python scripts for PDF parsing (only used by the workflow page), and JavaScript workers for AI proxying and maintenance mode.

Python scripts
FileRoleWhat it does
cable schedule.py PDF → schedule Reads Munters drawings with pdfplumber, groups words into table rows, and emits a structured cable schedule (Cable designation, From, To, Cable type, Conductors, Ø, Length, Munters part no., Function text).
bom download.py PDF → BOM Extracts Bill-of-Materials tables (Description, Qty, Manufacturer, Type Number, Munters Part No) and returns cleaned structured data.
build_deck.py / build_deployment_deck.py Doc builder Generate PowerPoint decks (M-PowerC_Overview.pptx, M-PowerC_Deployment.pptx) from templates.
JavaScript workers
FileRoleWhat it does
chatbot.js In-page AI client CableBot v4. Hybrid assistant embedded in tool pages. Routes deterministic live-calc questions to a local rule engine, and freeform questions to a hosted LLM via the Worker proxy. Each host page provides window.CableBotSnapshot() for context.
_worker.js Pause worker Cloudflare Pages Function. When deployed at site root, intercepts every request and returns maintenance.html. Lets static assets (bg image, favicon) through.
pause-worker.js Pause worker (backup) Identical copy of _worker.js kept aside so pause.bat/resume.bat can swap it in and out.
pilot/cloudflare-worker.js AI proxy Receives chat requests from chatbot.js, injects the secret LLM API key (Worker Secret), forwards to the hosted LLM’s OpenAI-compatible /chat/completions endpoint, and streams the response back. Includes 60 req/min per-IP throttle and an origin allow-list.
Pilot folder

pilot/ contains the 15-minute setup for the free Cloudflare proxy: PILOT_SETUP.md (step-by-step guide), cloudflare-worker.js (the proxy) and wrangler.toml (deploy config). On the Cloudflare free tier this gives ~14,400 calls/day — enough for 3–10 colleagues — with the LLM API key never leaving the Worker.

Deployment paths

Three independent deployment surfaces. Pick whichever your IT setup allows — pages stay the same; only hosting differs.

Local files

  1. Copy the v1.9 folder onto a shared drive
  2. Open the Electrical Tools Main Page in the browser
  3. For the pipeline: run python\Run Cable Pipeline.bat once
  4. Auto Cable Schedule will detect 127.0.0.1:5057

SharePoint

  1. Upload the folder to a SharePoint document library
  2. Share the Electrical Tools Main Page link with the team
  3. No IT changes required
  4. AI chat works if the Worker origin allow-list includes SharePoint

Cloudflare Pages

  1. Connect the repo to Cloudflare Pages
  2. Pages serves all HTML; _worker.js handles maintenance mode
  3. Deploy pilot/cloudflare-worker.js separately for AI proxy
  4. Store the LLM API key as a Worker Secret (LLM_API_KEY)

Pause / Resume

  1. Run pause.bat → swaps _worker.js in, serves maintenance.html
  2. Run resume.bat → removes the worker, site returns to normal
  3. Useful for releases or maintenance windows

What's inside each page

Pick a page below to see what's inside it and what you can do there. The details panel appears just below the picker.

  Click a page
Electrical Tools Main PageHub / landing
DH & System Component Selection ToolSwitchgear selector
Auto Cable SchedulePDF → Excel pipeline
Draw SLDDiagram editor
EN 60204-1 Cable SizingStandards calc
M-PowerC AI AssistantHybrid chat
E-dwg ExtractorDrawing → data
Help & DatasheetsModal with 5 tabs
Architecture (this page)6 tabs