AI & documents · CASE STUDY

PenteFino

Personal project for identifying document inconsistencies through processing and AI.

The challenge

Reduce repetitive checks in complex PDFs while retaining human review.

The solution

Workflow in development for PDF upload and validation, background processing through a persisted database queue and Gemini-assisted analysis with human review.

Architecture

Java/Spring Boot backend, React frontend and PostgreSQL, with authentication, PDF validation, asynchronous processing, failure handling and structured AI response validation. Private source code.

  1. PDF
  2. Queue
  3. AI

Main features

  • Validation of PDFs containing native text before storage.
  • Persistent queue for asynchronous processing, failure handling and recovery of interrupted jobs.
  • Structured findings by page, category, severity and recommendation, subject to human review.
  • Individual history, status tracking, cancellation and deletion.

Technical decisions and limitations

  • A PostgreSQL queue keeps the infrastructure simple without requiring a dedicated broker.
  • Gemini response validation reduces the persistence of findings outside the expected format.
  • The MVP does not process documents requiring OCR. AI does not replace human review.

Availability

Source code
Private
Demo
Not published
Case study
Available
Status
In development

Context and problem

Checking long PDFs by hand means repeating the same checks page after page. PenteFino automates the first pass and leaves the final judgment to a person.

How it works

  1. Sign-up and verified e-mail
  2. PDF upload and validation
  3. Queued job (PostgreSQL)
  4. Gemini analysis
  5. Findings validation
  6. Owner review

Business rules

  • Individual accounts, with a verified e-mail before any upload.
  • Native-text PDFs only, up to 20 MB and 200 pages. The file signature is checked, not just the declared type.
  • Allowed states: CREATED, QUEUED, PROCESSING, then COMPLETED or FAILED. Cancellation is possible only before processing.
  • Severities: INFO, LOW, MEDIUM, HIGH and CRITICAL. Each finding carries page, evidence, recommendation and confidence.
  • The original document expires after 30 days. Metadata and results remain.

Technical challenges and solutions

  • Challenge: Background processing without a message broker. Solution: A PostgreSQL table used as a queue, with SELECT ... FOR UPDATE SKIP LOCKED so two workers never take the same job.
  • Challenge: Jobs abandoned when the process restarts. Solution: A heartbeat per job and a periodic sweep that marks unresponsive jobs as FAILED.
  • Challenge: AI responses outside the expected format. Solution: A structural validator discards invalid findings, bounds confidence and page, and accepts at most 100 per audit.

Security and privacy

  • Every query checks ownership. Another user's resource returns 404, without revealing that it exists.
  • End-to-end CSRF, session rotation on login and session revocation after a password change.
  • Per-IP and per-account rate limits on authentication and audit creation.
  • The prompt defends against injection by treating document text as data. The AI key stays out of the repository and logs.

Tests and evidence

  • Backend with JUnit and MockMvc, including worker concurrency and the Gemini adapter against a local HTTP server. Frontend with Vitest and Testing Library, including a full flow through the UI.
  • README figures: 91 backend tests (1 skipped) and 25 frontend tests. No test calls the real Gemini API.

Lessons learned

  • A database-backed queue serves an MVP well and scales to more instances without changing the mechanism.
  • AI output is untrusted input and needs validation before it is stored.

Current status

Working end-to-end MVP, still in development. The code is private and no public demo is authorized. It does not process PDFs without native text (no OCR), and the live Gemini integration may still need parsing adjustments.

Documented evidence

Documentation records backend tests with JUnit/MockMvc and frontend tests with Vitest, including concurrency, sessions and response validation. There is no authorized public demonstration.

PenteFino landing page, without documents or user data.