跳到主要内容

技术栈

技术选型

层次技术版本选型理由
运行时.NET10.0高性能、跨平台、C# 语言特性
ORMFreeSql3.2+CodeFirst、多数据库支持、性能优异
依赖注入Autofac9.0+属性注入、AOP 拦截、模块化注册
认证授权OpenIddict6.0+标准 OAuth2/OIDC、与 ASP.NET Core 深度集成
日志Serilog4.0+结构化日志、丰富 Sink
实时通信SignalR10.0内置支持、WebSocket、自动重连
定时任务FreeScheduler2.0+基于 Redis、轻量级、可视化管理
消息队列CAP8.0+分布式事件、最终一致性、多存储支持
全文搜索MeiliSearch1.0+毫秒级搜索、中文支持、简单 API
对象存储Cloudflare R2-S3 兼容、免出口流量费

架构图

┌─────────────────────────────────────────────────────────────┐
│ 宿主层 (Host) │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ FreeKit │ │ Job │ │ Message │ │ Auth │ │
│ │ Host │ │ Host │ │ Host │ │ Host │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
├─────────────────────────────────────────────────────────────┤
│ 应用层 (Application) │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Identity │ │ CmsKit │ │ Platform │ │ Auth │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
├─────────────────────────────────────────────────────────────┤
│ 领域层 (Domain) │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ 实体 · 值对象 · 领域事件 · 仓储接口 · 领域服务 │ │
│ └──────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ 基础设施层 (Infrastructure) │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ FreeSql │ │ Redis │ │ RabbitMQ │ │ Meili │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
└─────────────────────────────────────────────────────────────┘

数据库支持

数据库提供程序适用场景
MySQLFreeSql.Provider.MySql生产环境(推荐)
PostgreSQLFreeSql.Provider.PostgreSQL生产环境
SQLiteFreeSql.Provider.Sqlite开发/测试
SqlServerFreeSql.Provider.SqlServer企业环境

开发环境使用 DefaultDB: "0" 启用内存数据库,零配置启动。

宿主结构

宿主端口PathBase用途
FreeKit.Host7002/kit_api主 API 入口
FreeKit.Job.Host7000/job_api定时任务
FreeKit.MessageHandler.Host7003/message_api消息处理
FreeKit.Auth.Host7001-OAuth2 授权
FreeKit.HealthChecks5005-健康检查

模块注册

模块在 src/Services/Host/FreeKit.DI/E.cs 中注册:

public static readonly Dictionary<string, Type> Modules = new(StringComparer.OrdinalIgnoreCase)
{
{ "identity", typeof(IdentityModuleStartup) },
{ "identity-inf", typeof(IdentityInfrastructureModuleStartup) },
{ "platform", typeof(PlatformModuleStartup) },
{ "cmskit", typeof(CmsKitModuleStartup) },
{ "member", typeof(MemberModuleStartup) },
};

禁用模块:从 E.Modules 移除对应条目。 新增模块:添加 IModuleStartup 实现并注册。

相关文档