T

TaxCopilot

AI-Powered Legal Intelligence for Indian Tax Professionals.

Project

AI Legal Tech Platform

Role

Full-Stack & AI Systems Engineer

Company

AWS AI for Bharat Hackathon — Team "Don't Expecto"

GitHub
TECH STACK

Frontend

Next.jsTypeScriptTipTap Editor

Backend & Gateway

Node.jsExpressPrismaPostgreSQLJWT

AI & Retrieval

AWS BedrockGemini 2.5 FlashLangChainpgvector

Infrastructure

AWS TextractAWS S3FastAPIDocker
Project main visual

Indian tax professionals — chartered accountants, consultants, lawyers — deal with GST notices constantly. Each notice can represent thousands of rupees in disputed liability, and responding to one correctly means reading it closely, pulling up the right sections of the CGST Act or IGST Act, and drafting a formal reply that would hold up to legal scrutiny. The current workflow for most professionals is almost entirely manual. TaxCopilot was built to change that.

THE IDEA 💡

Legal AI that earns the trust of professionals

The idea came out of a real observation: general-purpose AI tools are genuinely useful for most things, but for legal work they have a specific failure mode that makes them dangerous. They confidently cite laws that don't exist. A language model that hallucinates "Section 42(3) of the CGST Act" in a court submission isn't just unhelpful — it can directly harm the professional who trusted it.

The insight behind TaxCopilot was that the fix isn't a better model, it's better architecture. If you force the model to retrieve real law before it generates anything, and then validate every citation it produces against what was actually retrieved, you can build a system that simply cannot fabricate section numbers. That became the core design principle: retrieval first, generation last.

THE PROBLEM 🎯

Manual work that eats hours per case, every day

The typical workflow goes like this: a consultant receives a notice, reads it line by line to extract the key demands and deadlines, searches for the relevant sections of whichever act applies, and then drafts a formal reply from scratch in a word processor. For a complex notice involving disputed Input Tax Credit across multiple months, this can take three to four hours — just for one case.

The technical challenge in building a solution was not "make a chatbot for tax law." It was building a pipeline that handles scanned PDFs (because government notices are almost never machine-readable), retrieves the right law with semantic precision, generates output that a professional could actually send to a tax authority, and does all of this while rigorously preventing the hallucination problem that makes legal AI dangerous in the first place.

THE SOLUTION 🚀

A retrieval-first pipeline that grounds every claim in real law

When a user uploads a notice, AWS Textract handles OCR — pulling full text even from scanned or handwritten documents. That text goes into a retrieval pipeline backed by pgvector, which does semantic search over a knowledge base seeded with Indian tax statutes. The retrieved passages become the model's context. AWS Bedrock (Nova Lite) generates the analysis and draft reply strictly from that context, and a citation validation pass then checks every Section X and Rule Y reference in the output against what was actually retrieved. If a citation isn't grounded, the system flags it and forces a retry — the user sees a clear warning if the output isn't fully verified. Gemini 2.5 Flash runs as a transparent fallback if Bedrock fails.

Smart Document OCR via AWS Textract

Handles scanned PDFs and handwritten notices — the kind of real-world government documents that most tools quietly fail on. Full text extraction happens before any AI processing begins.

Retrieval-First Legal Analysis

Every legal claim the system makes is traced back to a retrieved passage from the knowledge base. If the law isn't in the index, the system admits it — it does not fill the gap with a guess.

Citation Validation with Automatic Retry

A dedicated pass after generation checks every section and rule reference against the retrieved context. Ungrounded citations trigger a warning and a fresh generation attempt — automatically.

Agentic Legal Draft Editor

The draft mode takes the full HTML document and a plain-language instruction — "add a confidentiality clause after paragraph 3" — and returns the complete updated document with all formatting intact.

Server-Side Chat History

Conversation history is stored in Postgres, indexed by case and mode. Context is always consistent regardless of device or browser tab — the frontend never has to manage this itself.

Dual-LLM Fallback Architecture

AWS Bedrock is the primary model. On any failure, the system silently falls back to Gemini 2.5 Flash via an identical LangChain interface. From the user's perspective, nothing changes.

ARCHITECTURE 🏗️

Four focused services, each with exactly one job

TaxCopilot is deliberately split into four decoupled services so that each layer can be reasoned about, tested, and scaled independently.

The AI Microservice (Python / FastAPI) is the intelligence layer. It handles all five interaction modes — chat, decode, analyze, strategy, and draft — through a single unified /api/v1/ask endpoint. Semantic retrieval runs on pgvector using Bedrock Titan embeddings. AWS Bedrock Nova Lite is the primary LLM, with Gemini 2.5 Flash as an automatic fallback. Chat history is stored server-side in PostgreSQL so context is consistent across every request.

The Backend Service (Node.js / Express / Prisma) handles everything that isn't AI — user management, JWT authentication, case and document storage, file uploads to S3, and soft-delete with restore for cases.

The Gateway Service (Node.js / Express) sits in front of everything. It rate-limits all inbound traffic, validates JWT tokens before anything reaches the backend or AI service, and routes requests to the right downstream service. The frontend never communicates directly with any internal service — everything goes through the gateway.

The Frontend (Next.js / TypeScript) provides a workspace organized around cases. Each case has its own sidebar, document library, chat panel, and a rich-text editor built on TipTap — with a custom FontSizeExtension for professional legal document formatting.

TaxCopilot Architecture

Project Gallery

A visual walkthrough of the interface and key screens.

Gallery photo
Gallery photo
Gallery photo
DEMO 🎬
youtube • demo

Similar Projects