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.
Next.js · TypeScript · Express · Node.js · OpenAI · PostgreSQL · pgvector · BullMQ · Redis · Drizzle ORM
7-stage ingestion pipeline (parse → chunk → embed → classify → profile → extract → store) runs fully async via BullMQ + Redis, so the UI stays responsive throughout
Semantic search via pgvector HNSW index over 1,536-dim OpenAI embeddings finds meaning across documents, not just keyword matches
Deterministic Excel extraction: the LLM infers a column schema once, then regex processes every row zero tokens per row after the first pass
The agent picks between 5 tools per question and offloads all arithmetic to compute_result, so no number in an answer is ever hallucinated
A unified JSONB document profile stores AI-generated query hints and suggested tools, giving the agent a per-document strategy
Semantic category matching embeds user terms and resolves them to the nearest sheet or section name by cosine distance, handling abbreviations, synonyms, and typos
Structured JSON answers render as typed UI cards (key_facts, table, timeline, list, parties) a predictable shape over open-ended questions