33med

title: "Orchestrating GROMACS via Node.js"
description: "How 33MED is bridging the gap between modern web architectures and legacy Fortran/C++ physics engines to build a commercial-grade autonomous biotech infrastructure."
date: 2024-05-24
author: "33MED Engineering"
category: "ImmuNav & Computational Biology"

Orchestrating GROMACS via Node.js: Bridging the Gap Between Web Architecture and Legacy Physics Engines

The modern biotechnology stack is fractured. On one side, we have highly performant, massively scalable web architectures driven by Node.js, React, and NoSQL. On the other, we have the foundational bedrock of computational biology: decades-old physics engines, molecular dynamics simulators, and cellular models written in Fortran, C++, and R.

Historically, bridging this gap required layers of academic infrastructure bloat—heavy Python wrappers, complex RabbitMQ message brokers, and convoluted database schemas. At 33MED, we are stripping away the bloat.

To power ImmuNav, our foundational computational immunology engine, we have engineered a lean, highly performant Node.js, MongoDB, and React ecosystem. By directly orchestrating legacy binaries via native Node.js child processes, we are transforming isolated scientific tools into a cohesive, autonomous swarm capable of driving rapid commercial drug discovery and surgical robotics modeling.

Here is an inside look at the engineering architecture powering Phase 1 of ImmuNav.


🧬 The Commercial-Safe Computational Matrix

Building a commercial SaaS platform requires strict adherence to licensing constraints. Many popular models, such as AlphaFold 3, carry non-commercial restrictions that poison the well for enterprise utilization.

To maintain total commercial sovereignty, the ImmuNav backend completely bypasses restricted wrappers. Instead, our Node.js infrastructure natively orchestrates a highly curated matrix of 100% free, open-source, and commercial-safe tools using native CLI execution:


🏗️ The Native Node/Mongo Swarm Engine

We have eliminated the need for dedicated message brokers like RabbitMQ or Kafka. In our architecture, MongoDB acts as a durable, atomic task queue using standard query modifiers. This keeps the stack lean and maximizes I/O efficiency.

Document-Driven State Management

Our database architecture relies on two foundational collections to track our AI agents and manage the execution pipeline:

// Collection: agents
{
  _id: ObjectId("66654a..."),
  role: "BioinformaticsOperator",
  status: "active",
  globalObjective: "Identify molecular targets to halt syndesmophyte growth and spine fusion.",
  humanGuidanceOverride: "Focus explicitly on small-molecule inhibitors targeting IL-17 pathways.",
  lastPulse: ISODate("2024-05-24T22:00:00Z")
}

// Collection: tasks (The Lightweight Queue)
{
  _id: ObjectId("66654b..."),
  agentId: ObjectId("66654a..."),
  tool: "gromacs",
  status: "pending_review",
  payload: {
    inputFiles: ["target_sequence.fasta"],
    md_params: { nsteps: 50000, dt: 0.002, integrator: "md" } // Validated dynamically via Zod
  },
  humanSignOff: { isApproved: false, actionedAt: null },
  logs: [], 
  outputMetadata: {}
}

The Background Execution Loop

Within our Simulation Worker, a lightweight, recursive Node.js polling loop queries MongoDB for actionable jobs. Before touching the local hardware, it respects global pause states and verifies mandatory human approvals. When a job is cleared, it natively spawns the legacy binary:

import { spawn } from 'child_process';

async function processQueue() {
  // 1. Structural Check: Ensure the swarm isn't globally paused
  const globalStatus = await db.collection('settings').findOne({ key: 'swarm_status' });
  if (globalStatus?.isPaused) return setTimeout(processQueue, 5000);

  // 2. Fetch the next executable, human-approved task atomically
  const task = await db.collection('tasks').findOneAndUpdate(
    { status: 'queued', 'humanSignOff.isApproved': true },
    { $set: { status: 'processing', startedAt: new Date() } },
    { sort: { createdAt: 1 }, returnDocument: 'after' }
  );

  if (!task.value) return setTimeout(processQueue, 2000); 

  try {
    // 3. Native binary execution via Node Child Processes
    const binaryProcess = spawn(getToolBinary(task.value.tool), task.value.payload.cliArgs);
    
    // Stream runtime stdout/stderr directly into MongoDB
    binaryProcess.stderr.on('data', (data) => {
      db.collection('tasks').updateOne(
        { _id: task.value._id }, 
        { $push: { logs: data.toString() } }
      );
    });

    binaryProcess.on('close', async (code) => {
      const finalStatus = code === 0 ? 'completed' : 'failed';
      await db.collection('tasks').updateOne({ _id: task.value._id }, { $set: { status: finalStatus } });
      processQueue(); // Instantly jump to the next job
    });

  } catch (error) {
    await db.collection('tasks').updateOne({ _id: task.value._id }, { $set: { status: 'failed', error: error.message } });
    processQueue();
  }
}

📡 Automated Data Ingestion & LLM Structuring

Models are only as good as the data they consume. 33MED’s Data Ingestion Agents run as automated background loops, harvesting raw literature and utilizing Large Language Models (LLMs) to structure biological insights.

We target the NCBI Entrez E-utilities (PubMed) and the arXiv XML feed, securing commercial-safe, high-throughput access (up to 10 requests/second via native API keys). When raw XML text lands in the Node backend, it bypasses intermediate parsers and is passed directly to the Google Gemini SDK (@google/generative-ai).

By utilizing strict system prompts, we force the LLM to act as a structured data pipeline rather than a conversational agent:

const systemPrompt = `You are an expert computational immunologist. Analyze the provided scientific text. 
Extract any explicit molecular targets, binding affinities, genetic expressions, or pathways related to Ankylosing Spondylitis.
Return the output strictly in the following JSON format:
{
  "targetProtein": "string",
  "associatedCytokines": ["string"],
  "observedEffect": "string",
  "confidenceScore": 0.00
}`;

const result = await geminiModel.generateContent([systemPrompt, rawPaperText]);
const structuredData = JSON.parse(result.response.text());
await db.collection('knowledge_base').insertOne(structuredData);

🎛️ The Human-In-The-Loop (HITL) React Control Center

To guarantee absolute executive control over our AI agents without modifying code or manually adjusting environment variables, ImmuNav is governed by a Swarm Management Dashboard built in React.

The interface serves three critical functions:

  1. The Global Interrupter State: A unified kill-switch. Toggling the "Global Pause" updates settings.swarm_status in MongoDB. Because the Node worker polls this boolean before execution, the entire background swarm safely halts without corrupting mid-calculation physics processes.
  2. The Guidance Injector: Engineers can inject high-level directional pivots via a clean text interface. This string is appended to the agent's database document and is dynamically merged into system instructions during the next Gemini generation cycle.
  3. The Mandatory Approval Gate: When an agent designs a simulation run (e.g., GROMACS md_params), the task enters a pending_review state. Engineers can view, verify, and manually tweak the Zod-validated JSON parameters directly in the UI. Clicking Approve transitions the state to queued, seamlessly passing the job down to the local hardware execution loop.

🧪 Micro-Dataset Testing: Fast Local Safety Loops

Executing heavy computational physics locally can rapidly exhaust API quotas or crash machines under thermal load. To build, test, and iterate safely, the 33MED engineering team adheres to a strict micro-testing protocol:

The Future of Autonomous Biotech Infrastructure

By tightly coupling the speed and developer experience of Node.js with the raw computational power of C++ and Fortran physics engines, 33MED is redefining how in-silico research is conducted. We are moving away from manual, isolated command-line operations toward a scalable, autonomous, and commercially viable computational immunology stack.

ImmuNav Phase 1 is just the beginning.