This project is a RESTful API designed to fetch and deliver detailed information about the top n stories, sorted by their score in a descending order, from the Hacker News API. It’s built on .NET 9.0 and leverages Docker for containerization, while the testing framework uses xUnit in conjunction with TestContainers to ensure robust and isolated test environments.
- Technology Stack:
The API is developed with .NET 9.0, utilizes Docker for containerization, and is tested with xUnit and TestContainers to ensure reliable, isolated test environments. Stress tests are carried out using NBomber. - Exposed Endpoint:
The API exposes a single GET endpoint:http://localhost:8080/best-stories/{storyNumber} - Scalar Endpoint:
Although the project does not include a Swagger UI, it provides a Scalar endpoint for quick status checks and diagnostics:http://localhost:8080/scalar/ - Distributed Caching:
The API leverages Redis for distributed caching, improving performance by reducing the number of external calls to the Hacker News API.
- Clone https://github.com/rustamhajiyev/best-stories.git
- Move to the solution directory and restore dependencies
dotnet restore - Start the application suite
docker-compose up -d - Application should be up and running at http://localhost:8080
- Test GET /api/BestStories/{n} by inputting value for n, also the GET method can be tested using http://localhost:8080/best-stories/5 as well
- Unit test project can be run
cd HackerNews.API.IntegrationTests/ dotnet test - Stress test project can be run (while the app is running)
cd HackerNews.API.StressTests/ dotnet run - Stop the application suite
docker-compose down
Slowness in fetching the best stories is well understood as every new request (with different parameter) requires retrieval of all best stories from Hacker News API and getting story details for each story are bit of time-consuming tasks.
- Improve caching mechanism for faster API response time
- Improve exception handling
- Extend IntegrationTests with more cases
- Add support for HTTPS