SESSION 04 GUIDE

Practical Resources & Complete Guide

2026-08-27 · DIGITAL TRANSFORMATION S04
SESSION 04 COMPLETED · REPLAY & REPOS ONLINE

2 Hours: Hand-Crafting a Structural Mechanics Solver with AI

From Vibe Coding to Harness & Loop Engineering: How structural engineers build custom analysis tools using AI Agents, Vue 3, Canvas/SVG, WASM, Docker, and Electron.

Vibe Coding PrinciplesHarness & Loop EngineeringSkills & MCP ProtocolsVue 3 + CanvasWASM Fast ComputeDocker & Electron Deployment
01

Session Replay & Live WebApp

Core Open Source Assets

NSStructure 2D Mechanics Solver

Built with Vue 3 + Canvas in-place rendering for tension-side Bending Moment Diagrams (BMD) and Shear Force Diagrams (SFD), powered by Direct Stiffness Method FEM core with dual Web container & Electron desktop delivery.

🎯 Bilibili Recording: BV1zxt467EeZ ↗

📐 Solver Project 1 (Skills-based): gitee.com/wx_c3969733c0/structural-mechanics-skills ↗

💬 Solver Project 2 (Prompt-based): gitee.com/wx_c3969733c0/structural-mechanics-prompt ↗

02

17-Slide Curriculum & Architectural Framework

MODULE 01

Paradigm Shift: Tool Users to Tool Makers

  • • Slide 01: Title & Introduction
  • • Slide 02: Commercial Software Monopolies vs Custom Tools
  • • Slide 03: True Vibe Coding: Intent-driven engineering (Humans define physics & limits, AI implements code)
MODULE 02

Three Engineering Pillars & Agent Arsenal

  • • Slide 04: Harness Engineering: Rule injection & test stubs
  • • Slide 05: Loop Engineering: Sense-Act-Observe-Repair cycle
  • • Slide 06: Skills & MCP Protocols (USB interfaces for AI)
  • • Slide 07: Structural Vibe Coding Arsenal (Guardrails, Visual Eyes, WASM, Subagents)
MODULE 03

Core Vibe Coding Best Practices

  • • Slide 08: Golden Rules:
    1. Incremental rapid iterations;
    2. Explicit physical definitions;
    3. Separation of Data, Solver, and View.
MODULE 04

Modern Full-Stack Mechanics Architecture

  • • Slide 09: Vue 3 Reactive State driving structural topology
  • • Slide 10: Canvas/SVG Tension-Side Moment rendering & Hermite curves
  • • Slide 11: Dual Delivery Matrix (Web & Native Electron .exe)
  • • Slide 12: WebAssembly (WASM) Client-side fast compute
  • • Slide 13: Node.js + Docker 20MB Lightweight Alpine image
MODULE 05

Live Demo, Pitfall Guide & Future Horizons

• Slide 14: WSL 2 × Docker live run & localhost:51674 verification

• Slide 15: Pitfall prevention (CRLF endings, zoom inverse-transform drift, load vector signs)

• Slide 16: 3 Major trends for structural engineers in the AI era

• Slide 17: Concluding remarks & Q&A

03

Structural Solver Skills Toolkit

MASTER BUNDLE

Structural Mechanics Solver Skills Bundle (ZIP)

Includes 2D Direct Stiffness Method core, tension-side moment diagram rendering, standard structural benchmark suite, and Docker/Electron dual-delivery configs.

matrix-stiffness-2d Mechanics Core

2D Planar Direct Stiffness Method FEM calculation core: Element stiffness matrix, coordinate transformation, master stiffness matrix assembly, and displacement/reaction solver.

mechanics-diagram-renderer Graphics Rendering

Civil engineering drawing conventions & Canvas renderer: Mandatory tension-side bending moments, signless BMD, parabolas, and standard support graphics.

structure-benchmark-verifier Benchmark QA

Classic structural benchmarks & automated regression suite: Simply supported beams, cantilevers, and continuous beams analytical comparisons (<0.01% tolerance).

docker-electron-delivery Dual Delivery

Dual-form packaging & deployment: 20MB lightweight Nginx containerized deployment and offline Electron desktop client scaffold.

04

Engineered Vibe Coding Prompt Sequences

Copy and paste these prompts into Claude Code, Cursor, or Codex. The full practical project is open-sourced on Solver Demo (Prompt Mode) Repo ↗.

Stage 1: Harness Rule Initialization (`CLAUDE.md`)

Guardrails
Please create a project-level specification file CLAUDE.md for our 2D Frame Structural Mechanics Solver (NSStructure 2D):

1. Civil Engineering Standards:
   - Bending Moment Diagram (BMD) MUST be strictly drawn on the TENSION side;
   - Global coordinate conventions: +X to the right, +Y upward, counterclockwise rotation is positive;
   - Axial Force Diagram (AFD): Tension and compression in distinct blue/red colors;
   - Shear Force Diagram (SFD): Plotted perpendicular to element axis.
2. Architecture Separation:
   - Data Layer (/src/types/ & /src/store/): Pure reactive state for nodes, elements, loads;
   - Solver Layer (/src/core/): Pure TypeScript Direct Stiffness Method with NO DOM/UI imports;
   - View Layer (/src/components/): Canvas/SVG coordinate transforms and interactive UI.
3. Unit Test Validation:
   - All solver edits must pass simply supported beam analytical benchmark cases.

Stage 2: Direct Stiffness Method FEM Core (`/src/core/solver.ts`)

FEM Core
Implement the 2D Direct Stiffness Method FEM solver in /src/core/solver.ts:
1. 6x6 Local Element Stiffness Matrix [k_local] with axial (EA/L) and bending stiffness (12EI/L^3, 6EI/L^2, 4EI/L, 2EI/L);
2. Transformation Matrix [T] using element inclination angle θ;
3. Global Stiffness Matrix [K_global] assembly by degree of freedom indices;
4. Boundary condition enforcement (elimination or penalty method);
5. Solve [K]{Δ} = {P} for node displacements, element internal forces (N, V, M), and reactions.

Stage 3: Tension-Side Moment Diagram & Canvas Renderer

Renderer
Render structural analysis results in-place on Canvas:
1. BMD: Strictly rendered on the TENSION side of members. Under UDL, sample 20 points along member length for quadratic parabola with translucent blue fill;
2. SFD: Render rectangular/trapezoidal hatching perpendicular to member;
3. AFD: Tension in dark blue, compression in orange-red;
4. Deformed Shape: Hermite cubic interpolation with a user-adjustable magnification factor slider.
05

Docker Containerization & Electron Desktop Client

Docker Web 20MB Alpine Lightweight Image

Deploy locally or on servers via docker-compose:

# Build and run container mapping port 51674
docker-compose up -d --build

# Access solver at
http://localhost:51674
Electron Desktop Native .exe Standalone App

Package offline desktop client via electron-builder:

# Install deps and build Windows executable
npm install
npm run build:electron

# Output binary located at: release/NSStructure-2D-Setup.exe