Skip to content

vineetsarpal/re-ink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

38 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

re-ink

Automated Reinsurance Contracts & Parties creation using Agentic Document Extraction

re-ink is a full-stack web application that streamlines reinsurance contract management by automatically extracting contract details and party information from uploaded documents using AI-powered document extraction.

Recognition

Finalist in the LandingAI Financial AI Hackathon Championship 2025

Demo

Watch the demo

Features

  • πŸ“„ Document Upload: Upload PDF and DOCX reinsurance contract documents
  • πŸ€– AI Extraction: Automatic extraction of contract terms and parties using LandingAI
  • βœ… Review Workflow: Review and edit AI-extracted data before creating records
  • πŸ“Š Contract Management: Full CRUD operations for reinsurance contracts
  • πŸ‘₯ Party Management: Manage parties (cedants, reinsurers, brokers)
  • πŸ” Search & Filter: Find contracts and parties quickly
  • πŸ“ˆ Dashboard: Overview of contracts and parties with statistics
  • πŸ§ͺ Sample Extraction Mode: Seed mock data to test the workflow without LandingAI
  • 🀝 AI Agent Guidance: LangChain/LangGraph agents surface intake insights and automated reviews

Sample Documents

Two sample PDFs are bundled with the frontend and available directly in the Upload page UI β€” just click a sample card to load it, no setup required.

Technology Stack

Backend

  • FastAPI: Modern Python web framework
  • SQLAlchemy: ORM for database operations
  • PostgreSQL: Relational database
  • LandingAI: Agentic document extraction API
  • Alembic: Database migrations

Frontend

  • React 18: UI framework
  • TypeScript: Type-safe JavaScript
  • Vite: Fast build tool
  • React Router: Client-side routing
  • React Query: Server state management
  • Axios: HTTP client

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              USER / BROWSER                                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚     React Frontend    β”‚
                    β”‚  - Upload & Review UI β”‚
                    β”‚  - AI Insight Panels  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚  HTTP/REST
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚     FastAPI Backend   β”‚
                    β”‚                       β”‚
                    β”‚ /api/documents        β”‚
                    β”‚ /api/review           β”‚
                    β”‚ /api/agents           β”‚
                    β””β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
                        β”‚              β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”      β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚ Document  β”‚      β”‚ Agent Service     β”‚
                β”‚ Service   β”‚      β”‚ (LangChain/Graph) β”‚
                β”‚ (LandingAIβ”‚      β”‚ - Guided Intake   β”‚
                β”‚  workflow)β”‚      β”‚ - Contract Review β”‚
                β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚                  β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚
        β”‚ LandingAI ADE API   β”‚         β”‚
        β”‚ Parse & Extract     β”‚         β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚
                     β”‚                  β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚ PostgreSQL                  │◄┼───────────── LangChain LLM   β”‚
        β”‚ - Contracts & Parties       β”‚ β”‚  prompts   β”‚  (OpenAI, Ollamaβ”‚
        β”‚ - Extraction Jobs           β”‚ β”‚            β”‚   or offline)   β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                        β”‚
                            (insights returned to frontend)

Quick Start

Rapid Start via Makefile

The repo includes a Makefile so you can bootstrap both services quickly:

# Install backend + frontend dependencies
make setup

# Copy and edit environment files (run once)
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.env

# Launch both dev servers (Ctrl+C stops both)
make dev

Use make backend-dev or make frontend-dev to run either side individually, and make backend-install / make frontend-install to refresh dependencies. make sync-version copies the root VERSION file into backend/ (included automatically in make setup).

Prerequisites

  • Python 3.9+
  • Node.js 18+
  • PostgreSQL 12+
  • LandingAI API key

Backend Setup

cd backend

# Create virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Configure environment
cp .env.example .env
# Edit .env with your settings

# Set up database
createdb reink_db
alembic upgrade head

# Run server
uvicorn app.main:app --reload
# or use: make backend-dev

Backend will be available at http://localhost:8000 API docs at http://localhost:8000/docs

Frontend Setup

cd frontend

# Install dependencies
npm install

# Configure environment
cp .env.example .env
# Edit .env with backend URL

# Run development server
npm run dev
# or use: make frontend-dev

Frontend will be available at http://localhost:3000

Project Structure

re-ink/
β”œβ”€β”€ VERSION                   # Single source of truth for app version
β”œβ”€β”€ backend/                  # FastAPI backend
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/             # API endpoints
β”‚   β”‚   β”œβ”€β”€ core/            # Configuration (reads VERSION file)
β”‚   β”‚   β”œβ”€β”€ db/              # Database setup
β”‚   β”‚   β”œβ”€β”€ models/          # SQLAlchemy models (Contract, Party, ExtractionJob)
β”‚   β”‚   β”œβ”€β”€ schemas/         # Pydantic schemas
β”‚   β”‚   β”œβ”€β”€ services/        # Business logic
β”‚   β”‚   └── main.py          # Application entry
β”‚   └── pyproject.toml
β”œβ”€β”€ frontend/                 # React frontend
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   └── samples/         # Bundled sample PDFs (selectable in UI)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/      # React components
β”‚   β”‚   β”œβ”€β”€ pages/           # Page components
β”‚   β”‚   β”œβ”€β”€ services/        # API client
β”‚   β”‚   β”œβ”€β”€ types/           # TypeScript types
β”‚   β”‚   └── styles/          # CSS styles
β”‚   └── package.json

Workflow

  1. Upload: User uploads a reinsurance contract document (PDF or DOCX)
  2. Extract: System sends document to LandingAI for AI-powered extraction
  3. Process: AI extracts contract details, dates, financial terms, and party information
  4. Review: User reviews and edits the extracted data in a user-friendly form
  5. Approve: User approves the data, creating Contract and Party records
  6. Manage: Contracts and parties can be viewed, searched, and managed

API Endpoints

Documents

  • POST /api/documents/upload - Upload a document and start extraction in the background
  • GET /api/documents/status/{job_id} - Check extraction status (supports processing, completed, failed)
  • GET /api/documents/results/{job_id} - Retrieve parsed extraction results when a job is complete

Contracts

  • GET /api/contracts/ - List contracts (supports status, contract_type, skip, limit filters)
  • POST /api/contracts/ - Create a contract
  • GET /api/contracts/{id} - Get contract details with associated parties
  • PUT /api/contracts/{id} - Update contract fields
  • DELETE /api/contracts/{id} - Soft delete a contract
  • POST /api/contracts/{id}/parties/{party_id} - Link a party to a contract with a role
  • DELETE /api/contracts/{id}/parties/{party_id} - Remove a party association from a contract

Parties

  • GET /api/parties/ - List parties (supports is_active, skip, limit)
  • POST /api/parties/ - Create a party
  • GET /api/parties/{id} - Get party details
  • PUT /api/parties/{id} - Update party fields
  • DELETE /api/parties/{id} - Soft delete a party
  • GET /api/parties/search/by-name - Search parties by partial name match

Review

  • POST /api/review/approve - Approve extracted data
  • POST /api/review/reject/{job_id} - Reject extraction

Agents

  • POST /api/agents/intake - Run the guided intake LangChain agent for an extraction job
  • POST /api/agents/review - Generate an automated review for a contract

System

  • GET /api/system/config - Return agent configuration flags (e.g., offline mode) for the frontend

Development

See detailed development guides:

Configuration

Backend (.env)

SECRET_KEY=your_secret_key
DATABASE_URL=postgresql://user:password@localhost:5432/reink_db
LANDINGAI_API_KEY=your_landingai_api_key   # Optional β€” users can supply their own key in the UI (BYOK)
LANDINGAI_PARSE_URL=https://api.va.landing.ai/v1/ade/parse
LANDINGAI_EXTRACT_URL=https://api.va.landing.ai/v1/ade/extract
LANDINGAI_PARSE_MODEL=dpt-2-latest
LANDINGAI_EXTRACT_MODEL=extract-latest
MAX_UPLOAD_SIZE=52428800
UPLOAD_DIR=./uploads
ALLOWED_ORIGINS=["http://localhost:3000","http://localhost:5173"]
LOG_LEVEL=INFO
LLM_PROVIDER=openai               # "openai" or "ollama"
OPENAI_API_KEY=your_openai_key    # Only needed when LLM_PROVIDER=openai
AGENT_MODEL=gpt-4o-mini
AGENT_TEMPERATURE=0.1
AGENT_OFFLINE_MODE=false          # Set true to skip LLM calls entirely
OLLAMA_BASE_URL=http://localhost:11434  # Only needed when LLM_PROVIDER=ollama
OLLAMA_MODEL=llama3.1
  • LANDINGAI_API_KEY is optional on the server β€” users can enter their own key directly in the Upload UI (BYOK). If neither is set, the upload will be rejected with a clear error.
  • LLM_PROVIDER selects the agent LLM backend; set AGENT_OFFLINE_MODE=true to skip LLM calls entirely.
  • ALLOWED_ORIGINS supports JSON array notation (shown above) or a comma-separated list. In production, set this to your deployed frontend URL.
  • The app version is read from the VERSION file at the repo root β€” do not set APP_VERSION in .env.

Frontend (.env)

VITE_API_BASE_URL=http://localhost:8000/api

License

See LICENSE file for details.

Contributing

This project is designed for insurance and reinsurance companies to streamline contract management workflows. Contributions are welcome!

Support

For issues, questions, or feature requests, please open an issue on the project repository.

About

AI-powered Reinsurance Contracts & Parties management

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors