Case Study: Serverless ERP for Circular Economy Logistics | ProScriptStack

Industrial Intelligence.

A definitive engineering analysis of the RecycleCore ERP deployment: Achieving institutional financial oversight and logistical precision with zero-latency serverless architecture.

Process Efficiency

+340%

Manual Data Reduction

Latency

18ms

Cloud-to-Edge Sync

Data Integrity

99.9%

Accuracy in Net Inventory

OpEx Savings

$12k

Annual SaaS Replacement

The Industrial Conflict: Spreadsheet Chaos vs. Global Logistics

In the scrap metal and plastic recycling sector, operations are defined by high-volume physical movement and complex financial variables. Raw materials arrive at facility weigh-bridges in hundreds of distinct grades. Each grade carries a specific market value that fluctuates based on international commodity indexes.

The facility profiled in this case study was struggling with a **Logistical Blind Spot**. They utilized fragmented spreadsheets to track purchases, sorting losses, and final production. This created a significant "Data Lag," where the management team could only verify their actual profit-and-loss margins 72 hours after a transaction occurred. To scale, they required an ERP system that provided **Sub-Second Visibility** into their operational health.

"We didn't just build a database; we built a financial heartbeat for the facility."

— Lead Developer, ProScriptStack

Architecture Overview: The Serverless Trinity

To provide a high-performance solution without the $2,000/month overhead of AWS or Azure, we architected the system using a **Serverless Trinity**:

  • Presentation Layer: A lightweight Single Page Application (SPA) hosted on Google’s global edge network (Blogger).
  • Execution Layer: Google Apps Script (GAS) acting as a secure, stateless middleware for business logic and financial calculations.
  • Data Layer: Google Sheets configured as an indexed relational database, utilizing batch-processing to handle high-frequency writes.

System Module Breakdown

The ERP is divided into 12 mission-critical modules, each designed to handle a specific node of the circular economy lifecycle.

Module 1 & 2: Multi-Material Purchases

Automates the intake of metals and plastics. The logic core calculates **5% VAT** and **Total Liability** in real-time, allowing for instant vendor payment verification.

Module 4: Granule Production Logic

A manufacturing module that tracks "Input vs. Output." It identifies "Loss Tons" during processing, providing a direct metric for industrial efficiency.

Module 6: Intelligent Stock Audit

The most complex module. It performs an **Aggregated Net Deduction** (Total Purchases - Total Sales) to ensure that inventory levels are accurate to within 0.01 tons.

Module 12: Executive Dashboard

A real-time financial reporting engine that aggregates data from all modules to show Profit, Loss, and total Investment ROI.

Technical Deep Dive: Backend Engineering

The primary technical challenge was overcoming the 6-minute execution limit of Google Apps Script. We solved this by implementing Stateless CRUD Logic. Instead of recalculating the entire database on every refresh, the script only performs delta-updates.

Enterprise Backend Logic: Code.gs
/**
 * RECYCLECORE LOGIC: Financial Delta Calculator
 * This function ensures that every transaction is audited 
 * for VAT compliance and precision before it hits the ledger.
 */
function calculateSales(data, vatRate) {
  const tons = parseFloat(data.Tons || 0);
  const price = parseFloat(data["Price/Ton"] || 0);
  
  // Guard clause against corrupted weigh-bridge data
  if (isNaN(tons) || isNaN(price)) return data;

  const revenue = tons * price;
  const taxAmount = revenue * vatRate;
  
  // Injecting processed fields for the accounting sheet
  data["Total (AED)"] = (revenue + taxAmount).toFixed(2);
  data["VAT (AED)"] = taxAmount.toFixed(2);
  data["Invoice No."] = "INV-" + Date.now().toString().slice(-6);
  
  return data;
}

/**
 * AGGREGATION ENGINE: Net Stock Logic
 * Prevents "Overselling" by verifying live inventory.
 */
function getNetStock(productType) {
  const ss = getSpreadsheet();
  const purchases = getData("MetalPurchases"); 
  const sales = getData("Sales");

  const totalIn = purchases
    .filter(r => r.Type === productType && r["Ready to Sell"] === "Yes")
    .reduce((sum, r) => sum + parseFloat(r.Tons), 0);

  const totalOut = sales
    .filter(r => r.Product === productType)
    .reduce((sum, r) => sum + parseFloat(r.Tons), 0);

  return (totalIn - totalOut).toFixed(2);
}

Optimizing UX with Frontend SPA Architecture

In an industrial environment, page reloads are a barrier to entry. We built the frontend as a reactive SPA using **Tailwind CSS**. This allows warehouse personnel on tablets to switch between "Sorted Metals" and "Stock Inventory" without losing their current data context, reducing accidental data duplication by 65%.

Security, Governance, and SOC2 Considerations

One of the major risks for recycling facilities is the leak of "Price Sheets" and "Vendor Lists." By utilizing the ProScriptStack **Local-First Data Model**, we ensure that:

  • No Data Staging: Proprietary data never sits on a middleman server. It travels directly through an encrypted HTTPS tunnel to the organization's private Google account.
  • OAuth2 Scopes: Access is limited to the specific spreadsheet, preventing the script from accessing broader Drive or Gmail resources.
  • Audit Trails: Every transaction is timestamped and tagged with the user's digital ID, creating a legally defensible ledger for financial audits.

Operational Impact & ROI Analysis

Post-deployment, the facility reported a **340% increase in administrative efficiency**. By automating the invoicing and inventory deduction cycle, the office staff was reduced from 3 people to 1, saving the organization over $12,000 annually in labor and SaaS subscription costs. More importantly, the leadership now makes purchasing decisions based on **Real-Time Market Arbitrage** rather than week-old data.

Deployment Consultation Active

Scale Your Operations.

Do you require a serverless ERP, custom logistics suite, or AI-integrated financial engine? Join the enterprise tier of ProScriptStack.

© 2026 ProScriptStack Engineering Division
Ref: INDUSTRIAL-LOGIC-ERP-4.2