Vehicle Parser is a service that fetches and processes vehicle make and type information from an external API (NHTSA API). It first processes a local dataset, then runs background tasks to update from the API. The service exposes GraphQL endpoints to access the data. It includes logging and error handling mechanisms for resilience.
- Docker
- Node.js (for local development)
- Nest.js (for local development)
- Build and start the services using Docker Compose:
docker-compose up --build
This will start the service, including the database and API. The dataset will be loaded, and API updates will run in the background.
-
Install dependencies:
npm install
-
Set up environment variables in .env:
GET_MAKES_URL=https://vpic.nhtsa.dot.gov/api/vehicles/getallmakes?format=xml GET_VEHICLE_TYPES_URL=https://vpic.nhtsa.dot.gov/api/vehicles/GetVehicleTypesForMakeId MONGO_URL=mongodb://localhost:27017/vehicles
-
Start the service:
npm run start
- The service exposes GraphQL endpoints:
getAllMakes
: Returns all vehicle makes and types.getMake(makeId: String!)
: Returns a specific make by ID.
- To test the GraphQL API, navigate to
http://localhost:3000/graphql
and use the GraphQL playground.
To run the tests:
npm run test