frank-fs / frank
F# computation expressions for defining HTTP resources and configuring IWebHostBuilder.
AI Architecture Analysis
This repository is indexed by RepoMind. By analyzing frank-fs/frank in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.
Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.
Repository Overview (README excerpt)
Crawler viewFrank F# computation expressions, or builders, for configuring the and defining routes for HTTP resources using . This project was inspired by @filipw's Building Microservices with ASP.NET Core (without MVC). --- Packages | Package | Description | NuGet | |---------|-------------|-------| | **Frank** | Core computation expressions for WebHost and routing | | | **Frank.Auth** | Resource-level authorization extensions | | | **Frank.OpenApi** | Native OpenAPI document generation with F# type schemas | | | **Frank.Datastar** | Datastar SSE integration for reactive hypermedia | | | **Frank.LinkedData** | Semantic RDF/Linked Data content negotiation middleware | | | **Frank.Cli.MSBuild** | MSBuild integration for auto-embedding semantic artifacts | | | **Frank.Statecharts** | Application-level state machines for stateful hypermedia resources | | | **Frank.Analyzers** | F# Analyzers for compile-time error detection | | | **Frank.Statecharts** | Stateful resources with state machines, guards, and WSD parser | | | **Frank.Validation** | SHACL shape validation derived from F# types | | | **Frank.Provenance** | PROV-O provenance tracking for resource state changes | | Package Dependency Graph --- Features • - computation expression for configuring • - computation expression for configuring resources (routing) • **No** pre-defined view engine - use your preferred view engine implementation, e.g. Falco.Markup, Oxpecker.ViewEngine, or Hox • Easy extensibility - just extend the with your own methods! Basic Example --- Middleware Pipeline Frank provides two middleware operations with different positions in the ASP.NET Core pipeline: Use for middleware that must run **before** routing decisions are made: • **HttpsRedirection** - redirect before routing • **StaticFiles** - serve static files without routing overhead • **ResponseCompression** - compress all responses • **ResponseCaching** - cache before routing Use for middleware that needs routing information (e.g., the matched endpoint): • **Authentication** - may need endpoint metadata • **Authorization** - requires endpoint to check policies • **CORS** - may use endpoint-specific policies Conditional Middleware Both and run in the position (after routing): Conditional Before-Routing Middleware Both and run in the position (before routing): --- Frank.Auth Frank.Auth provides resource-level authorization for Frank applications, integrating with ASP.NET Core's built-in authorization infrastructure. Installation Protecting Resources Add authorization requirements directly to resource definitions: Application Wiring Configure authentication and authorization services using Frank's builder syntax: Authorization Patterns | Pattern | Operation | Behavior | |---------|-----------|----------| | Authenticated user | | 401 if unauthenticated, 200 if authenticated | | Claim (single value) | | 403 if claim missing or wrong value | | Claim (multiple values) | | 200 if user has any listed value (OR) | | Role | | 403 if user not in role | | Named policy | | Delegates to registered policy | | Multiple requirements | Stack multiple | AND semantics — all must pass | | No requirements | (default) | Publicly accessible, zero overhead | --- Frank.OpenApi Frank.OpenApi provides native OpenAPI document generation for Frank applications, with first-class support for F# types and declarative metadata using computation expressions. Installation HandlerBuilder Computation Expression Define handlers with embedded OpenAPI metadata using the computation expression: HandlerBuilder Operations | Operation | Description | |-----------|-------------| | | Sets the OpenAPI operationId | | | Brief summary of the operation | | | Detailed description | | | Categorize endpoints | | | Define response type and status code | | | Response with content negotiation | | | Empty responses (204, 404, etc.) | | | Define request body type | | | Request with content negotiation | | | Handler function (supports Task, Task , Async , Async ) | F# Type Schema Generation Frank.OpenApi automatically generates JSON schemas for F# types: WebHostBuilder Integration Enable OpenAPI document generation in your application: The OpenAPI document will be available at . Content Negotiation Define multiple content types for requests and responses: Backward Compatibility Frank.OpenApi is fully backward compatible with existing Frank applications. You can: • Mix and plain handlers in the same resource • Add OpenAPI metadata incrementally without changing existing code • Use the library only where you need API documentation --- Frank.LinkedData Frank.LinkedData provides automatic RDF content negotiation for Frank applications. Endpoints marked with can serve JSON-LD, Turtle, and RDF/XML representations alongside standard JSON — driven by an OWL ontology extracted from your F# domain types. Installation The package auto-embeds semantic artifacts (ontology, SHACL shapes, manifest) into your assembly at build time. Marking Resources Add to any resource to enable RDF content negotiation: Application Wiring Content Negotiation Clients request RDF formats via the header: | Accept Header | Response Format | |---------------|----------------| | | JSON-LD | | | Turtle | | | RDF/XML | | (or any other) | Original JSON (pass-through) | Semantic Toolchain Use to extract an ontology from your F# types: The compiled artifacts are automatically embedded by and loaded at startup by . --- Frank.Datastar Frank.Datastar provides seamless integration with Datastar, enabling reactive hypermedia applications using Server-Sent Events (SSE). **Version 7.1.0** features a **native SSE implementation** with zero external dependencies, delivering high-performance Server-Sent Events directly via ASP.NET Core's API. Supports .NET 8.0, 9.0, and 10.0. Installation Example Available Operations • - Update HTML elements in the DOM • - Update client-side signals • - Remove elements by CSS selec…