05 · Applied R&D
Live in productionInsurance Policy and Claims Services
Ten-plus FastAPI services on Oracle for policy issuance and claims settlement across seven insurance lines, with a rollback step so a retry cannot write a second financial document.
- Role
- Engineer on the services
- Scope
- Issuance, settlement, rollback, streaming
- Stack
- Python, FastAPI, Pydantic
Client details are confidential. No client data is shown.
Overview
Premia Tools is a set of services I engineered for policy issuance and claims settlement. There are more than ten FastAPI applications, in one monorepo, using Oracle. They cover seven lines: motor, medical, workmen compensation, personal accident, third-party liability, and the property and construction lines used for that book. Settlement writes the financial documents. The services are live.
The problem
The old path was the core system's own screens. Issuance and settlement were manual, slow, and easy to repeat by accident. A failed call that was retried could create a second credit note or debit note for the same provision. Long settlement jobs also needed a way to report progress without holding a single silent request open until the end.
What I built
- The FastAPI services and their Pydantic contracts.
- Issuance flows for the seven lines.
- Settlement that produces the credit note, debit note, VAT, and general-ledger entries.
- SAVEPOINT rollback per provision, so a retry undoes the partial financial write instead of adding another document.
- Oracle connection pooling.
- Server-sent events for long settlement jobs.
- JWT on the service boundary.
Architecture
A caller hits the FastAPI service for a line of business. The service opens an Oracle transaction, does the provision, and uses a savepoint around that unit. If the call fails and is retried, the savepoint rollback removes the partial financial document. Long jobs stream progress with server-sent events instead of one blocked response. Pooling keeps the Oracle sessions reused across those calls.
Diagram
Key engineering decisions
One monorepo of small FastAPI services, not one process that knows every line. A motor issuance bug should not be a medical settlement deploy.
The duplicate-document bug is handled in the database transaction, with a savepoint, rather than by asking the caller to remember not to retry.
Hard problems and how I solved them
Retries created a second financial document. The savepoint wraps the provision. A failed attempt rolls back to that point, and the retry starts clean.
Settlement jobs ran long enough to look hung. Server-sent events stream progress, and the Oracle pool keeps those jobs from opening a new session every time.
Seven lines in one place. Separate services, shared patterns, one repo.
Reliability and failure handling
The savepoint is the failure policy for money documents. Pooling is the failure policy for session storms. The stream is how a caller tells a slow success from a dead request.
Outcome
Issuance and settlement for those lines run through the services, in production, instead of through the core screens. A retry no longer leaves a second financial document behind.
Stack
Python, FastAPI, Pydantic, Oracle, JWT, server-sent events, Docker.
What I would improve next
A per-line timing number for issuance, so the gain over the manual screen is a measured duration and not only a change of path.
Client details are confidential. No client data is shown.