Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions doc/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -454,22 +454,21 @@ builder.Services.AddNLWebNet();
// Map endpoints
app.MapNLWebNet();

// Use in controller/service
public class MyController : ControllerBase
// Use in service or endpoint
public class MyService
{
private readonly INLWebService _nlweb;

public MyController(INLWebService nlweb)
public MyService(INLWebService nlweb)
{
_nlweb = nlweb;
}

[HttpGet]
public async Task<IActionResult> Search(string query)
public async Task<NLWebResponse> SearchAsync(string query)
{
var request = new NLWebRequest { Query = query };
var response = await _nlweb.ProcessQueryAsync(request);
return Ok(response);
var response = await _nlweb.ProcessRequestAsync(request);
return response;
}
}
```
Expand Down
26 changes: 11 additions & 15 deletions doc/development-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ This document provides comprehensive guidance for developers working with the NL
### 1. Minimal API Approach

- **Primary approach**: Uses **Minimal APIs** for modern, lightweight endpoints
- **Legacy support**: Traditional controllers still present but being phased out
- Endpoints are organized in static classes: `AskEndpoints`, `McpEndpoints`
- Extension methods provide clean endpoint mapping: `app.MapNLWebNet()`
- Both `app.MapNLWebNet()` (minimal APIs) and `app.MapNLWebNetControllers()` (legacy) available
- Modern .NET 9 features including TypedResults for improved type safety

### 2. Dependency Injection

Expand All @@ -46,8 +45,8 @@ This document provides comprehensive guidance for developers working with the NL
### 3. Service Layer Architecture

```text
Controllers/Endpoints → Services → Data Backends
↘ MCP Integration
Endpoints → Services → Data Backends
↘ MCP Integration
```

Key interfaces:
Expand All @@ -65,14 +64,13 @@ Key interfaces:
- User secrets for sensitive data (API keys)
- Environment-specific configurations

### 5. Architectural Migration
### 5. Modern Architecture

**Important**: The project is transitioning from traditional MVC controllers to Minimal APIs.
The project uses **Minimal APIs exclusively** for a modern, lightweight approach.

- **Preferred**: Use `Endpoints/` classes with static mapping methods
- **Legacy**: `Controllers/` still exists but should not be extended
- **Extension methods**: Both approaches supported via `MapNLWebNet()` (minimal APIs) and `MapNLWebNetControllers()` (legacy)
- **New development**: Always use Minimal API patterns in the `Endpoints/` directory
- **Current**: Uses `Endpoints/` classes with static mapping methods and TypedResults
- **Extension methods**: Clean API surface via `MapNLWebNet()` for minimal APIs
- **Best practices**: .NET 9 features including TypedResults for type safety

## Code Conventions

Expand All @@ -82,8 +80,7 @@ Key interfaces:
- **Models**: Request/response DTOs with JSON serialization attributes
- **Services**: Interface + implementation pattern (`IService` → `Service`)
- **Extensions**: Static extension classes for framework integration
- **Endpoints**: Static classes with minimal API mapping methods (preferred)
- **Controllers**: Traditional MVC controllers (legacy, being phased out)
- **Endpoints**: Static classes with minimal API mapping methods

### C# Style Guidelines

Expand All @@ -99,9 +96,8 @@ Key interfaces:
src/NLWebNet/
├── Models/ # Request/response DTOs
├── Services/ # Business logic interfaces/implementations
├── Endpoints/ # Minimal API endpoint definitions (preferred)
├── Endpoints/ # Minimal API endpoint definitions with TypedResults
├── Extensions/ # DI and middleware extensions
├── Controllers/ # Legacy MVC controllers (being phased out)
├── MCP/ # Model Context Protocol integration
└── Middleware/ # Custom middleware components
```
Expand Down Expand Up @@ -203,7 +199,7 @@ src/NLWebNet/

### When Modifying Endpoints

1. **Use Minimal APIs** - Prefer `Endpoints/` classes over `Controllers/`
1. **Use Minimal APIs** - All endpoints use the modern `Endpoints/` classes with TypedResults
2. **Maintain protocol compliance** - Follow NLWeb specification
3. **Add OpenAPI documentation** - Use `.WithSummary()` and `.WithDescription()`
4. **Include error responses** - Proper status codes and problem details
Expand Down
17 changes: 10 additions & 7 deletions doc/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The NLWebNet library is now fully functional and feature complete with a modern
- ✅ **API Testing**: Comprehensive interface for testing all NLWeb endpoints
- ✅ **Modern UI**: Bootstrap-based responsive design with FontAwesome icons
- ✅ **Real-time Features**: Streaming demonstrations and live response displays
- ✅ **Minimal API Endpoints**: Converted Controllers to modern Minimal API endpoints with route groups and OpenAPI support
- ✅ **Minimal API Endpoints**: Modern Minimal API endpoints with TypedResults, route groups and OpenAPI support (legacy controllers completely removed)
- ✅ **Extension Methods**: Added `MapNLWebNet()` extension method for easy endpoint mapping in consuming applications
- ✅ **Dependency Injection**: Created `AddNLWebNet()` extension method with options configuration
- ✅ **GET/POST Support**: Both endpoints support GET and POST with appropriate parameter binding
Expand All @@ -73,7 +73,7 @@ The NLWebNet library is now fully functional and feature complete with a modern
- ✅ **Testing Framework**: Using MSTest 3.9.3 with NSubstitute 5.3.0 for comprehensive unit testing
- ✅ **Production Ready**: All builds (Debug/Release) work correctly, with properly configured NuGet packaging

**Phases 1-11 are now complete.** The library provides a complete implementation of the NLWeb protocol with both traditional controller-based endpoints (legacy) and modern minimal API endpoints for improved performance and maintainability. The project includes comprehensive configuration management, CORS support, extensive testing infrastructure, and complete documentation for real AI integration.
**Phases 1-11 are now complete.** The library provides a complete implementation of the NLWeb protocol using modern minimal API endpoints exclusively, fully migrated from legacy controllers. Features include improved performance and maintainability with .NET 9 TypedResults, comprehensive configuration management, CORS support, extensive testing infrastructure, and complete documentation for real AI integration.

**✅ MAJOR BREAKTHROUGH: NuGet Package PUBLISHED SUCCESSFULLY** - The NLWebNet package is now live on NuGet.org at <https://www.nuget.org/packages/NLWebNet/>! The package is fully functional with working extension methods accessible via `using NLWebNet;`. End-to-end testing confirms that consumer applications can successfully install the package, use the `AddNLWebNet()` and `MapNLWebNet()` extension methods, and run working HTTP servers.

Expand Down Expand Up @@ -278,21 +278,24 @@ All Phase 5 objectives have been completed successfully, initially using the tra
### Phase 6.5: Minimal API Migration (Completed)

- [x] **Convert Controllers to Minimal API Endpoints**:
- [x] Created `/src/NLWebNet/Endpoints/AskEndpoints.cs` with static endpoint methods
- [x] Created `/src/NLWebNet/Endpoints/McpEndpoints.cs` with static endpoint methods
- [x] Updated `ApplicationBuilderExtensions.MapNLWebNet()` to use endpoint mapping
- [x] Created `/src/NLWebNet/Endpoints/AskEndpoints.cs` with static endpoint methods and TypedResults
- [x] Created `/src/NLWebNet/Endpoints/McpEndpoints.cs` with static endpoint methods and TypedResults
- [x] Updated `ApplicationBuilderExtensions.MapNLWebNet()` to use endpoint mapping exclusively
- [x] Maintained feature parity with existing controller functionality for `/ask` endpoints
- [x] Implemented and enabled `/mcp` endpoints with full functionality
- [x] **REMOVED**: All legacy controller code (`AskController.cs`, `McpController.cs`)
- [x] **CLEANED**: Removed controller dependencies from DI registration
- [x] **Testing and Validation**:
- [x] Tested GET and POST endpoints for `/ask` with successful results
- [x] Fixed logger DI for minimal APIs by using ILoggerFactory
- [x] Fixed parameter binding and routing for minimal APIs
- [x] Added [FromServices] attributes to McpEndpoints parameters for proper DI
- [x] Complete test migration from controller tests to endpoint tests
- [x] **REMOVED**: Legacy controller test files

**Current Status**: Minimal API migration is complete, with all endpoints successfully implemented and tested. Both the `/ask` and `/mcp` endpoints (GET and POST) are fully functional and have been verified with test requests. The library builds successfully and can be consumed by applications with a clean, modern API. The migration to ILoggerFactory provides proper logging support in all endpoint methods.
**Current Status**: Complete migration to Minimal APIs with full removal of legacy controller code. All endpoints use modern .NET 9 patterns including TypedResults for better type safety. The library is now exclusively using Minimal APIs with improved performance and maintainability.

**Benefits**: More modern approach, better performance, cleaner API surface, improved compatibility with .NET 9 and future versions, and enhanced developer experience through fluent endpoint definitions.
**Benefits**: Modern .NET 9 approach with TypedResults, better performance, cleaner API surface, improved compatibility, enhanced developer experience, and complete removal of legacy code.

### Phase 7: Demo Application Development

Expand Down
209 changes: 0 additions & 209 deletions src/NLWebNet/Controllers/AskController.cs

This file was deleted.

Loading