Skip to content
cloud-tekPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

405 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Hive

.NET Version C# Version Version

An opinionated, extensible microservices framework for .NET 10 that provides a plugin-based architecture for building production-ready services with minimal boilerplate.


Table of Contents


Overview

Hive is a comprehensive .NET microservices framework that embraces:

  • Extension-based architecture - All features are implemented as extensions to the core IMicroService abstraction
  • Configuration flexibility - Pre-configuration and post-configuration patterns with validation
  • Multiple hosting models - REST APIs, GraphQL, gRPC, MCP servers, background jobs, and Azure Functions
  • Production-ready observability - Built-in OpenTelemetry integration for logs, traces, and metrics
  • Testing utilities - Comprehensive testing support with xUnit extensions and TestServer integration
  • Kubernetes-ready - Built-in health probes and lifecycle management

Design Principles

Hive follows these core principles:

  • KISS (Keep It Simple, Stupid) - Straightforward code that beginners can follow
  • YAGNI (You Aren't Gonna Need It) - Implement only explicitly defined features
  • SOLID - Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion
  • Extension Pattern - All features are opt-in via extensions
  • Configuration Validation - Fail fast at startup with detailed error messages

Key Features

Core Framework

  • βœ… Extension-based architecture - Plugin all features via MicroServiceExtension
  • βœ… Lifecycle management - Initialize β†’ Start β†’ Stop β†’ Dispose pattern
  • βœ… Configuration validation - DataAnnotations, FluentValidation, and custom delegates
  • βœ… Pre/Post configuration - Configure before or after IServiceProvider is built
  • βœ… Kubernetes integration - Built-in /startup, /readiness, /liveness probes

Hosting Models

  • βœ… REST APIs - Minimal APIs and traditional MVC controllers
  • βœ… GraphQL - HotChocolate integration
  • βœ… gRPC - Standard protobuf-first and code-first approaches
  • βœ… MCP - Model Context Protocol servers via the official SDK (streamable HTTP transport)
  • βœ… Background Jobs - Worker services and scheduled tasks
  • βœ… Azure Functions - Azure Functions Worker integration (docs)

Observability

  • βœ… OpenTelemetry - Unified logging, tracing, and metrics
  • βœ… OTLP export - Send telemetry to OpenTelemetry collectors
  • βœ… Resource attributes - Automatic service identification
  • βœ… Automatic instrumentation - ASP.NET Core, HTTP Client, Runtime metrics

Developer Experience

  • βœ… Testing utilities - xUnit attributes, port providers, test extensions
  • βœ… TestServer integration - In-memory integration testing
  • βœ… Environment-aware - Different configs per environment
  • βœ… Centralized package management - All versions in Directory.Packages.props

Architecture

graph TB
    subgraph "Foundation"
        Abstractions[Hive.Abstractions
Core abstractions & interfaces] Testing[Hive.Testing
Testing utilities] end subgraph "Observability" OpenTelemetry[Hive.OpenTelemetry
Logs, Traces, Metrics] end subgraph "Extensions" HTTP[Hive.HTTP
Typed HTTP Clients] Messaging[Hive.Messaging
Wolverine Messaging] HealthChecks[Hive.HealthChecks
Readiness Gating] end subgraph "Microservices Framework" MicroServices[Hive.MicroServices
Core orchestration] Api[Hive.MicroServices.Api
REST APIs] GraphQL[Hive.MicroServices.GraphQL
GraphQL APIs] Grpc[Hive.MicroServices.Grpc
gRPC Services] Mcp[Hive.MicroServices.Mcp
MCP Servers] Job[Hive.MicroServices.Job
Background Workers] MSTesting[Hive.MicroServices.Testing
Integration Testing] end subgraph "Azure Functions" Functions[Hive.Functions
Serverless Functions] end Abstractions --> Testing Abstractions --> OpenTelemetry Abstractions --> MicroServices Abstractions --> Functions MicroServices --> Api MicroServices --> GraphQL MicroServices --> Grpc MicroServices --> Mcp MicroServices --> Job MicroServices --> MSTesting MicroServices --> HTTP MicroServices --> Messaging MicroServices --> HealthChecks style Abstractions fill:#e1f5ff,stroke:#01579b,stroke-width:3px style MicroServices fill:#81d4fa,stroke:#0277bd,stroke-width:2px style OpenTelemetry fill:#b3e5fc,stroke:#0288d1 style Functions fill:#b3e5fc,stroke:#0288d1 style HTTP fill:#c8e6c9,stroke:#2e7d32 style Messaging fill:#c8e6c9,stroke:#2e7d32 style HealthChecks fill:#c8e6c9,stroke:#2e7d32
Loading

Repository Structure

Hive is organized as a monorepo with distinct modules:

hive/
β”œβ”€β”€ hive.core/                          # Foundation layer
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ Hive.Abstractions/         # Core abstractions & interfaces
β”‚   β”‚   └── Hive.Testing/              # Testing utilities
β”‚   └── tests/
β”‚       └── Hive.Abstractions.Tests/
β”‚
β”œβ”€β”€ hive.extensions/                    # Feature extensions
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ Hive.HTTP/                 # Typed HTTP clients (Refit)
β”‚   β”‚   β”œβ”€β”€ Hive.HTTP.Testing/         # HTTP testing utilities
β”‚   β”‚   β”œβ”€β”€ Hive.Messaging/            # Messaging abstractions (Wolverine)
β”‚   β”‚   β”œβ”€β”€ Hive.Messaging.RabbitMq/   # RabbitMQ transport
β”‚   β”‚   └── Hive.HealthChecks/         # Threshold-based readiness gating
β”‚   └── tests/
β”‚       β”œβ”€β”€ Hive.HTTP.Tests/
β”‚       β”œβ”€β”€ Hive.Messaging.Tests/
β”‚       β”œβ”€β”€ Hive.Messaging.RabbitMq.Tests/
β”‚       └── Hive.HealthChecks.Tests/
β”‚
β”œβ”€β”€ hive.microservices/                 # Microservices framework
β”‚   β”œβ”€β”€ demo/                           # Demo applications
β”‚   β”‚   β”œβ”€β”€ Hive.MicroServices.Demo.Api/
β”‚   β”‚   └── Hive.MicroServices.Demo.Aspire/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ Hive.MicroServices/        # Core framework
β”‚   β”‚   β”œβ”€β”€ Hive.MicroServices.Api/    # REST API support
β”‚   β”‚   β”œβ”€β”€ Hive.MicroServices.GraphQL/
β”‚   β”‚   β”œβ”€β”€ Hive.MicroServices.Grpc/
β”‚   β”‚   β”œβ”€β”€ Hive.MicroServices.Mcp/
β”‚   β”‚   β”œβ”€β”€ Hive.MicroServices.Job/
β”‚   β”‚   └── Hive.MicroServices.Testing/
β”‚   └── tests/
β”‚       └── Hive.MicroServices.Tests/
β”‚
β”œβ”€β”€ hive.opentelemetry/                 # OpenTelemetry integration
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   └── Hive.OpenTelemetry/
β”‚   └── tests/
β”‚       └── Hive.OpenTelemetry.Tests/
β”‚
β”œβ”€β”€ hive.functions/                     # Azure Functions integration
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   └── Hive.Functions/
β”‚   β”œβ”€β”€ demo/
β”‚   β”‚   └── Hive.Functions.Demo/
β”‚   └── tests/
β”‚       └── Hive.Functions.Tests/
β”‚
β”œβ”€β”€ Directory.Packages.props            # Centralized package versions
β”œβ”€β”€ Directory.Build.props               # Global MSBuild properties
β”œβ”€β”€ Version.targets                     # Version source of truth
β”œβ”€β”€ Hive.sln                           # Solution file
└── README.md                          # This file

Module Naming Convention

Modules follow lowercase naming with dot separators:

  • βœ… hive.core
  • βœ… hive.extensions
  • βœ… hive.microservices
  • βœ… hive.opentelemetry
  • βœ… hive.functions

Each module MUST follow the structure:

{module-name}/
β”œβ”€β”€ src/        # Source code projects (mandatory)
β”œβ”€β”€ tests/      # Test projects (optional)
└── demo/       # Demo applications (optional)

πŸ“– Complete Repository Policies


Quick Start

Prerequisites

Basic REST API Example

using Hive;
using Hive.MicroServices.Api;
using Hive.OpenTelemetry;

var service = new MicroService("hello-api")
    .WithOpenTelemetry()  // Add observability
    .ConfigureApiPipeline(endpoints =>
    {
        endpoints.MapGet("/", () => "Hello from Hive!");
        endpoints.MapGet("/health", () => Results.Ok("Healthy"));
    });

await service.RunAsync();

With Configuration and Services

var config = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json")
    .AddEnvironmentVariables()
    .Build();

var service = new MicroService("my-api")
    .WithOpenTelemetry()
    .ConfigureServices((services, configuration) =>
    {
        services.AddSingleton<IMyService, MyService>();
        services.ConfigureValidatedOptions<MyOptions>(
            configuration.GetSection("MyOptions")
        );
    })
    .ConfigureApiPipeline(endpoints =>
    {
        endpoints.MapGet("/api/data", async (IMyService myService) =>
        {
            var data = await myService.GetDataAsync();
            return Results.Ok(data);
        });
    });

await service.RunAsync(config);

Running the Demo

# Clone the repository
git clone https://github.com/cloud-tek/hive.git
cd hive

# Run the API demo
dotnet run --project hive.microservices/demo/Hive.MicroServices.Demo.Api

# Or run all demos via Aspire
dotnet run --project hive.microservices/demo/Hive.MicroServices.Demo.Aspire

Modules

Foundation layer providing core abstractions and testing utilities.

Packages:

  • Hive.Abstractions - Core abstractions, configuration patterns, extension base classes
  • Hive.Testing - xUnit attributes, test extensions, port providers

Key Features:

  • IMicroServiceCore and IMicroService interfaces
  • MicroServiceExtension base class with compile-time safety
  • Pre/post configuration patterns with validation
  • Test categorization attributes via CloudTek.Testing ([UnitTest], [IntegrationTest], etc.)

πŸ“– Read Full Documentation


Feature extensions for messaging, HTTP clients, and health checks.

Packages:

Key Features:

  • Typed HTTP clients with authentication, circuit breakers, and telemetry
  • Wolverine-based messaging with readiness middleware
  • Health check registry with configurable thresholds and startup gating
  • Cross-extension tracing via IActivitySourceProvider

πŸ“– Read Full Documentation


Comprehensive microservices framework with multiple hosting models.

Packages:

Key Features:

  • Extension-based architecture
  • Multiple pipeline modes (Api, GraphQL, gRPC, Mcp, Job)
  • Built-in CORS support with validation
  • Kubernetes probe endpoints
  • Lifecycle management (Initialize β†’ Start β†’ Stop β†’ Dispose)

πŸ“– Read Full Documentation


OpenTelemetry integration for production-ready observability.

Packages:

Key Features:

  • Zero-configuration defaults
  • Declarative configuration via appsettings.json
  • OTLP export to OpenTelemetry collectors
  • Automatic instrumentation (ASP.NET Core, HTTP Client, Runtime)
  • Resource attributes with service identification
  • Environment-aware configuration

Example:

var service = new MicroService("my-service")
    .WithOpenTelemetry()  // That's it!
    .ConfigureApiPipeline(app => { });

πŸ“– Read Full Documentation


Azure Functions integration following the same extension pattern.

Packages:

  • Hive.Functions - Azure Functions Worker integration with Hive framework

Key Features:

  • IFunctionHost implementing IMicroServiceCore
  • Extension-based architecture (OpenTelemetry, configuration validation)
  • Native Azure Functions Worker support
  • HTTP, Timer, Queue, and Blob triggers
  • Automatic Application Insights integration

πŸ“– Read Full Documentation πŸ“– Read Design Document


Building and Testing

Using CloudTek.Build.Tool (Recommended)

# Install the build tool (if not already installed)
dotnet tool install CloudTek.Build.Tool

# Run complete build (all targets)
dotnet tool run cloudtek-build --target All

# Quick build (skip checks)
dotnet tool run cloudtek-build --target All --Skip RunChecks

Using dotnet CLI

# Build entire solution
dotnet build Hive.sln

# Build specific configuration
dotnet build -c Release

# Run all tests
dotnet test Hive.sln

# Run tests by category
dotnet test --filter Category=UnitTests
dotnet test --filter Category=IntegrationTests

# Run specific test
dotnet test --filter FullyQualifiedName~MyTestClass.MyTestMethod

Test Categories

Hive uses custom xUnit attributes for test categorization:

Attribute Category Use Case
[UnitTest] UnitTests Fast, isolated unit tests
[IntegrationTest] IntegrationTests Integration tests with dependencies
[ModuleTest] ModuleTests Module-level tests
[SmokeTest] SmokeTests Quick validation tests
[SystemTest] SystemTests End-to-end system tests

Documentation

For the full documentation index β€” design docs, topic guides, build reference, and all package READMEs β€” see docs/README.md.

Project Documentation

Module Documentation

Design Documents


Development Workflow

Creating a New Extension

public class MyExtension : MicroServiceExtension<MyExtension>
{
    public MyExtension(IMicroServiceCore service) : base(service)
    {
        // Configure during construction
        ConfigureActions.Add((services, config) =>
        {
            services.AddSingleton<IMyService, MyService>();
        });
    }

    public override IServiceCollection ConfigureServices(
        IServiceCollection services, IMicroServiceCore microservice)
    {
        // Additional service configuration
        return services;
    }

    public override IApplicationBuilder Configure(
        IApplicationBuilder app, IMicroServiceCore microservice)
    {
        app.UseMiddleware<MyMiddleware>();
        return app;
    }

    public override IEndpointRouteBuilder ConfigureEndpoints(
        IEndpointRouteBuilder builder)
    {
        builder.MapGet("/my-endpoint", () => "Hello!");
        return builder;
    }
}

// Usage
var service = new MicroService("my-service")
    .RegisterExtension<MyExtension>()
    .ConfigureApiPipeline(endpoints => { });

Adding a New Module

When creating a new module:

  1. Create module folder with lowercase naming: hive.mymodule/
  2. Follow mandatory structure:
    hive.mymodule/
    β”œβ”€β”€ src/          # Source code projects (MANDATORY)
    β”œβ”€β”€ tests/        # Test projects (optional)
    └── demo/         # Demo applications (optional)
    
  3. Add projects to Hive.sln
  4. Use centralized versioning via Version.targets
  5. Update Directory.Packages.props for new NuGet dependencies

πŸ“– Complete Guidelines


Dependency Management

Hive uses centralized package management:

Adding a New Package

  1. Add version to Directory.Packages.props:

    <PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
  2. Reference in project WITHOUT version:

    <PackageReference Include="Newtonsoft.Json" />

Kubernetes Deployment

All Hive microservices include built-in Kubernetes support:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-hive-service
spec:
  template:
    spec:
      containers:
      - name: app
        image: my-hive-service:latest
        ports:
        - containerPort: 8080
        env:
        - name: ASPNETCORE_ENVIRONMENT
          value: "Production"
        - name: OTEL_EXPORTER_OTLP_ENDPOINT
          value: "http://otel-collector:4317"
        startupProbe:
          httpGet:
            path: /startup
            port: 8080
          failureThreshold: 30
          periodSeconds: 10
        livenessProbe:
          httpGet:
            path: /liveness
            port: 8080
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: /readiness
            port: 8080
          periodSeconds: 5

Contributing

This is a monorepo project. When contributing:

  1. Follow Repository Policies - See .claude/rules/repository-policies.md
  2. Use Test Attributes - Categorize tests with [UnitTest], [IntegrationTest], etc.
  3. Follow SOLID Principles - Keep code simple, extensible, and maintainable
  4. Validate Configuration - Always validate configuration with FluentValidation or DataAnnotations
  5. Write Tests - All features require unit and integration tests
  6. Update Documentation - Keep README files synchronized with code changes

Git Workflow

# Create feature branch
git checkout -b feature/my-feature

# Make changes and commit
git add .
git commit -m "feat: add my feature"

# Run tests before pushing
dotnet test Hive.sln

# Push and create PR
git push origin feature/my-feature

License

[Check Repository License]


Repository


Support

For issues, questions, or feature requests:

  • Open an issue on GitHub Issues
  • Refer to module-specific documentation linked above
  • Check the CLAUDE.md for detailed project information

Built with ❀️ using .NET 10 and C# 14

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages