HackerNewsApi
所属分类:系统/网络安全
开发工具:C#
文件大小:0KB
下载次数:0
上传日期:2024-02-28 16:47:39
上 传 者:
sh-1993
说明: 黑客新闻Api
(HackerNewsApi)
文件列表:
HackerNewsApi/
HackerNewsApiTests/
HackerNewsApi.sln
LICENSE
# Hacker News API Integration
## Overview
This project integrates with the `Hacker News API` (https://github.com/HackerNews/API) to fetch and cache the best stories. Designed as a read-biased in-memory temporal data store, it optimizes for high-read scenarios with efficient caching strategies to minimize external API calls.
## Getting Started
### Prerequisites
- .NET 6 SDK or later
- An IDE like Visual Studio 2019/2022, Visual Studio Code, or JetBrains Rider
- Docker (optional, for containerization)
### Running the Application
Clone the repository (It's a private repo, request access if you want to use it):
```bash
git clone https://github.com/JordiCorbilla/HackerNewsApi.git
```
### Navigate to the project directory:
```bash
cd HackerNewsApi
```
### Restore dependencies:
```bash
dotnet restore
```
### Build the project:
```bash
dotnet build
```
### Run the application:
```bash
dotnet run --project HackerNewsApi
```
Alternatively, use your IDE's run/debug functionality.
## Access the application:
The application will be available at [https://localhost:7007 or http://localhost:5171](https://localhost:7007/swagger/index.html) by default.
![image](https://github.com/JordiCorbilla/HackerNewsApi/assets/7347994/28686c52-fdb1-4593-b095-e5e064150c3d)
## Using Docker (Optional)
To containerize the application, ensure Docker is installed and running, then:
### Build the Docker image:
```bash
docker build -t hackernewsapi .
```
### Run the container:
```bash
docker run -p 8080:80 hackernewsapi
```
The application will now be accessible at https://localhost:49155/swagger/index.html.
![image](https://github.com/JordiCorbilla/HackerNewsApi/assets/7347994/af998ebe-96f6-4ab6-9404-8e659f2c5a99)
## Assumptions
- The Hacker News API remains stable and backward compatible.
- The application takes into account a safe-threading in-memory caching mechanism to avoid hitting the Hacker News API.
- The kids property has been left as it is (without continue fetching news).
- The application is primarily read-heavy, with frequent fetches for the best stories.
- Network latency and reliability between the application and the Hacker News API are not significant concerns.
- API Documentation: I have utilized Swagger/OpenAPI for API documentation to make the service more discoverable and easier to use for developers.
## Enhancements
Given more time, the following enhancements could be considered:
- Implement Distributed Caching: To better support scalability and high availability, integrating a distributed cache like Redis would be beneficial.
- Add Resilience Patterns: Implementing resilience patterns such as retries with exponential backoff, circuit breakers, and bulkheads would help improve the robustness of external API calls.
- Enhance Logging and Monitoring: Integrating with a centralized logging platform and adding more detailed metrics would facilitate better observability and troubleshooting.
- Automated Testing: Expanding the test suite to cover more scenarios, including performance and load testing, would ensure the application's reliability and scalability.
- Security Enhancements: Adding authentication, rate limiting, input validation, and securing sensitive configuration settings would improve the application's security posture.
近期下载者:
相关文件:
收藏者: