chore: remove NHTSA code and update documentation (refs #227)
Delete vehicles/external/nhtsa/ directory (3 files), remove VPICVariable and VPICResponse from platform models. Update all documentation to reflect Gemini VIN decode via OCR service architecture. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,7 +13,7 @@ Primary entity for vehicle management consuming MVP Platform Vehicles Service. H
|
||||
- `DELETE /api/vehicles/:id` - Soft delete vehicle
|
||||
|
||||
### VIN Decoding (Pro/Enterprise Only)
|
||||
- `POST /api/vehicles/decode-vin` - Decode VIN using NHTSA vPIC API
|
||||
- `POST /api/vehicles/decode-vin` - Decode VIN using Gemini via OCR service
|
||||
|
||||
### Hierarchical Vehicle Dropdowns
|
||||
**Status**: Vehicles service now proxies the platform vehicle catalog to provide fully dynamic dropdowns. Each selection step filters the next list, ensuring only valid combinations are shown.
|
||||
@@ -104,11 +104,7 @@ vehicles/
|
||||
├── data/ # Database layer
|
||||
│ └── vehicles.repository.ts
|
||||
├── external/ # External service integrations
|
||||
│ ├── CLAUDE.md # Integration pattern docs
|
||||
│ └── nhtsa/ # NHTSA vPIC API client
|
||||
│ ├── nhtsa.client.ts
|
||||
│ ├── nhtsa.types.ts
|
||||
│ └── index.ts
|
||||
│ └── CLAUDE.md # Integration pattern docs
|
||||
├── migrations/ # Feature schema
|
||||
│ └── 001_create_vehicles_tables.sql
|
||||
├── tests/ # All tests
|
||||
@@ -121,14 +117,14 @@ vehicles/
|
||||
|
||||
## Key Features
|
||||
|
||||
### 🔍 VIN Decoding (NHTSA vPIC API)
|
||||
### VIN Decoding (Gemini via OCR Service)
|
||||
- **Tier Gating**: Pro and Enterprise users only (`vehicle.vinDecode` feature key)
|
||||
- **NHTSA API**: Calls official NHTSA vPIC API for authoritative vehicle data
|
||||
- **Gemini**: Calls OCR service Gemini VIN decode for authoritative vehicle data
|
||||
- **Caching**: Results cached in `vin_cache` table (1-year TTL, VIN data is static)
|
||||
- **Validation**: 17-character VIN format, excludes I/O/Q characters
|
||||
- **Matching**: Case-insensitive exact match against dropdown options
|
||||
- **Confidence Levels**: High (exact match), Medium (normalized match), None (hint only)
|
||||
- **Timeout**: 5-second timeout for NHTSA API calls
|
||||
- **Timeout**: 5-second timeout for OCR service calls
|
||||
|
||||
#### Decode VIN Request
|
||||
```json
|
||||
@@ -140,15 +136,15 @@ Authorization: Bearer <jwt>
|
||||
|
||||
Response (200):
|
||||
{
|
||||
"year": { "value": 2021, "nhtsaValue": "2021", "confidence": "high" },
|
||||
"make": { "value": "Honda", "nhtsaValue": "HONDA", "confidence": "high" },
|
||||
"model": { "value": "Civic", "nhtsaValue": "Civic", "confidence": "high" },
|
||||
"trimLevel": { "value": "EX", "nhtsaValue": "EX", "confidence": "high" },
|
||||
"engine": { "value": null, "nhtsaValue": "2.0L L4 DOHC 16V", "confidence": "none" },
|
||||
"transmission": { "value": null, "nhtsaValue": "CVT", "confidence": "none" },
|
||||
"bodyType": { "value": null, "nhtsaValue": "Sedan", "confidence": "none" },
|
||||
"driveType": { "value": null, "nhtsaValue": "FWD", "confidence": "none" },
|
||||
"fuelType": { "value": null, "nhtsaValue": "Gasoline", "confidence": "none" }
|
||||
"year": { "value": 2021, "decodedValue": "2021", "confidence": "high" },
|
||||
"make": { "value": "Honda", "decodedValue": "HONDA", "confidence": "high" },
|
||||
"model": { "value": "Civic", "decodedValue": "Civic", "confidence": "high" },
|
||||
"trimLevel": { "value": "EX", "decodedValue": "EX", "confidence": "high" },
|
||||
"engine": { "value": null, "decodedValue": "2.0L L4 DOHC 16V", "confidence": "none" },
|
||||
"transmission": { "value": null, "decodedValue": "CVT", "confidence": "none" },
|
||||
"bodyType": { "value": null, "decodedValue": "Sedan", "confidence": "none" },
|
||||
"driveType": { "value": null, "decodedValue": "FWD", "confidence": "none" },
|
||||
"fuelType": { "value": null, "decodedValue": "Gasoline", "confidence": "none" }
|
||||
}
|
||||
|
||||
Error (400 - Invalid VIN):
|
||||
@@ -157,7 +153,7 @@ Error (400 - Invalid VIN):
|
||||
Error (403 - Tier Required):
|
||||
{ "error": "TIER_REQUIRED", "requiredTier": "pro", "currentTier": "free", ... }
|
||||
|
||||
Error (502 - NHTSA Failure):
|
||||
Error (502 - OCR Service Failure):
|
||||
{ "error": "VIN_DECODE_FAILED", "message": "Unable to decode VIN from external service" }
|
||||
```
|
||||
|
||||
@@ -230,7 +226,7 @@ Error (502 - NHTSA Failure):
|
||||
## Testing
|
||||
|
||||
### Unit Tests
|
||||
- `vehicles.service.test.ts` - Business logic with mocked dependencies (VIN decode, caching, CRUD operations)
|
||||
- `vehicles.service.test.ts` - Business logic with mocked dependencies (VIN decode via OCR service mock, caching, CRUD operations)
|
||||
|
||||
### Integration Tests
|
||||
- `vehicles.integration.test.ts` - Complete API workflow with test database (create, read, update, delete vehicles)
|
||||
|
||||
Reference in New Issue
Block a user