SparkToolkit 1.0.3
See the version list below for details.
dotnet add package SparkToolkit --version 1.0.3
NuGet\Install-Package SparkToolkit -Version 1.0.3
<PackageReference Include="SparkToolkit" Version="1.0.3" />
<PackageVersion Include="SparkToolkit" Version="1.0.3" />
<PackageReference Include="SparkToolkit" />
paket add SparkToolkit --version 1.0.3
#r "nuget: SparkToolkit, 1.0.3"
#:package SparkToolkit@1.0.3
#addin nuget:?package=SparkToolkit&version=1.0.3
#tool nuget:?package=SparkToolkit&version=1.0.3
๐ฅ 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.
โจ 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
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - 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 | Versions 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. |
-
net8.0
- Asp.Versioning.Mvc.ApiExplorer (>= 8.1.0)
- AutoMapper (>= 14.0.0)
- Confluent.Kafka (>= 2.11.0)
- FluentValidation (>= 12.0.0)
- FluentValidation.DependencyInjectionExtensions (>= 12.0.0)
- MassTransit (>= 8.5.0)
- MassTransit.RabbitMQ (>= 8.5.0)
- MediatR (>= 12.5.0)
- MediatR.Extensions.Microsoft.DependencyInjection (>= 11.1.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.16)
- Microsoft.EntityFrameworkCore (>= 9.0.6)
- Microsoft.EntityFrameworkCore.Abstractions (>= 9.0.6)
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.6)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.5)
- MongoDB.Bson (>= 3.4.0)
- MongoDB.Driver (>= 3.4.0)
- MongoDB.Driver.Core (>= 2.30.0)
- Newtonsoft.Json (>= 13.0.3)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 9.0.4)
- Scalar.AspNetCore (>= 2.4.13)
- StackExchange.Redis (>= 2.8.37)
- Swashbuckle.AspNetCore (>= 8.1.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
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.