Fig. 04 · Document intelligence / Graph RAG

Cogni
Graph

Documents become a graph you can explore, then question.

My role
Solo build: the Next.js workspace, the FastAPI processing worker, retrieval and the graph view
Stack
Next.js, FastAPI, pgvector, OpenAI, S3
Status
Web app live
v0-cognigraph.vercel.app
CogniGraph landing page with the headline “Turn scattered documents into connected answers” beside a sample knowledge graph.
Captured Oct 2026 from the public page.

§ 01

The problem

Search works when you know what you are looking for. It is much weaker at the harder question: how do the people, events and claims across a pile of documents connect?

CogniGraph answers from the documents instead of from model memory, and puts the extracted graph on screen, so the context behind an answer can be inspected rather than taken on trust.

§ 02

System drawing

Solid = per request · Dashed = prepared separately

Question path · query → grounded answerDwg CG-004
  1. 01 · BrowserAsk a questionchat or split view
  2. 02 · Next.js APIResolve the userClerk session → that user’s documents only
  3. 03 · OpenAIEmbed the querytext-embedding-3-small
  4. 04 · PostgresPassages + relationshipspgvector similarity and graph lookups
  5. 05 · OutStreamed answerAI SDK
Ingestion pathupload → S3extract / OCRchunkembedentities + edges
Documents are processed once by a separate worker. A question only reads what is already stored.

§ 03

How it came together

Scroll to step through · Mine = my work

  1. Stage 1Mine

    Documents get in

    Files upload directly to S3, and a worker extracts their text, with OCR for images.

    + presigned S3 upload+ FastAPI worker: extract text / OCR
    Documents
  2. Stage 2Mine

    Text becomes vectors

    Each document is chunked by its domain mode, embedded, and stored in Postgres with pgvector.

    + domain-aware chunk size and overlap+ embeddings → pgvector
    Ingestion path
  3. Stage 3Mine

    Text becomes a graph

    Entities and the relationships between them are extracted per document and drawn as a graph you can filter and inspect.

    + entity + relationship extraction → nodes, edges+ force-directed graph view
    Graph · 3 of 12 nodes
  4. Stage 4Mine

    Answers grounded in both

    Chat retrieves passages and relationships together and streams the reply.

    - passages only+ passages + graph relationships+ streamed replies
    Ask your sources

§ 04

Decision log

  1. D-01

    Upload straight to storage

    The browser sends a file to S3 through a presigned URL that expires after 60 seconds, so documents never pass through the web server. storage.ts ↗

  2. D-02

    Process outside the request

    A FastAPI worker runs extraction as a background task and records each document as processing, completed or failed, so a slow file never holds a page open. main.py ↗

  3. D-03

    Chunk by domain

    Nine document modes, from legal to engineering, each set their own chunk size (800 to 2,500 characters) and overlap, and steer what the graph extraction looks for. main.py ↗

  4. D-04

    Retrieve from the vectors and the graph

    A question pulls the closest passages by embedding similarity and the relationships whose entities match it, both limited to the signed-in user’s documents. route.ts ↗

§ 05

What I built