Mohammad Houda
All work
AI Document Intelligence2025

DocAgent

DocAgent transforms raw construction documents into an intelligent query system. Files flow through a 7-stage async pipeline parse, chunk, embed, classify, profile, extract, store producing both semantic search vectors and structured SQL extractions. An AI agent with 5 flexible tools then answers business questions: aggregating costs, comparing budgets against actuals, listing line items, or searching document text. Every number in an answer is fetched from SQL and never fabricated; the agent does no arithmetic itself. Document profiles stored as JSONB supply per-document query hints and tool suggestions that guide the agent's strategy, and answers render as typed cards tables, timelines, fact grids, party cards so the frontend can stay predictable while the questions stay open-ended.

At a glance

7Pipeline stages
5Agent tools
1,536Embedding dimensions

Built with

Next.js · TypeScript · Express · Node.js · OpenAI · PostgreSQL · pgvector · BullMQ · Redis · Drizzle ORM

Interface

03 views

Engineering notes

  1. 01

    7-stage ingestion pipeline (parse → chunk → embed → classify → profile → extract → store) runs fully async via BullMQ + Redis, so the UI stays responsive throughout

  2. 02

    Semantic search via pgvector HNSW index over 1,536-dim OpenAI embeddings finds meaning across documents, not just keyword matches

  3. 03

    Deterministic Excel extraction: the LLM infers a column schema once, then regex processes every row zero tokens per row after the first pass

  4. 04

    The agent picks between 5 tools per question and offloads all arithmetic to compute_result, so no number in an answer is ever hallucinated

  5. 05

    A unified JSONB document profile stores AI-generated query hints and suggested tools, giving the agent a per-document strategy

  6. 06

    Semantic category matching embeds user terms and resolves them to the nearest sheet or section name by cosine distance, handling abbreviations, synonyms, and typos

  7. 07

    Structured JSON answers render as typed UI cards (key_facts, table, timeline, list, parties) a predictable shape over open-ended questions

Architecture

Interactive click any node

Loading diagram…

Next project

Hope Link

Humanitarian Platform