Automated Contract Processing

Automated Insurance Contract Processing

Python Python / FastAPI
OpenAI OpenAI / Gemini
PostgreSQL PostgreSQL

CLIENT: “Our primary goal is to maximize positive customer service and deliver a truly client-centric approach. We need to significantly speed up request handling while maintaining maximum accuracy, so our operators don't spend time on routine data transcription and can focus fully on clients.”

About the Project

This modular multi-tenant portal is designed as a suite of automations for an insurance brokerage firm and its Customer Care department. The system continuously monitors incoming email inboxes, automatically downloads attached PDF documents, extracts key data, and generates a payment QR code along with a personalized instruction email for the client. In the subsequent step, emails are automatically generated and dispatched to clearly communicate key information, step-by-step guides, and essential instructions on how to act in case of complications, an accident, or a claim—saving 485 hours per year.

Thanks to strict isolation into individual projects (tenants), the portal can serve multiple insurance products or clients simultaneously, each with its own email templates, logs, and processing rules. The solution features a custom web user interface where users always see the exact outcome of every run and maintain full operational control—allowing them to configure automations, manually toggle them on or off, manage email templates, or trigger manual document processing whenever needed.

The portal also includes built-in IDM (Identity Management) with role-based access control (RBAC). Each user has pre-configured permissions and specific projects assigned to them, ensuring secure data isolation and clear responsibilities across the Customer Care team.

Technical Solution

The backend is built on Python (FastAPI) and uses decentralized processing via dedicated daemon threads. For each registered project, a background loop monitors an IMAP folder-based state queue (to-process → done / error), ensuring 100% reliability even on mail servers without custom flag support.

PDF text layers are extracted using PyMuPDF (fitz). Subsequent classification and data extraction are powered by AI models with seamless switching between OpenAI and Gemini. To achieve maximum accuracy, the system uses process duplication (dual extraction) and randomized result cross-checking, while Structured Outputs validated against Pydantic models guarantee 100% type-safe JSON responses. From the extracted data, the system automatically computes the Czech IBAN, generates a Czech SPD payment QR code, and sends instructions via secure SMTP (SSL).

The frontend is built with Next.js 16 (React 19, TypeScript) focusing on speed and a clean UI. Data is stored in PostgreSQL with a custom ThreadedConnectionPool for safe concurrent writes and secured with JWT and bcrypt.

Before

  • Manual opening and reading of every contract PDF
  • Manual transcription of amounts, accounts, and variable symbols
  • Risk of human error when creating payment instructions
  • Delays in handling client emails
  • Lack of central audit and processing status overview

After

  • Fully automated PDF extraction within seconds
  • 100% type-valid data extraction via Structured Outputs
  • Automatic Czech SPD QR code and IBAN generation
  • Instant client instruction delivery via SMTP
  • Multi-tenant web portal with complete run history

Project Parameters

Client Industry Insurance Brokerage
Domain Customer Care
Technologies Used Python, FastAPI, Next.js 16, OpenAI / Gemini, PyMuPDF, PostgreSQL, IMAP/SMTP
Architecture Multi-tenant Portal + Daemon Processors
Laura

Hello, I'm Laura, David's AI assistant. I can provide information about David or schedule a meeting for you right away. How can I help you?

Hello, I am David's AI assistant Laura, how can I help you?