Skip to content

About

A fast, lightweight, efficient, and thoughtfully crafted .NET microkernel development framework. It serves as the backend foundation for the XiHanFun open-source ecosystem.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

114 stars

Watchers

3 watching

Forks

Repository files navigation

XiHan.Framework, a fast, lightweight, efficient, thoughtful .NET framework: microkernel, capability graph, pipeline execution

One operation contract, served over HTTP, gRPC, MCP and the command line

CI NuGet .NET 10 MIT License GitHub Stars Gitee Stars GitCode Stars

Docs · Getting Started · Samples · Packages · Specification · Changelog

English | 简体中文

XiHan.Framework is a .NET application framework for long-lived systems, built on a microkernel, a capability graph and an execution pipeline. It is also the reference implementation of the language-neutral XiHan Spec.

Features

Feature Description
Operation contracts Declared once, exposed over many protocols, sharing schema, authorization and error codes
Capability graph Dependencies declared by capability ID, resolved and validated before startup
Execution pipeline Eleven fixed stages for authentication, tenancy, authorization, validation, idempotency and transactions
Replaceable implementations Defaults with no external dependencies; providers pass the same conformance suite
Native AOT Reflection-free kernel, with registration code and schemas generated at compile time
Plugins In-process, Wasm and out-of-process isolation, in multiple languages, with failures contained from the host
AI integration Operations as MCP tools and model tools, plus an offline knowledge base for coding assistants

Getting Started

dotnet add package XiHan.Framework.Profiles.Minimal --prerelease
dotnet add package XiHan.Framework.Protocols.Http --prerelease
dotnet add package XiHan.Framework.Kernel.Generators --prerelease
[Operation("greetings.create")]
public sealed class Greet : IOperation<GreetRequest, GreetResponse>
{
    public ValueTask<Result<GreetResponse>> HandleAsync(GreetRequest request, InvocationContext context)
        => ValueTask.FromResult(Result.Success(new GreetResponse($"Hello, {request.Name}!")));
}

Protocol entry points derive from the contract and take effect once the matching protocol package is added:

HTTP gRPC MCP Command line
POST /greetings Greetings/Create greetings_create greetings create --name Ada

The feature manifest, serializer context and application entry point are covered in the quickstart.

Architecture

%%{init: {"flowchart": {"wrappingWidth": 560}}}%%
flowchart TB
    subgraph protocols["Protocol adapters"]
        direction LR
        http["HTTP · OpenAPI"] ~~~ grpc["gRPC"] ~~~ mcp["MCP"] ~~~ cli["Command line"] ~~~ events["CloudEvents"]
    end

    pipeline["<b>Kernel pipeline: eleven fixed stages</b><br/>Ingress → Observe → Resilience → Authenticate → Tenant → Authorize<br/>→ Validate → Idempotency → Transaction → Handle → Egress"]

    operation["<b>Operation contract</b><br/>IOperation&lt;TRequest, TResponse&gt;"]

    subgraph capabilities["Capabilities"]
        direction LR
        abstractions["Abstractions<br/>repositories · cache · messaging · object storage …"] --> implementations["Default implementation (no external infrastructure)<br/>or provider (EF Core, Redis, Kafka, S3 …)"]
    end

    protocols --> pipeline --> operation --> capabilities
Loading

Three tiers of promise, after the I Ching's unchanging (不易), simple (简易) and changing (变易). Dependencies point only to lower rings, enforced by architecture tests. See the overall design (in Chinese).

Tier Scope Promise
Unchanging Primitives Never breaks, only grows
Simple Kernel No breaking changes within a major version
Changing Abstractions, implementations, hosts, protocols, plugins, profiles Evolves independently, with compatibility held by conformance tests

Capabilities

Capability Default Providers
Persistence In-memory EF Core, SqlSugar
Caching and distributed locks In-memory Redis, two-level cache, remote plugin
Messaging In-memory, with outbox RabbitMQ, Kafka, Redis Streams, CloudEvents webhook
Multi-tenancy In-memory Database, with per-tenant databases
Authentication and authorization In-memory (API key, RBAC) JWT, OpenID Connect, database
Scheduling In-memory Database (clustered), Kubernetes (leader election)
Workflow In-memory Database
Object storage File system S3 and compatible services
Auditing In-memory Database
Localization In-memory (10 locales) Database
Configuration .NET configuration Nacos
Observability System.Diagnostics OpenTelemetry
AI Tool bridge OpenAI-compatible endpoints, VectorData

Profiles: Profiles.Minimal (kernel and host), Profiles.Standard (adds the domain model and five subsystems), Profiles.Full (adds the remaining subsystems and four protocol adapters).

Samples

git clone --recurse-submodules --branch dev https://github.com/XiHanFun/XiHan.Framework.git
cd XiHan.Framework
dotnet run --project framework/samples/SimpleApp
Sample Contents
SimpleApp Standard profile: a multi-protocol order service with tenancy, authentication, permissions, transactions and an outbox; the Native AOT smoke test
SimpleCli Minimal profile: command line and MCP stdio
KubernetesApp Full profile: probes, graceful shutdown, configuration hot reload, leader election
Plugin samples In-process, out-of-process (.NET, Go) and Wasm (Rust)

Use Cases

  • Suited to: medium to large backends with long maintenance horizons; multi-tenant SaaS and enterprise admin systems; services exposed over several protocols; third-party plugins in multiple languages.
  • Not suited to: short-lived CRUD projects; projects that need built-in templating, search or a gateway.

See Why XiHan for selection criteria.

Quality

  • Gates: warnings as errors; architecture tests and analyzers enforce dependency direction, naming, reflection and third-party type leaks.
  • Public API: PublicAPI baselines, package validation and stability levels.
  • Conformance: defaults and providers share test suites, run in CI against PostgreSQL, SQL Server, MySQL, Oracle, Redis, RabbitMQ and Qdrant.
  • Decisions: public contracts begin as RFCs, and major decisions are recorded as ADRs.

Ecosystem

Project Description
framework-spec XiHan Spec: RFCs, vocabulary, protocol mappings and conformance vectors
framework-sdk-go Go SDK for out-of-process plugins and remote providers
XiHan.UI A fast, lightweight, efficient and thoughtfully built framework-agnostic headless UI component library
XiHan.BasicApp A beautifully crafted general-purpose admin kernel built on XiHan.Framework and XiHan.UI, and the framework's reference application

Documentation

The documentation site and design documents are written in Chinese.

Destination Contents
Quickstart From installation to the first operation
Guides Task-oriented docs by capability
Packages One page per package: capabilities, configuration keys, main types
Design documents Overall design, architecture notes and ADRs
Changelog Release notes and upgrade advisories

Connect a coding assistant (cursor, vscode and codex are also supported):

dnx XiHan.Framework.Cli --yes -- setup --client claude

Ask an AI: Zread · DeepWiki

Contributing

Issues and pull requests are welcome; see the contributing guide. Community: QQ group 462371834. Support the project: sponsorship page.

Acknowledgements

Project Influence
Abp The project that started it all, and the inspiration for parts of the architecture and design
Linux "Don't break userspace" and netfilter hook points: grow-only primitives and fixed pipeline stages
Go Small interfaces and context.Context: entities composed from interfaces, and an invocation context carrying cancellation, deadlines and tracing
Rust The core / std split, private by default and Result: host-independent primitives and failures as values
FastAPI Types as the contract: schemas generated from types, producing OpenAPI, .proto and MCP tools
OpenTelemetry Specification, multi-language SDKs and conformance tests: how XiHan Spec is organized

Other influences are listed in the overall design (in Chinese).

License

MIT © 2021-Present XiHanFun and contributors. The XiHan.Framework logo and name belong to the author.

About

A fast, lightweight, efficient, and thoughtfully crafted .NET microkernel development framework. It serves as the backend foundation for the XiHanFun open-source ecosystem.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

114 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages