Nowfeeds is a modular .NET 8 application that aggregates local weather, news, and social feeds. It is designed with clean architecture principles, supports dependency injection with Autofac, and is ready for scalable caching, logging, and metrics solutions.
- Aggregates weather, news, and social feeds for a given city
- Clean separation of Application, Infrastructure, Domain, and API layers
- Extensible caching (in-memory by default, Redis-ready, distributed cache support)
- External API integration (OpenWeatherMap, Twitter)
- Exception handling middleware
- AutoMapper for DTO mapping
- Serilog for structured logging (file, Elasticsearch-ready)
- Health checks endpoint
- Metrics collection and reporting for external service calls
- Swagger/OpenAPI documentation
- xUnit test project for infrastructure and application services
- Nowfeeds.Api: ASP.NET Core Web API, controllers, middleware, API models, startup configuration, health checks, and Swagger
- Nowfeeds.Application: Application logic, interfaces, DTOs, business rules, and shared extensions
- Nowfeeds.Infrastructure: External service integrations, cache implementations, decorators, metrics, and configuration
- Nowfeeds.Domain: Core domain models and value objects
- Nowfeeds.Test: xUnit test project for unit and integration tests
- .NET 8 SDK
- (Optional) Redis for distributed caching
- (Optional) Elasticsearch for log aggregation
- Update
appsettings.jsonandappsettings.Development.jsonwith your API keys and service endpoints for OpenWeatherMap and Twitter. - Configure the
InfrastructureConfigurationsection for external services and cache settings. - Configure Serilog in
appsettings.jsonfor file or Elasticsearch logging. - For Redis, set the
ConnectionStrings:Redisvalue.
# Restore dependencies
dotnet restore
# Build the solution
dotnet build
# Run the API
dotnet run --project Nowfeeds.Api- Swagger UI is available at
/swaggerwhen running in Development mode.
- The app uses a generic
ICacheServiceinterface. - Default implementation is in-memory (
InMemoryCacheService). - Distributed cache (
CacheService) supports Redis or SQL Server viaIDistributedCache. - To use Redis, configure
AddStackExchangeRedisCacheinProgram.csand update DI registration.
- Serilog is configured for console and file logging by default.
- Logs are written to
logs/log-.txtwith daily rolling. - To write logs in Elasticsearch format, use the
Serilog.Formatting.Elasticsearchpackage and configure the file sink inProgram.cs.
- Health check endpoint is available at
/health. - Add custom or external service checks in
Program.csas needed.
- HTTP client calls to external services are decorated to record metrics (request count, success/failure, response time, etc.).
- Metrics are stored in cache and can be retrieved via the metrics service.
- Metrics endpoint:
/api/Metrics
- The
Nowfeeds.Testproject contains xUnit tests for infrastructure and application services. - To run tests:
dotnet test- Autofac is used as the DI container.
- Modules are registered in
Program.cs. - Decorators are used for cross-cutting concerns like metrics.
- Custom middleware (
ExceptionsMiddleware) handles validation and general exceptions, returning structured API responses.
- Add new external services by implementing interfaces in
Nowfeeds.Applicationand providing concrete classes inNowfeeds.Infrastructure. - Add new API endpoints in
Nowfeeds.Api.Controllersand map results to API models using AutoMapper. - Add new health checks or metrics as needed.
Example request to get local feeds:
GET /api/feeds/getlocalfeeds?city=Thessaloniki