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.
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
-
Clone the repository:
git clone https://github.com/sohv/genoshi-assignment.git cd genoshi-assignment -
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
- Copy
.env.exampleto.envand fill in the API key for the Gemini API.
- Copy
-
Run the application:
uvicorn app.main:app --reload
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.
Run all tests:
pytestRun a single test file:
pytest tests/test_ai_extractor.py -qTo use the Docker image in your local environment, just run this command:
docker pull sohanv/document-validator:latest