This is the backend to support the Meteor App UI.
- Data set is finite and small, containing only 1000 records.
For caching, we utilized the cache-manager
library to naively cache each HTTP call using the URL as the key. This decision was made for simplicity and ease of implementation.
However, a more advanced caching system could be beneficial for larger scenarios. Systems like Redis or other in-memory caching solutions could provide better performance. They would permit caching of query results and introduce more optimization opportunities.
The dataset, being small and finite, is stored as a JSON data structure for demonstration purposes. In more scalable scenarios, a relational DB would be more appropriate. A potential SQL data model might be:
CREATE TABLE meteorites (
meteorite_id INT PRIMARY KEY,
name VARCHAR(255),
nametype VARCHAR(255),
recclass VARCHAR(255),
mass FLOAT,
fall VARCHAR(255),
year DATETIME
);
Using a relational database would provide benefits like caching, offsetting, relationships, and lookups. Still, given our dataset's size, the JSON structure should perform adequately.
Given our primary assumption and the choice against a relational DB, pagination is straightforward. We slice the dataset and offset results based on the requested page.
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# build the container
$ docker build -t meteor-server .
# run the container
$ docker run -p 3001:3001 meteor-server
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov