Skip to content

Latest commit

 

History

History
executable file
·
89 lines (70 loc) · 2.1 KB

File metadata and controls

executable file
·
89 lines (70 loc) · 2.1 KB

Backend Task: Mini document validator

This is a FastAPI application designed to automate the validation of insurance documents using Google Gemini-2.5-pro model. The application extracts key information from raw text documents and validates it against a set of predefined rules.

Project Structure

document-validator
├── app
│   ├── __init__.py
│   ├── main.py
│   ├── models
│   │   ├── __init__.py
│   │   └── schemas.py
│   ├── services
│   │   ├── __init__.py
│   │   ├── ai_extractor.py
│   │   └── validator.py
│   └── utils
│       ├── __init__.py
│       └── config.py
├── assets
│   ├── sample_document_fail.txt
│   ├── sample_document_pass.txt
│   └── valid_vessels.json
├── tests
│   ├── __init__.py
│   ├── test_ai_extractor.py
│   └── test_validator.py
├── .env.example
├── .gitignore
├── Dockerfile
├── README.md
├── requirements.txt
└── pytest.ini

Setup Instructions

  1. Clone the repository:

    git clone https://github.com/sohv/genoshi-assignment.git
    cd genoshi-assignment
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install dependencies:

    pip install -r requirements.txt
  4. Set up environment variables:

    • Copy .env.example to .env and fill in the API key for the Gemini API.
  5. Run the application:

    uvicorn app.main:app --reload

Usage

Send a POST request to the /validate endpoint with the raw text of the insurance document in the request body. The application will return the extracted data and the results of the validation checks.

Testing

Run all tests:

pytest

Run a single test file:

pytest tests/test_ai_extractor.py -q

Docker

To use the Docker image in your local environment, just run this command:

docker pull sohanv/document-validator:latest