SparkToolkit 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package SparkToolkit --version 1.0.3
                    
NuGet\Install-Package SparkToolkit -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SparkToolkit" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SparkToolkit" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="SparkToolkit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SparkToolkit --version 1.0.3
                    
#r "nuget: SparkToolkit, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SparkToolkit@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SparkToolkit&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=SparkToolkit&version=1.0.3
                    
Install as a Cake Tool

๐Ÿ”ฅ SPARK โ€“ Service Pack and Rapid Kit

SPARK is a powerful, opinionated starter toolkit for building enterprise-grade microservices with .NET 8. It provides essential configurations, integrated libraries, and best practices to accelerate development while maintaining consistency and quality across your microservices architecture.

.NET Version License


โœจ Key Features

๐Ÿ—๏ธ Core Infrastructure

  • โœ… Centralized Configuration - Structured settings management with validation
  • ๐ŸŽฏ Dependency Injection - Advanced DI patterns with service discovery
  • ๐Ÿ›ก๏ธ Global Exception Handling - Comprehensive error management middleware
  • ๐Ÿ“Š API Versioning - Built-in versioning support with Swagger documentation

๐Ÿ”„ Message Queues & Communication

  • ๐Ÿฐ RabbitMQ Integration - Full MassTransit support with consumer discovery
  • ๐Ÿ“จ Redis Pub/Sub - High-performance message publishing and subscription
  • โšก Apache Kafka - Enterprise-grade streaming platform support
  • ๐ŸŽญ MediatR CQRS - Command/Query pattern with pipeline behaviors

๐Ÿ’พ Data Access & Storage

  • ๐Ÿ˜ PostgreSQL - Entity Framework Core with advanced configurations
  • ๐Ÿƒ MongoDB - Document database support with repository patterns
  • ๐Ÿ”ด Redis Caching - Distributed caching with connection multiplexing
  • ๐Ÿ“‹ Repository Pattern - Abstracted data access layer

๐Ÿ” Security & Authentication

  • ๐Ÿ”‘ JWT Authentication - Token-based authentication with Bearer support
  • ๐Ÿ›ก๏ธ Authorization - Role-based and policy-based access control
  • ๐ŸŒ CORS Configuration - Environment-based CORS policies

๐Ÿงช Development & Documentation

  • ๐Ÿ“– Swagger/OpenAPI - Auto-generated API documentation with Scalar UI
  • โœ… FluentValidation - Comprehensive model validation
  • ๐Ÿ—บ๏ธ AutoMapper - Object mapping with profile configurations
  • ๐Ÿ”ง Background Services - Scalable background task processing

๐Ÿ“ฆ Installation

dotnet add package SparkToolkit

๐Ÿš€ Quick Start

1. Initial Setup

# First time setup
.\setup.ps1

2. Basic Usage

var builder = WebApplication.CreateBuilder(args);

// Add SPARK libraries
builder.AddLibrary();

var app = builder.Build();

// Use SPARK middleware and configurations
await app.UseLibrary();

2. Configuration Setup

Add the following sections to your appsettings.json:

{
  "DocumentApiSetting": {
    "Title": "My Microservice API",
    "Description": "A powerful microservice built with SPARK"
  },
  "RedisSetting": {
    "ClientName": "MyService",
    "Host": "localhost",
    "Port": 6379,
    "User": "default",
    "Password": "your-password"
  },
  "RabbitMqSetting": {
    "Host": "localhost",
    "Username": "guest",
    "Password": "guest",
    "Port": 5672
  },
  "PostgresSetting": {
    "ConnectionString": "Host=localhost;Database=mydb;Username=postgres;Password=password",
    "CommandTimeout": 30,
    "RetryCount": 3,
    "RetryDelay": 1000
  },
  "MongoSetting": {
    "Username": "admin",
    "Password": "password",
    "Host": "localhost",
    "Port": "27017",
    "DatabaseName": "mydatabase"
  },
  "JwtSetting": {
    "SecurityKey": "your-super-secret-key-here",
    "Issuer": "your-issuer",
    "Audience": "your-audience",
    "TokenExpiry": 3600,
    "RefreshTokenExpiry": 86400
  },
  "WorkerSetting": {
    "MinWorkerCount": 1,
    "MaxWorkerCount": 10,
    "ScaleInterval": 1800,
    "TaskThresholdToScaleUp": 50,
    "TaskThresholdToScaleDown": 20
  }
}

๐Ÿ”ง Advanced Usage

Message Queue Integration

RabbitMQ with MassTransit
builder.Services.AddMassTransitWithRabbitMq(
    builder.Configuration,
    typeof(Program).Assembly  // Consumer assemblies
);
Redis Pub/Sub
// Register Redis Pub/Sub
builder.Services.AddRedisPubSub();

// Register message handlers
builder.Services.AddRedisMessageHandlers(typeof(Program).Assembly);

// Or register specific handlers
builder.Services.AddRedisMessageHandler<MyMessageHandler>("my-channel");

MediatR with Behaviors

builder.Services.AddMediatr(typeof(Program).Assembly);

Includes built-in behaviors:

  • Validation Behavior - FluentValidation integration
  • Caching Behavior - Automatic response caching
  • Transaction Behavior - Database transaction management

Entity Framework Configuration

public class MyEntity : BaseAuditableEntity<Guid>
{
    public string Name { get; set; } = string.Empty;
    public string Description { get; set; } = string.Empty;
}

public class MyEntityConfiguration : BaseConfiguration<MyEntity, Guid>
{
    public override void Configure(EntityTypeBuilder<MyEntity> builder)
    {
        base.Configure(builder);
        
        builder.Property(e => e.Name)
               .HasMaxLength(200)
               .IsRequired();
    }
}

Background Services

// Auto-scaling background worker
builder.Services.AddHostedService<WorkerService<MyTaskQueue>>();

๐Ÿ“ Project Structure

Spark.Core/                    # Core abstractions and models
โ”œโ”€โ”€ Attributes/                # Custom attributes for caching, messaging
โ”œโ”€โ”€ Constants/                 # Application constants and enums
โ”œโ”€โ”€ Extensions/                # Extension methods
โ”œโ”€โ”€ Models/                    # DTOs, settings, and response models
โ””โ”€โ”€ SeedWorks/                 # Base entities and abstractions

Spark.Libraries/               # Implementation libraries
โ”œโ”€โ”€ BackgroundServices/        # Background task processing
โ”œโ”€โ”€ Cache/                     # Redis caching implementation
โ”œโ”€โ”€ DocumentApi/               # Swagger/OpenAPI configuration
โ”œโ”€โ”€ EntityFramework/           # EF Core configurations
โ”œโ”€โ”€ Mediatr/                   # MediatR pipeline behaviors
โ”œโ”€โ”€ MessageQueues/             # RabbitMQ & Redis Pub/Sub
โ”œโ”€โ”€ Middlewares/               # Custom middleware
โ”œโ”€โ”€ Mongo/                     # MongoDB support
โ””โ”€โ”€ Repositories/              # Repository pattern implementation

๐ŸŽฏ Core Concepts

Base Entities

All entities inherit from base classes providing:

  • Audit Fields - Created/Updated timestamps with user tracking
  • Soft Delete - Logical deletion support
  • Concurrency Control - Optimistic locking with row versioning

Message Handling

  • Automatic Discovery - Handlers are automatically registered via reflection
  • Typed Messages - Strong typing with ITypedMessageHandler<T>
  • Channel-based Routing - Redis Pub/Sub with channel-specific handlers

Caching Strategy

  • Distributed Caching - Redis-based caching with connection pooling
  • Attribute-based - Method-level caching with [Cache] attribute
  • Invalidation Support - Smart cache invalidation patterns

๐ŸŒ Environment Configuration

SPARK supports environment-specific configurations:

  • Development - Full Swagger UI with Scalar documentation
  • Production - Optimized settings with security headers
  • Staging - Balanced configuration for testing

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ†˜ Support

  • ๐Ÿ“ง Email: support.study@gmail.com
  • ๐ŸŒ Website: max-h.vercel.app
  • ๐Ÿ“š Documentation: [Coming Soon]

๐Ÿ”ฎ Roadmap

  • OpenTelemetry Integration - Distributed tracing support
  • Health Checks - Comprehensive health monitoring
  • Metrics Collection - Prometheus/Grafana integration
  • Service Discovery - Consul/Eureka support
  • Rate Limiting - API throttling capabilities
  • Event Sourcing - Event-driven architecture patterns

Built with โค๏ธ for the .NET community

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 10 8/10/2025
1.0.9 10 8/10/2025
1.0.7 87 7/27/2025
1.0.6 201 7/26/2025
1.0.5 237 7/26/2025
1.0.4 104 7/12/2025
1.0.3 99 7/12/2025
1.0.2 98 7/12/2025
1.0.1 60 7/12/2025
1.0.0 62 7/12/2025

Initial release of SPARK - Complete microservices toolkit for .NET 8.

 🏗๏ธ Core Infrastructure:
 - Centralized configuration with validation
 - Advanced dependency injection patterns
 - Global exception handling middleware
 - API versioning with Swagger documentation

 🔄 Message Queues & Communication:
 - RabbitMQ integration with MassTransit
 - Redis Pub/Sub messaging
 - Apache Kafka support
 - MediatR CQRS with pipeline behaviors

 💾 Data Access & Storage:
 - PostgreSQL with Entity Framework Core
 - MongoDB document database support
 - Redis distributed caching
 - Repository pattern implementation

 🔐 Security & Authentication:
 - JWT authentication with Bearer support
 - Role-based authorization
 - Environment-based CORS configuration

 🧪 Development Features:
 - Swagger/OpenAPI with Scalar UI
 - FluentValidation integration
 - AutoMapper object mapping
 - Scalable background services

 See CHANGELOG.md for detailed release notes.