技术栈介绍
FreeKit Pro Modules 基于 .NET 10 构建,所有依赖项均采用国内开源生态或主流开源库,不依赖 EF Core,不依赖 Hangfire。
核心技术选型
| 层次 | 技术 | 版本 | 说明 |
|---|---|---|---|
| 框架 | ASP.NET Core | .NET 10 | Web API / 中间件 |
| ORM | FreeSql | 3.5+ | CodeFirst,支持 MySQL/SQLServer/PostgreSQL/SQLite |
| 缓存 | FreeRedis | 最新 | Redis 客户端,类 StackExchange.Redis |
| 任务调度 | FreeScheduler | 1.2+ | 基于 FreeRedis 的分布式定时任务,非 Hangfire |
| 依赖注入 | Autofac | 8.x | 替代原生 DI,支持属性注入 |
| 日志 | Serilog | 4.x | 结构化日志,写入文件 + 数据库 |
| 消息队列 | RabbitMQ + CAP | 8.x | 分布式事件总线 |
| 全文搜索 | MeiliSearch | v1.13 | 文章/沸点全文搜索与建议 |
| 实时通信 | SignalR | .NET 10 内置 | IM 会话、CmsKit 实时通知 |
| AI/LLM | 阿里云 DashScope | - | 内容推荐、摘要生成(可选) |
| 对象存储 | 阿里云 OSS / 本地文件 | - | 附件/图片存储(可配置) |
| API 文档 | RapiDoc | - | Swagger UI 替换方案 |
数据库说明
FreeSql 同时支持多数据源,项目内以命名连接字符串区分:
| 连接字符串名 | 用途 |
|---|---|
ConnectionStrings.MySql | 主业务库(CmsKit / Identity / IM / Mall 等) |
ShortUrlConnectionStrings.MySql | 短链模块独立库 |
FileConnectionStrings.MySql | 文件管理独立库 |
LogConnectionStrings.MySql | Serilog 日志独立库 |
ConnectionStrings.Redis | 主 Redis 连接 |
所有数据库表结构通过 FreeSql CodeFirst 在模块 Configure() 中调用 SyncStructure() 或 ConfigFreeKitXxx() 自动同步,无需手动执行 migration 命令。
模块化架构
模块化基于 IGeekFan.FreeKit.Modularity 包实现:
// src/Services/Host/FreeKit.DI/E.cs — 模块注册表
public static readonly Dictionary<string, Type> Modules = new(StringComparer.OrdinalIgnoreCase)
{
{ "identity", typeof(IdentityModuleStartup) },
{ "identity-inf", typeof(IdentityInfrastructureModuleStartup) },
{ "cmskit", typeof(CmsKitModuleStartup) },
{ "im", typeof(ImModuleStartup) },
{ "mall", typeof(MallModuleStartup) },
{ "platform", typeof(PlatformModuleStartup) },
{ "holiday", typeof(HolidayModuleStartup) },
{ "todo", typeof(ToDoModuleStartup) },
{ "member", typeof(MemberModuleStartup) },
{ "short", typeof(ShortModuleStartup) },
{ "toolkit", typeof(ToolKitModuleStartup) },
};
要禁用某个模块,直接从字典中移除对应条目即可。
宿主项目结构
src/Services/Host/
├── FreeKit.Host/ # 主 API 宿主(对外提供 HTTP API)
├── FreeKit.Job.Host/ # 任务调度宿主(FreeScheduler)
├── FreeKit.MessageHandler.Host/ # 消息消费者宿主(CAP/RabbitMQ)
├── FreeKit.HealthChecks/ # 健康检查服务
└── FreeKit.DI/ # 模块注册中心(E.cs)
项目依赖关系
FreeKit.Host
└── FreeKit.DI (引用所有业务模块)
├── FreeKit.CmsKit
├── FreeKit.Identity
├── FreeKit.IM
├── FreeKit.Mall
├── FreeKit.Platform
├── FreeKit.Short
├── FreeKit.ToDos
├── FreeKit.Toolkit
├── FreeKit.Member
└── Holidays