DEV Community

Arash Kabiri
Arash Kabiri

Posted on

I Built a Tribology Expert System from Scratch — No Frameworks, No Backend, Just Vanilla JavaScript

Industrial tribology failures — wear, friction, and lubrication problems — cost billions annually. Yet diagnosing a failed bearing or selecting the right lubricant requires expertise spanning mechanical engineering, material science, and fluid dynamics.

Most engineers don't have instant access to a senior tribologist. Instead, they rely on manually searching through thousand-page reference books, scattered spreadsheets, and trial-and-error that extends downtime from hours to days.

I experienced this firsthand as a mechanical engineering graduate. The knowledge existed — in Stachowiak & Batchelor's Engineering Tribology, the definitive reference in the field — but accessing it during an urgent failure was slow, error-prone, and frustrating.

So I asked myself: what if the textbook could think?

The Solution: TEA — Tribology Expert Advisor

TEA is a fully functional web-based decision-support system that digitizes the entire diagnostic workflow of a senior lubrication engineer.

It guides users through a 4-step adaptive process:

  1. Problem Definition — What failed? How urgent is it? Is it a new design, a breakdown, or preventive monitoring?
  2. Material & Surface Analysis — 20 mechanical and thermal properties per component, surface roughness, wear pattern identification, and microstructure analysis
  3. Lubrication System Design — Regime recommendation from 10 options, diagnostic checklist with 19 failure modes, and supply equipment specification
  4. Lubricant Selection & Film Analysis — Viscosity calculation using two methods, full EHL film thickness analysis, flash temperature calculation, wear synergism detection, and root cause analysis

At the end, it generates a comprehensive report covering everything from recommended lubricant grade to replacement intervals and condition monitoring parameters.

👉 Live Demo: stvflwers-alt.github.io/tribology
👉 Source Code: github.com/stvflwers-alt/tribology

The Technical Challenge: Pure Logic, No Shortcuts

The system has zero dependencies. No React. No Python backend. No database. Just vanilla JavaScript, HTML, and CSS — all calculations performed client-side in the browser.

This was intentional. I wanted to prove that engineering logic alone, properly structured, can deliver a production-grade expert system without the overhead of modern frameworks.

What's Inside

  • 80+ JavaScript modules — each representing a specific decision point, question, or calculation step
  • Adaptive routing — questions dynamically change based on previous answers, exactly like a real engineering consultation
  • Full Hertzian contact mechanics — point and line contact stress calculations
  • EHL film thickness — Hamrock-Dowson and Grubin formulas with proper dimensionless parameter classification
  • Flash temperature analysis — Blok-Jaeger theory with thermal regime detection
  • 19-point lubrication system diagnostic checklist — each with textbook-referenced solutions
  • 9 wear pattern families — automatically mapped to 13 failure mechanisms
  • Material compatibility matrix — lubricant versus seals, bearings, and coatings
  • Internationalization — English and Farsi supported via JSON locale files, any language can be added without code changes

The Hardest Part

The real challenge wasn't writing the formulas — it was building the decision logic.

A tribologist doesn't just plug numbers into equations. They ask follow-up questions. They eliminate possibilities. They apply conservative triage when safety data is missing.

Modeling that adaptive reasoning in pure JavaScript, with no AI or ML shortcuts, meant designing a state machine that handles:

  • Conservative triage logic: if a user answers "I don't know" to safety-critical questions, the system assumes the worst case
  • Special condition overrides: six conditions — fire risk, vacuum, precision requirements, start-stop cycles, maintenance-free operation, and ultra-high temperature — that override the normal lubrication regime selection
  • Wear synergism detection: the combined effect of corrosion and abrasion that can cause failure within hours, even with contamination levels below 0.01%

What I Learned

1. Engineering logic is a form of software architecture.
The four-step workflow in Stachowiak and Batchelor's textbook mapped surprisingly well to a state machine pattern. Good engineering thinking is already structured thinking.

2. Vanilla JS can go much further than people think.
No framework means zero build steps, instant deployment, and complete control. For a domain-heavy tool like this, a framework would have added complexity, not reduced it.

3. The gap between domain expertise and software is where value lives.
There are thousands of JavaScript developers. There are thousands of tribologists. There are very few people who can do both.

What's Next

TEA is currently in beta — fully functional through all four steps, but edge cases and unusual input combinations may surface bugs.

Planned improvements include more language translations, an extended bearing database, PDF export for reports, and potentially a backend for saving and comparing analyses.

Why This Matters

I'm a mechanical engineer who believes that deep domain expertise should be accessible — not locked behind years of specialized training or buried in thousand-page textbooks.

TEA is my attempt to package what I've learned into something useful for maintenance teams, R&D engineers, and anyone dealing with machinery reliability.

If you work in mechanical engineering, maintenance, or reliability, I'd love your feedback. Try the live demo, break it, and tell me what you think.

And if you're hiring someone who can bridge deep engineering knowledge with practical software execution — let's talk.


Arash Kabiri
Mechanical Engineer | Tribology | Intelligent Systems

LinkedIn | GitHub | stv.flwers@gmail.com

Top comments (0)