Skip to content
All projects
Case studyCS/18
StatusPersonal project
TypeAI
Year2025

FinTafsir

Upload a bank statement PDF, get structured JSON back

A Spring Boot API that extracts text with Apache PDFBox and asks an OpenAI model for the account holder, email, and opening and closing balances as strict JSON. A small dark-themed page handles the upload.

  • 1 endpoint
  • 10 MB upload cap
  • Raw-text fallback
  • Runs without a key

§1

The problem

Every bank lays out its statements differently, so template or regex extraction breaks with each new format.

§2

My role

Sole developer: API, PDF extraction, prompt, response parsing, front end and Docker setup.

§3

Architecture

Fig. 1 · FinTafsir architecture
UPLOAD PAGEstatic HTMLCONTROLLERtype · 10 MBPDFBOXtext layerPARSERJSON promptOPENAIchat completionJSON RESULTfields + raw
clientserviceexternal

§4

Key decisions

  1. D/01

    Reject early

    Empty files, non-PDF content types and missing .pdf extensions get 400; anything over 10 MB gets 413, all before the PDF is opened.

  2. D/02

    Ask for JSON, plan for prose

    A system message and a strict JSON template ask for fields only. Fences are stripped before parsing, and if parsing still fails the raw model output is returned instead of an error.

  3. D/03

    Dummy mode

    Without OPENAI_API_KEY the app still starts and returns demo data, so the UI can be tried without a key. Logs only ever show the key's last 4 characters.

§5

Challenges

  • Scanned PDFs have no text layer; they're rejected with a clear message instead of sending an empty prompt to the model.
  • Next step: chunking long statements to stay inside the model's context window.

§6

Stack

  • Java
  • Spring Boot
  • Apache PDFBox
  • OkHttp
  • OpenAI API
  • Docker

Next case study

GraphEcomX

Event-driven e-commerce microservices behind a GraphQL gateway