An @imqueue RPC microservice that serves the car catalog — the makes, models and body types customers pick from when registering a vehicle.
On start it downloads the public US EPA FuelEconomy vehicle
dataset, extracts and parses it, and keeps the catalog in memory for fast lookups. It never
speaks HTTP; every method is exposed over the @imqueue/rpc Redis message queue and consumed by
the gateways (api, api-rest).
This repo is one piece of the imqueue-sandbox tutorial — a complete car-wash booking app built from independent RPC microservices that communicate over a Redis-backed message queue.
| Repo | Role | Store |
|---|---|---|
| user | Customer accounts & their garage | MongoDB |
| auth | Login, JWT issuing & revocation | Redis |
| car | Car catalog (makes / models / types) | in-memory |
| time-table | Washing reservations & schedule | PostgreSQL |
| api | GraphQL gateway orchestrating the fleet | — |
| api-rest | REST/OpenAPI gateway over the same fleet | — |
| web-app | React front-end on api (GraphQL/Relay) |
— |
| web-app-rest | React front-end on api-rest (REST) |
— |
The backend services are transport-agnostic: two interchangeable gateways and two independent front-ends prove the same fleet can be fronted by completely different API styles without changing a single service.
Exposed by the Car service (src/Car.ts) via @expose():
| Method | Signature | Description |
|---|---|---|
version |
() |
Running service name / version / repository. |
brands |
() |
Sorted list of manufacturer (brand) names. |
list |
(brand, fields?, sort='model', dir='asc') |
Cars for a given brand, sorted and de-duplicated. |
fetch |
(id | id[], fields?) |
One car by id, or many when given an array of ids. |
A catalog entry is { id, make, model, type, years[] }, where type is a normalized size
class (mini / midsize / large) and id is a stable hash of make + model + type.
- On cold start the service downloads the dataset zip from
CARS_DATA_URL, extracts it withadm-zip, and streams the CSV into an in-memory index (brands, id → car). - A per-host Redis lock (
SET … NX EX 30) elects a single downloader so that multiple workers on the same machine share one download and the localdata/directory. - The dataset is refreshed on a 24-hour interval; Redis is used only for the update lock — the catalog itself is never cached in Redis.
Environment variables (loaded from an optional .env via process.loadEnvFile()):
| Variable | Default | Purpose |
|---|---|---|
CARS_DATA_URL |
EPA vehicles.csv.zip URL |
Source of the car catalog dataset. |
IMQ_REDIS |
localhost:6379 |
Redis endpoint(s) for the RPC message queue and the update lock. |
The first start needs outbound network access to fetch the dataset (~20 MB). Subsequent starts reuse the extracted CSV under
data/.
Development mode (rebuilds and restarts on change):
npm run devProduction mode:
npm startBoth start the service under the imqueue label car. Requires Redis at IMQ_REDIS.