PROJECT STUDY

RAG Finance

Keep the sources close to the answer.

A research assistant for Indonesian finance and tax regulations that answers from indexed sources, cites article and page evidence, and says so when the evidence falls short.

Explore the build
Illustration of the research workspace: a sample regulation question, a source-grounded answer with numbered chips for an official source and article evidence, and a source library card with an article-level citation and a link to open the source.
Original interface illustration · Synthetic demo data.View larger

At a glance

Industry
Finance and tax research
Capabilities
6
Technologies
12
Year
2026
0.96 hit@5

Retrieval on a labelled benchmark of 25 questions over 693 regulatory chunks

The challenge

Finance and tax teams work with rules spread across official portals, lengthy documents and amendments.

Indonesian regulations are often amended article by article, so finding a plausible answer is easier than checking which provision supports it and whether later wording changes the conclusion.

A useful research assistant needs to show its evidence, preserve the context around an article and admit when the indexed sources do not answer the question.

What we built

RAG Finance combines a searchable regulatory library with a research chat workspace.

Questions in Indonesian or English

Conversation context and query planning turn everyday wording into targeted searches across finance or tax sources

Questions in Indonesian or English

Conversation context and query planning turn everyday wording into targeted searches across finance or tax sources

Answers with references

Article and page evidence, document metadata and official-source links let the user inspect the material behind a grounded answer

Amendment-aware research

Retrieval considers document status and brings in later amended wording found in the index. It distinguishes the old provision from the indexed change

A reusable document library

Resources and hybrid search work independently of the chat, with filters for source, domain, document type and status

Controlled ingestion

Source adapters cover Bank Indonesia, OJK, SIKePO, DJP and the Ministry of Finance, alongside administrator uploads. File validation, incremental processing and reusable embeddings avoid repeating unchanged work

Tools for review

Administrators can inspect ingestion progress and retrieval traces, compare search results and configure model providers

How it works

  1. Collect and structure sources

    Crawlers for five official sources and administrator uploads feed one ingestion pipeline, kept apart from the interface. Each file is validated and hashed, OCR runs only on pages without a text layer, and every new document version is written with its chunks and vectors in one transaction.

  2. Deterministic query analysis, with an optional language-model planner, turns a question into targeted searches. Vector search, full-text search and direct regulation-number lookups are combined through weighted rank fusion.

  3. Check the evidence

    A sufficiency check judges whether the selected material supports each part of the question. Amendment lookup then places later indexed wording beside the older article it changes.

  4. Stream a cited answer

    The answer streams to the Next.js workspace over Server-Sent Events, and the server validates every citation marker against the evidence. The interface labels each answer as grounded, hybrid, general or no-answer; when the optional general-knowledge fallback is enabled, that answer is visibly labelled and does not acquire official-source status simply because it appears in the same conversation.

Engineering insights

RAG Finance is a modular monolith: one FastAPI service over a single PostgreSQL database that holds documents, versions, legal-structure chunks, per-model embeddings, full-text indexes, conversations and a retrieval trace for every question. The language model explains; retrieval, rules and server-side checks decide what counts as evidence.

Stack by layer

Frontend
  • Next.js
  • React
  • TypeScript
  • Tailwind CSS
  • shadcn/ui
  • Radix UI
  • TanStack Query
  • react-markdown
  • next-themes
  • Lucide
  • Sonner
Backend
  • Python
  • FastAPI
  • Uvicorn
  • Pydantic
  • SQLAlchemy
  • Psycopg
  • Alembic
  • HTTPX
  • Beautiful Soup
  • lxml
  • pypdfium2
  • python-docx
  • cryptography
Data
  • PostgreSQL
  • pgvector
  • PostgreSQL full-text search
  • Snowball stemmer
AI
  • OpenAI-compatible chat APIs
  • Anthropic Messages API
  • OpenRouter
  • Google Gemini
  • FastEmbed
  • ONNX Runtime
  • Tesseract OCR
Infrastructure
  • Docker
  • Docker Compose
  1. The evidence gate decides before the model

    A sufficiency gate judges each part of a question. When no part passes, the service returns a deterministic no-answer with the closest sources and never calls the answer model, and general-knowledge answers stay behind a flag that is off by default

  2. Citations are checked on the server

    After generation, citation markers that point at no evidence item are removed, and regulation or article numbers that no evidence chunk, title or succession link contains are flagged as unverified. The result is stored with the answer's retrieval trace

  3. Amendments resolved by rules, not the model

    Indonesian laws are often amended by restating articles inside later regulations, so the retriever looks up each evidence article's lineage in one SQL query. A restatement counts only from a regulation of the same rank whose wording overlaps the older article above a calibrated threshold, and every decision is traced

  4. One vector table, one index per model

    Embeddings sit in a dimension-agnostic column keyed by model, and each model gets its own partial HNSW index, so a new embedding model is indexed beside the old one without a schema migration. Vectors are reused by content hash across versions and sources

  5. Chunks follow the structure of the law

    The chunker segments regulations along BAB, Bagian, Paragraf and Pasal, then splits long articles at ayat, huruf or angka and at sentences. Each chunk keeps its hierarchy, page range and a contextual heading embedded with its text, so an excerpt stays understandable on its own

Design system

Editorial evidence workspace is a calm, editorial interface for researchers who must check every claim. A deep teal primary signals trust, and the other colours carry legal meaning rather than decoration.

Colour palette

  • Deep teal#155b60Primary buttons, links and the searched-domain badge
  • Evidence indigo#313eafCitation chips, evidence badges and the selected answer
  • In-force green#12683dRegulations in force (berlaku) and indexed documents
  • Caution amber#8e4a06Historical sources and general or hybrid answers labelled unverified
  • Revoked red#af1d1dRevoked regulations (dicabut), failed jobs and errors
  • Ink#151b28Body text and headings
  • Warm off-white#fbfaf9Light-theme page background
  • Colour

    Teal for actions and links, indigo for citations and evidence, green for regulations in force, amber for historical sources and unverified answers, and red for revoked status and errors. Light and dark themes share one set of HSL tokens, so each tone keeps its meaning in both

  • Typography

    Inter through next/font for the interface, Source Serif 4 for page and answer headings, conversation titles and quoted regulation text, and the system monospace stack for code

  • Components

    shadcn/ui-style components on Radix Dialog, Dropdown Menu and Tooltip, with class-variance-authority variants, Lucide icons and Sonner toasts. A custom badge maps each regulation status and evidence tone to one colour

  • Accessibility

    Every citation is a focusable chip tied to its source, and unverified answers are labelled before they are read. The interface keeps AA contrast, a skip link, visible focus rings and reduced motion

Where this fits

The same architecture can help teams research internal policies, standards or contracts with references they can inspect. Explore our AI solutions and web applications, or discuss your knowledge workflow.

discuss your knowledge workflow

Let’s connect the dots

Let's put these ideas to work.

Share a process, product, or problem you want to improve. We will work through the possibilities together.

Discuss your project