How captainsafia/minapi-sse works
Main Components
• API Server:
• Represented by Program.cs, which is the main entry point of the application.
• Configured via the MinimalServerSentEvents.csproj and the global.json (to align .NET tooling).
• Endpoints and SSE Logic:
• Minimal API endpoints that expose paths such as “/string-item”, “/json-item”, and “/sse-item” (and the sample “/sse-endpoint” shown in the README).
• That these endpoints use the TypedResults.ServerSentEvents API to stream data to clients.
• Configuration Components:
• “appsettings.json” and “appsettings.Development.json” which supply configuration details (i.e., hosting settings, logging, etc.).
• The “Properties/launchSettings.json” outlines the local development environment settings (such as ports and environment variables).
• External Clients:
• External consumers (or browsers) that connect to the API endpoints to receive streamed data.
• Framework & Libraries:
• That the system leverages .NET minimal API, ASP.NET Core hosting, and built-in configuration with dependency injection.
Relationships and Interactions
• Inside the API Server, indicate that incoming HTTP requests are processed by minimal API route handlers defined in Program.cs.
• Points where data is “streamed” back to the client using SSE (via the TypedResults.ServerSentEvents abstraction) should be clearly shown, with a note on the continuous asynchronous stream mechanism (using IAsyncEnumerable).
• Cancellation token mechanism flowing from the ASP.NET Core HTTP context into the SSE logic, ensuring proper cleanup.
Important Architectural Patterns and Design Principles
• Minimal API Pattern:
• That the project leverages the minimal API style, meaning it does not employ the MVC pattern or controllers; all endpoint mappings are done directly in Program.cs.
• Event Streaming:
• Use of server-sent events as a streaming method, with considerations for long-lived HTTP connections.
• Configuration & Environment Separation:
• Separate treatment of configuration files (appsettings.json vs. appsettings.Development.json) based on the environment.
Relevant Technologies and Tools
• .NET 10 Preview 3 and the Minimal APIs feature.
• ASP.NET Core hosting (for managing HTTP requests/responses).
• TypedResults for handling strongly-typed HTTP responses, especially for SSE.
• The use of global.json to specify tooling versions.