My setup:
- Ubuntu Linux
- .NET Core SDK:
8.0.103
[/usr/lib/dotnet/sdk]
Run the following command in the root directory of the project:
dotnet build . && dotnet run --project ./src/Phi.Api/
Run tests:
dotnet test
The applications Swagger UI will be accessible on http://localhost:5214/swagger/index.html
To not overload HackerNews API, the in-memory cache was used for test purposes only. The In-mem approach is not horizontally scalable so in real scenarios some external key/value storage should be used. (redis and so on)
I did not find any confirmation in docs that beststories.json
endpoint returns ids sorted in descending by score order but according to tests, it looks like it is true. My assumption is beststories.json returns ids in descending by score order and I can load story details only for the first N
ids.
In case it is not true it needs to load all stories to be able to sort them, which would require a warm-up cache by first requests after application start.
- Adding AutoMapper configuration to map from HackerNews API model
Phi.Model.Client.Story
to API modelPhi.Model.API.Story
- Dockerize the application to not depend on the environment.
- Think about the cache invalidation mechanism in case data is changed.
- Adding sturtup check in case if configuration is not valid.
- Adding more unit tests.