Skip to content

Repository files navigation

DrawingIQ

Turn an archive of engineering drawings into a knowledge base you can ask questions.

Engineering knowledge is locked inside static drawings. Experienced designers retire and take context with them; newcomers can't learn from past work; quotes are lost because nobody can quickly answer "have we built something like this before?". A database doesn't help — you have to know what to search for.

DrawingIQ reads a folder of drawing PDFs, extracts a structured record from each one (title block, classified dimensions, materials, cross-referenced parts, application notes), indexes them three ways, and puts a tool-using agent — Archie — in front of the result. Every answer cites the drawings it came from.

The drawings in this repository are synthetic: it ships a generator rather than a dataset. The pipeline, agent and UI are the real thing; the sheets are fabricated. See ADR-0005.


What it does

Extract A vision LLM reads the rendered page; a deterministic text parser reads the PDF layer. Results are merged, so vision adds detail and never loses what regex already got right.
Classify Every dimension is typed — bore, groove width, outer/inner diameter, radius, chamfer, wall thickness… — not just a bag of numbers.
Link Component callouts and recommended inserts become edges in a cross-reference graph, so "what goes with this part" is a graph query.
Search Semantic (vector), keyword (full text), structured (facets), regex/wildcard part numbers, and visual similarity of the rendered sheets.
Ask Archie plans over eight tools, refuses to claim absence without checking several ways, and cites part numbers for every claim.

Engineering highlights

  • Hybrid model routing — each drawing is scored for difficulty from its text layer before any API call (variant tables, scan-like pages, dense dimensioning, old layouts). Easy sheets go to a cheap model, hard ones to a stronger one, and a hard budget cap bounds what a full extraction run can spend.
  • Never lose data — unknown dimension classifications degrade to other with the model's own wording kept; list/number/dict type confusions from the model are coerced rather than allowed to void a record; a failed LLM call never overwrites a good record.
  • Extraction is measured, not asserted — a gold set plus a scoring harness compare extractors field by field (src/drawingiq/eval).
  • The UI was usability-tested with practising engineers; the layout, clickable part numbers and answer streaming all came out of those sessions.

Architecture

 PDFs --> Extraction pipeline --> +- SQLite registry     (structured records)
            (extractors/)         +- Chroma vector index (semantic search)
                                  +- Cross-reference graph (linked parts)
                                             |
                     Agent tools read all three (agent/tools.py)
                                             |
                        Archie (LangChain + any OpenAI-compatible LLM)
                                             |
                           Streamlit workspace (app/streamlit_app.py)

Every layer is swappable behind a small interface:

Interface Ships with Also available
Extractor heuristic (free, offline), vision_llm doc_intel (Azure Document Intelligence)
Registry SQLite DuckDB
Vector index Chroma (local files) Azure AI Search
Blob storage local filesystem Azure Blob
LLM Azure OpenAI / OpenAI any OpenAI-compatible endpoint, Ollama

Details: docs/architecture.md · docs/extraction_schema.md · decision records

Quickstart

git clone https://github.com/<you>/drawing-intelligence && cd drawing-intelligence
python -m venv .venv && . .venv/bin/activate      # Windows: .venv\Scripts\Activate.ps1
pip install -e ".[dev]"

The repo contains four synthetic sample drawings in sample_data/ — every sheet stamped "SYNTHETIC SAMPLE", covering both drawing kinds and all three title-block eras. Build the knowledge base from them and start the app:

export DATA_DIR=sample_data                        # Windows: $env:DATA_DIR="sample_data"
diq pipeline extract --extractor heuristic         # no API key needed
diq pipeline index
streamlit run src/drawingiq/app/streamlit_app.py

That gives you — with no API key at all — extraction, the registry, the cross-reference graph, visual similarity, keyword/regex/facet search and the full UI. Semantic search and Archie's chat need an LLM; add one to .env:

AZURE_OPENAI_ENDPOINT=https://<resource>.openai.azure.com/openai/v1
AZURE_OPENAI_API_KEY=<key>
AZURE_OPENAI_CHAT_DEPLOYMENTS=gpt-5-mini
AZURE_OPENAI_EMBEDDING_DEPLOYMENT=text-embedding-3-large
# or simply: OPENAI_API_KEY=sk-...

then re-run diq pipeline index to build the vector index.

Generate a bigger archive

Four sheets are enough to see the pipeline work, but not to exercise search. The generator is reproducible (fixed seed) — ask for as many as you want:

python scripts/generate_sample_archive.py --count 120   # ~1.6 MB, a few seconds
python scripts/build_gold_set.py --count 15             # refresh the eval gold set

Using your own drawings

Point DATA_DIR at a folder of PDFs and run the pipeline. The heuristic parser expects a title block with the usual cells; you will likely want to adapt _PRODUCT_*_HINTS in extractors/heuristic.py and the vocabulary in agent/product_knowledge.py to your catalogue. For anything but plain sheets, use --extractor vision_llm.

Command line

diq status                      # configuration + data health
diq pipeline extract [...]      # --extractor, --workers, --resume, --budget-usd
diq pipeline index              # (re)build vector index + graph
diq chat                        # talk to Archie without the browser
diq similar <part-number>       # nearest designs
diq export --format csv --out out.csv

Deployment

The app is a stateless web server plus the generated output/ data. The Dockerfile builds a code-only image and mounts data at runtime:

docker build -t drawingiq .
docker run -p 8000:8000 \
  -v "$PWD/output:/app/output" -v "$PWD/sample_data:/app/data" \
  -e DATA_DIR=/app/data -e APP_PASSCODE=changeme \
  drawingiq

APP_PASSCODE puts an access-code gate in front of the UI, for when the app is exposed on a shared URL.

Tests

pytest                    # 48 tests, no network needed
ruff check src tests      # lint

Repository layout

src/drawingiq/
  extractors/    heuristic · vision_llm · doc_intel · difficulty scoring
  pipeline/      extraction + indexing runner (workers, resume, budget cap)
  registry/      SQLite / DuckDB store + cross-reference graph
  index/         Chroma / Azure AI Search vector index
  agent/         Archie: agent, 8 tools, prompts, product vocabulary
  app/           Streamlit workspace + custom clickable-text component
  eval/          gold-set scoring + retrieval benchmark
scripts/         sample-archive generator, gold-set builder, audit, benchmarks
sample_data/     4 synthetic sample drawings + ground truth
docs/            architecture, schema, decision records

License

MIT — see LICENSE.

About

DrawingIQ - turns an archive of engineering drawings into a knowledge base you can ask questions, with an agent that cites every drawing behind its answer.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages