# Engineering drawings to SAP-ready bills of material

> Mirai Minds built a document AI system for an Indian public-sector refinery that turns engineering drawings into SAP-ready material-master data. Gemini finds the bill of materials on PDF, scanned or CAD drawings and extracts every row. An engineer reviews each row beside the drawing and exports a 16-column SAP upload sheet. Built over ten months; handed over in 2026.

Client: Indian public-sector refinery (Oil refining) · Status: delivered · Year: 2025–2026 · Written by Sagar Davara

## Results

- **SAP material-master fields per extracted row:** 16 — source: Delivered export specification, 2026
- **SAP picklist values enforced in the review screen:** ≈370 — source: Delivered system specification, 2026

## Key facts

- **Inputs:** PDF, TIFF and JPEG scans, DWG and DXF drawings, up to 500 MB
- **Extraction:** Gemini: fast model first, premium model on a reviewer's request
- **Review:** Split-pane workspace; an engineer checks every row
- **Output:** 16-column SAP material-master upload sheet
- **Validation:** About 370 SAP picklist values; material type limits valuation class
- **Timeline:** September 2025 to July 2026, then handover


## The problem

Equipment drawings, parts lists and bills of quantities reach the refinery as PDFs, scans, TIFFs and DWG or DXF CAD files, often with hundreds of line items each. Every item had to be keyed into SAP with the right material-master fields: material group, valuation class, MRP type, purchasing group, profit center and more. Skilled engineers were doing clerical work, and a single wrong field meant a bad record in procurement.

## What we built

A closed web application where an engineer uploads a drawing of up to 500 MB and gets back an editable, SAP-ready table.

- **Extraction.** Gemini locates the bill-of-materials table on the drawing and extracts every row, plus the drawing number, item numbers and maker. Roughly 200 lines of engineering rules steer it: keep the reading order, never drop a row, preserve gaps in part numbering, and shorten names with a dictionary for more than 20 component types so text fits SAP's length limits. When the parts list omits a part number, the model reads the callouts on the drawing itself.
- **Review.** A split-pane workspace shows the drawing next to the extracted table. Only the fields a reviewer touches change, and conflicting edits are rejected rather than merged. A reviewer can re-run extraction on the premium model with a plain-English hint, or compose SAP short and long texts from drag-and-drop variables.
- **SAP output.** Cascading validation encodes about 370 SAP picklist values; choosing a material type narrows valuation class to the legal values. Every picklist also has an "Other" option, validated on the server. One click builds the 16-column upload sheet in the browser.

## How it works in production

Progress streams to every open browser tab over Server-Sent Events: queued, downloading, extracting, persisting, completed. Large uploads are staged for 24 hours and promoted to permanent storage without a second upload. If the model returns malformed output, the parser's error goes back to the model for a retry, and each stage fails on its own with a precise message. Accounts are created by administrators only; there is no public sign-up, and deleted records can be recovered.

We built it over ten months, from September 2025 to July 2026, refining the extraction rules on the refinery's real drawings, and handed it to the client's IT partner. The same pattern of extraction, human review and system-ready output fits invoices, datasheets and inspection reports; see [custom LLM and document AI](/services/custom-llm-development) and our [manufacturing work](/industries/manufacturing-industrial).

## What we'd change

- **Log reviewer corrections as accuracy data from day one.** Corrections are the best measure of extraction quality. With them logged per field from the start, we could publish field-level accuracy here; we can't yet.
- **Plan direct SAP integration early.** The Excel upload sheet was the right first step, but creating records through SAP interfaces removes a manual hop, and the design is easier with it in mind.
- **Connect corporate sign-on sooner.** Wider rollout across the organization needs single sign-on, and it is cheaper to add before users arrive than after.

## Stack

- **AI:** Google Gemini (fast and premium models)
- **Backend:** FastAPI (async), MySQL 8.4, Alembic, Amazon S3
- **Frontend:** Vue 3, Vite, Tailwind CSS 4, PrimeVue
- **Delivery:** Server-Sent Events, JWT with role-based access, Firebase Hosting

## Frequently asked questions

### Why keep a person reviewing every row?

Because one wrong field creates a bad material-master record that spreads through procurement. The system makes review fast rather than optional: the drawing sits beside the table, edits save field by field, and SAP picklists only accept legal combinations.

### Why use two Gemini models instead of one?

Cost and control. A fast, cheaper model does the first pass on every drawing. The premium model runs only when a reviewer asks, with a plain-English hint such as 'the quantity column is on the right'. Model cost is tracked per document.

### Does it write to SAP directly?

Not in this version. It exports the 16-column material-master upload sheet that the SAP team loads. Creating records directly through SAP's BAPI or OData interfaces is the natural next phase.

### Who runs the system now?

The client's IT partner. We consolidated the code into a single repository for handover in May 2026 and finished development in July 2026.


---

Canonical: https://www.miraiminds.co/work/refinery-drawings-to-sap-bom
Last updated: 2026-09-23
Publisher: Mirai Minds LLP, 906 Sarthana Business Hub, Nana Varachha, Surat, Gujarat 395013, India. hello@miraiminds.co
