Skip to content

jagrat7/car-part-selector-ai-coding-challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Part Bay - CC

This project processes automotive insurance parts guidelines (e.g., Allstate policy documents) and validates whether specific parts are allowed, not allowed, or have limited usage based on their type (OEM, Aftermarket, or Recycled).

Tech Stack

This project uses:

  • LlamaIndex: Document parsing and extraction
  • Vercel AI SDK: AI SDK from Vercel with Claude Sonnet 4.5
  • Zod: Schema validation

Key Features

  • PDF Extraction: Uses LlamaExtract API with MULTIMODAL mode to extract structured parts guidelines from PDF documents
  • AI Classification: Leverages Claude Sonnet 4.5 to match specific part names to validation table entries
  • Batch Processing: Processes parts in batches with automatic retry logic

Installation

Note: This project uses bun as the package manager. You can use your preferred package manager like npm or pnpm.

bun install

Environment Setup

Create a .env file in the src directory:

LLAMA_CLOUD_API_KEY=your_llama_cloud_api_key
ANTHROPIC_API_KEY=your_anthropic_api_key

Usage

Run the Full Pipeline

cd src
bun run index.ts

This will:

  1. Extract parts guidelines from the PDF using LlamaExtract and save to src/data/validationTable.json
  2. Match input parts to validation table entries using Claude and save to src/data/partsWithValidationTableNames.json
  3. Determine status (Allowed/Not Allowed/Limited) for each part
  4. Save results to src/data/partsWithStatus.json

Visualization Tools

I have added two html files to visualize the results:

  • src/visualizeValidationTable.html: Visualizes the validation table(rules from Allstate policy)
  • src/visualizePartsWithStatus.html: Visualizes the parts with their status

Configuration

Edit src/index.ts to control behavior:

const RERUN = true  // Set to false to use saved extraction results

Project Structure

part-bay/
├── src/
│   ├── data/
│   │   ├── parts.json                          # Input parts to validate
│   │   ├── extracted_parts.json                # Extracted guidelines from PDF
│   │   ├── partsWithValidationTableNames.json  # Parts matched to validation table
│   │   └── partsWithStatus.json                # Final validation results
│   ├── constants.ts                            # Configuration constants
│   ├── schemas.ts                              # JSON schema for extraction
│   ├── utils.ts                                # LlamaExtract API and other utilities
│   ├── index.ts                                # Main application entry point
│   └── visualizeValidationTable.html           # Visualization tool
│   └── visualizePartsWithStatus.html           # Visualization tool
├── .env                                        # API keys (not committed)
├── package.json
└── README.md

How It Works

1. PDF Extraction (LlamaExtract)

The system uses LlamaExtract with the following configuration:

  • Extraction Mode: MULTIMODAL (for visually rich documents)
  • Extraction Target: PER_DOC (processes entire document)
  • Chunk Mode: PAGE (processes page by page)
// Extraction agent configuration
{
  extraction_mode: "MULTIMODAL",
  extraction_target: "PER_DOC",
  chunk_mode: "PAGE",
  invalidate_cache: true
}

The extracted guidelines are saved to src/data/validationTable.json.

2. Part Classification (Claude)

Parts are matched to validation table entries using Claude Sonnet 4.5:

  • Processes in batches of 50 parts
  • Automatic retry logic (up to 3 attempts)
  • Strict enum validation against known part names

3. Status Determination

For each part, the system:

  1. Looks up the matched validation table entry
  2. Checks the part type (OEM, Aftermarket, or Recycled)
  3. Returns the corresponding status

Data Schema

Input Parts (parts.json)

{
  "name": "L Frt Pickup Bed Brace",
  "type": "OEM"
}

Validation Table Entry

{
  "parts": ["supports", "brackets"],
  "oem_opt_oem": "Allowed",
  "certified_aftermarket": "Allowed",
  "recycled_parts": "Not Allowed"
}

Output (partsWithStatus.json)

{
  "name": "L Frt Pickup Bed Brace",
  "type": "OEM",
  "validationTablePartName": "supports",
  "status": "Allowed"
}

License

This project was created using bun init in bun v1.2.1.

About

A insurance guideline extractor for car parts. Uses LLMs and finds out if a part is allowed or not by the insurance guideline.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors