Intelligent Document Processing & RAG-Powered Q&A System
Transform PDFs into actionable insights with AI-powered extraction and enterprise automation
Features β’ Architecture β’ Tech Stack β’ Getting Started β’ API Reference β’ Deployment
DocPilot AI is an end-to-end intelligent document processing platform that combines Retrieval-Augmented Generation (RAG) with structured data extraction. It enables users to upload PDF documents (invoices, BOQs, contracts), ask natural language questions, and extract structured JSON data for downstream automation.
- π€ PDF Ingestion β Upload and process PDF documents with automatic text extraction
- π¬ RAG-Powered Q&A β Ask questions about your documents with AI-generated answers and source citations
- π Structured Extraction β Extract machine-readable JSON (invoice details, BOQ line items) using schema-based parsing
- π Enterprise Automation β Trigger n8n workflows to sync extracted data with Airtable, Jira, and Email
- Parse PDFs page-by-page with text extraction
- Semantic chunking (800 tokens with 120-token overlap)
- Vector embeddings using
BAAI/bge-small-en-v1.5model via FastEmbed - FAISS index storage for fast similarity search
- Natural language queries on uploaded documents
- Top-K similarity search for context retrieval
- LLM-powered answer generation via Groq API
- Source citations for answer verification
| Schema Type | Extracted Fields |
|---|---|
| Invoice | Vendor name, Invoice number, Date, Total amount, GSTIN |
| BOQ | Item count, Line items, Sample entries |
- Webhook-triggered workflows on successful extraction
- Airtable record creation for audit trails
- Automatic Jira ticket creation
- Email notifications to stakeholders
flowchart TB
%% ================
%% Swimlanes Style
%% ================
subgraph Client["π₯οΈ Client Layer"]
U[π€ User]
FE["DocPilot UI<br/>Next.js (Vercel)"]
U --> FE
end
subgraph API["βοΈ Service Layer"]
BE["DocPilot Backend<br/>FastAPI (Render)"]
PDF["PDF Parser<br/>+ Chunker"]
EMB["Embeddings Engine<br/>FastEmbed (BGE)"]
VS[("Vector Store<br/>FAISS Index")]
LLM["LLM Inference<br/>Groq API"]
end
subgraph Automation["π Automation Layer"]
N8N["n8n Orchestrator<br/>DocOps Workflow"]
AIR[("Airtable<br/>DocOps DB")]
JIRA["Jira Cloud<br/>Ticketing"]
MAIL["π§ Email Service<br/>SMTP/Gmail"]
end
%% Client -> Backend
FE -->|"POST /ingest"| BE
FE -->|"POST /ask"| BE
FE -->|"POST /extract"| BE
%% Ingestion
BE --> PDF --> EMB --> VS
VS -->|"doc_id"| BE --> FE
%% RAG Ask
BE -->|"Search chunks"| VS --> BE
BE -->|"Prompt + Context"| LLM --> BE --> FE
%% Extraction
BE -->|"Schema Prompt"| LLM -->|"Structured JSON"| BE --> FE
%% Automation Trigger
BE -->|"Webhook Event"| N8N
N8N --> AIR
N8N --> JIRA
N8N --> MAIL
N8N -->|"jira_key + status"| BE --> FE
flowchart LR
%% =========================
%% DocPilot AI Architecture
%% =========================
%% --- Actors ---
U[π€ User / Stakeholder]
%% --- Frontend ---
FE["DocPilot UI<br/>Next.js (Vercel)"]
%% --- Backend ---
BE["DocPilot API<br/>FastAPI (Render)"]
PDF["π PDF Parser + Chunker"]
EMB["π§ Embeddings Engine<br/>FastEmbed"]
VS[("πΎ Vector Store<br/>FAISS Index")]
LLM["π€ LLM Inference<br/>Groq API"]
%% --- Automation ---
N8N["β‘ n8n Orchestrator<br/>DocOps Workflow (Render)"]
AIR[("π Airtable<br/>DocOps DB")]
JIRA["π« Jira Cloud<br/>Create Issue"]
MAIL["π§ Email Notification<br/>SMTP/Gmail"]
%% =========================
%% User -> Frontend
%% =========================
U -->|"Upload PDF / Ask Question / Extract"| FE
%% =========================
%% Frontend -> Backend
%% =========================
FE -->|"POST /ingest<br/>PDF Upload"| BE
FE -->|"POST /ask<br/>(doc_id, query)"| BE
FE -->|"POST /extract<br/>(doc_id, schema)"| BE
%% =========================
%% Ingestion Pipeline (RAG)
%% =========================
BE -->|"Extract Text"| PDF
PDF -->|"Chunk Text"| EMB
EMB -->|"Store vectors + chunks"| VS
VS -->|"Return doc_id"| BE
%% =========================
%% RAG Query Pipeline
%% =========================
BE -->|"Top-k similarity search"| VS
VS -->|"Relevant chunks"| BE
BE -->|"Prompt + Context"| LLM
LLM -->|"Answer + Sources"| BE
BE -->|"Response to UI"| FE
%% =========================
%% Structured Extraction Pipeline
%% =========================
BE -->|"Schema-based extraction<br/>Invoice/BOQ JSON"| LLM
LLM -->|"Structured JSON output"| BE
BE -->|"Show extracted fields"| FE
%% =========================
%% Automation Trigger (n8n)
%% =========================
BE -->|"POST Webhook<br/>doc_id + extracted_json"| N8N
%% =========================
%% DocOps Workflow (n8n)
%% =========================
N8N -->|"Create Record"| AIR
N8N -->|"Create Jira Task"| JIRA
N8N -->|"Update Airtable (jira_key/status)"| AIR
N8N -->|"Send Summary Email"| MAIL
%% =========================
%% Return workflow output back
%% =========================
N8N -->|"Workflow status + jira_key"| BE
BE -->|"UI Notification<br/>Jira created"| FE
| Technology | Purpose |
|---|---|
| Next.js 16 | React framework with App Router |
| React 19 | UI library |
| TailwindCSS 4 | Utility-first styling |
| TypeScript | Type safety |
| Vercel | Deployment platform |
| Technology | Purpose |
|---|---|
| FastAPI | High-performance Python API framework |
| FAISS | Vector similarity search |
| FastEmbed | Lightweight embeddings (BGE-small-en-v1.5) |
| pypdf | PDF text extraction |
| Groq | LLM inference (fast, affordable) |
| Render | Deployment platform |
| Technology | Purpose |
|---|---|
| n8n | Workflow orchestration |
| Airtable | Document records storage |
| Jira Cloud | Task/ticket automation |
| Email (SMTP) | Stakeholder notifications |
- Node.js 18+ (for frontend)
- Python 3.10+ (for backend)
- Groq API Key (get one at console.groq.com)
# Navigate to backend directory
cd backend
# Create virtual environment
python -m venv .venv
# Activate virtual environment
# Windows:
.venv\Scripts\activate
# macOS/Linux:
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Create .env file
cp .env.example .env
# Edit .env and add your GROQ_API_KEY
# Run the server
uvicorn app.main:app --reload --port 8000# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Create .env.local file
cp .env.example .env.local
# Edit .env.local and set NEXT_PUBLIC_API_URL
# Run the development server
npm run devGROQ_API_KEY=your_groq_api_key_hereNEXT_PUBLIC_API_URL=http://localhost:8000- Local:
http://localhost:8000 - Production:
https://your-backend.onrender.com
Upload and process a PDF document.
Request:
curl -X POST "http://localhost:8000/ingest" \
-F "file=@invoice.pdf"Response:
{
"doc_id": "79bc66af-1234-5678-abcd-ef1234567890"
}Ask a question about an uploaded document.
Request:
{
"doc_id": "79bc66af-1234-5678-abcd-ef1234567890",
"query": "What is the total amount?"
}Response:
{
"answer": "The total amount on this invoice is βΉ59,000.",
"sources": [
{
"chunk_id": 0,
"text": "Total Amount: βΉ59,000..."
}
]
}Extract structured data from a document.
Request:
{
"doc_id": "79bc66af-1234-5678-abcd-ef1234567890",
"schema_type": "invoice"
}Response:
{
"vendor_name": "XYZ Solutions Pvt. Ltd.",
"invoice_number": "INV-2024-001",
"invoice_date": "24 Jan 2024",
"total_amount": "βΉ59,000",
"gstin": "27AABCX1234A1Z5"
}Health check endpoint.
Response:
{
"status": "ok"
}- User uploads PDF from UI
- Frontend calls
POST /ingest - Backend extracts text, chunks it, generates embeddings
- Stores vectors in FAISS index
- Returns
doc_idfor future queries
- User asks a natural language question
- Frontend calls
POST /askwithdoc_idandquery - Backend searches FAISS for relevant chunks
- Builds prompt with context and calls Groq LLM
- Returns answer with source citations
- User clicks "Extract" and selects schema (Invoice/BOQ)
- Frontend calls
POST /extract - Backend performs schema-based extraction
- Returns structured JSON response
- After successful extraction, backend triggers n8n webhook
- n8n creates Airtable record with extracted data
- n8n creates Jira ticket for follow-up
- n8n sends email notification to stakeholders
- Returns workflow status back to UI
- Push code to GitHub
- Connect repository to Vercel
- Set Root Directory to
frontend - Add environment variable:
NEXT_PUBLIC_API_URL - Deploy
- Push code to GitHub
- Create new Web Service on Render
- Set Root Directory to
backend - Build Command:
pip install -r requirements.txt - Start Command:
uvicorn app.main:app --host 0.0.0.0 --port $PORT - Add environment variable:
GROQ_API_KEY - Deploy
- Create new Web Service with n8n Docker image
- Configure webhook URL
- Set up Airtable, Jira, and Email credentials
- Import workflow template
docpilot-ai/
βββ backend/
β βββ app/
β β βββ __init__.py
β β βββ main.py # FastAPI endpoints
β β βββ rag.py # RAG pipeline (ingest, search)
β β βββ extract.py # Structured extraction logic
β β βββ llm.py # Groq LLM integration
β β βββ schemas.py # Pydantic models
β βββ data/ # Stored PDFs and FAISS indexes
β βββ Dockerfile
β βββ requirements.txt
β βββ .env.example
β
βββ frontend/
β βββ src/
β β βββ app/ # Next.js App Router pages
β β βββ components/ # React components
β β βββ lib/ # Utility functions
β βββ public/
β βββ package.json
β βββ .env.example
β
βββ README.md
- PDF upload and text extraction
- RAG-powered Q&A with citations
- Invoice structured extraction
- BOQ structured extraction
- LLM-enhanced extraction (beyond regex)
- n8n webhook integration
Built with β€οΈ by Kaushal
DocPilot AI β From documents to decisions, powered by intelligence.