A clean, layered ASP.NET Core Web API for querying and exposing Wikipedia data, following best practices for configuration, separation of concerns, and maintainability.
- Configuration & Settings
appsettings.json: Centralized configuration (API endpoints, etc.)Settings/WikipediaApiSettings.cs: Strongly-typed settings class
- Data Models & DTOs
Models/WikipediaModels.cs: Raw models matching Wikipedia API responsesDTOs/: Clean, public-facing data transfer objects (DTOs)
- Service Layer
Services/IWikipediaService.cs: Service interface (business logic contract)Services/WikipediaService.cs: Implementation (fetches, transforms, and returns data)
- Controller Layer
Controllers/WikipediaController.cs: Thin API controller exposing endpoints
- Entry Point
Program.cs: Configures DI, settings, middleware, and starts the app
- Configuration: All external values (like Wikipedia API URLs) are stored in
appsettings.jsonand mapped to a POCO for type safety. - Models & DTOs: Models mirror the raw Wikipedia API; DTOs are what your API returns to clients.
- Service Layer: Handles all business logic, HTTP calls, and data transformation. Exposes simple async methods.
- Controller: Receives HTTP requests, validates input, and delegates to the service layer. No business logic here.
- Startup:
Program.cswires everything together, registers services, and configures middleware.
- Clone the repository
- Configure your settings
- Edit
appsettings.jsonwith your Wikipedia API endpoints or credentials if needed.
- Edit
- Build and run
- Using the .NET CLI:
dotnet build dotnet run --project wikidata_explorer.sln
- Or use the provided VS Code tasks (
build,watch,publish).
- Using the .NET CLI:
- Explore the API
- Swagger UI is available at
/swaggerwhen running locally.
- Swagger UI is available at
GET /api/wikipedia/search?query=...— Search Wikipedia articlesGET /api/wikipedia/pages— List available Wikipedia page endpoints
- All configuration is externalized and strongly typed
- Models and DTOs are clearly separated
- Business logic is isolated in services
- Controllers are thin and focused
- Dependency Injection is used throughout
- Global exception handling is configured
- Fork the repo and create your branch
- Make your changes (keep layers clean and follow the blueprint)
- Submit a pull request
MIT License