MCPcopy
hub / github.com/8treenet/freedom

github.com/8treenet/freedom @v1.9.12 sqlite

repository ↗ · DeepWiki ↗ · release v1.9.12 ↗
1,453 symbols 4,732 edges 179 files 1,075 documented · 74%
README

Freedom DDD 框架

License Go Report CardGoDoc GitHub release

简介

Freedom 是一个基于六边形架构(Hexagonal Architecture)的 Go 语言框架,专注于支持领域驱动设计(DDD)开发范式。本框架提供了完整的基础设施和工具链,帮助开发者构建可维护、可扩展的企业级应用。

核心特性

架构支持

  • 完整实现六边形架构(端口和适配器模式)
  • 领域驱动设计(DDD)最佳实践支持
  • 依赖注入(DI)和依赖倒置原则(DIP)
  • 完全符合开闭原则的插件化设计

框架集成

  • 无缝集成 Iris Web 框架
  • 支持 HTTP/H2C 服务端和客户端
  • 内置 Prometheus 监控集成
  • 支持 AOP(面向切面编程)
  • 基于 Worker 的无侵入 Context 设计

领域模型支持

  • 聚合根(Aggregate Root)实现
  • 领域事件(Domain Events)支持
  • CQS(命令查询分离)模式
  • 实体(Entity)和值对象(Value Object)支持

数据处理

  • 自动化 CRUD 操作生成
  • PO(持久化对象)代码生成器
  • 多级缓存架构
  • 一级缓存(内存)
  • 二级缓存(分布式)
  • 缓存击穿防护

消息和事件

  • 集成消息队列组件
  • 领域事件发布订阅
  • 事件驱动架构支持

快速开始

安装框架

# 安装 Freedom 命令行工具
$ go install github.com/8treenet/freedom/freedom@latest

# 验证安装
$ freedom version

创建新项目

# 创建项目
$ freedom new-project [项目名称]

# 进入项目目录
$ cd [项目名称]

# 安装依赖
$ go mod tidy

# 运行服务
$ go run main.go

代码生成工具

# 生成数据库相关代码(支持两种方式)

# 1. 通过数据库连接生成
$ freedom new-po --dsn "root:密码@tcp(127.0.0.1:3306)/数据库名?charset=utf8"

# 2. 通过 JSON Schema 生成
$ freedom new-po --json ./domain/po/schema.json

# 查看更多生成选项
$ freedom new-po -h

文档指南

核心文档

学习资源

示例项目

  • 基础教程 - DDD 基础概念实践与框架核心功能演示
  • HTTP2 示例 - HTTP2 服务配置与依赖倒置实现
  • 基础设施示例 - 事务组件、自定义组件开发、Kafka 集成与领域事件
  • 电商系统示例 - 完整电商领域实现,涵盖 CQS 模式、聚合根、实体值对象、领域事件、资源库模式及基础设施层集成

贡献指南

欢迎提交 Issue 和 Pull Request 来帮助改进 Freedom 框架。在提交代码前,请确保:

  • 代码符合 Go 语言规范
  • 添加了必要的测试用例
  • 更新了相关文档

开源协议

本项目采用 Apache 2.0 开源协议。详见 LICENSE 文件。

Extension points exported contracts — how you extend this code

Builder (Interface)
Builder . [7 implementers]
example/infra-example/adapter/repository/generate.go
AdminRepo (Interface)
AdminRepo . [18 implementers]
example/fshop/domain/dependency/dependency.go
Transaction (Interface)
Transaction The interface definition of the transaction component. [7 implementers]
infra/transaction/transaction.go
BeginRequest (Interface)
BeginRequest Requests to start the interface, and the call is triggered when the instance is implemented. [11 implementers]
internal/core.go
DomainEvent (Interface)
DomainEvent Interface definition of domain events for subscription and publishing of entities. To create a domain event, [4 …
internal/entity.go
Client (Interface)
Client The client interface is defined. [2 implementers]
infra/requests/client.go
Consumer (Interface)
Consumer Kafka Consumer interface definition. [2 implementers]
infra/kafka/consumer.go
Configurator (Interface)
Configurator . [1 implementers]
profile.go

Core symbols most depended-on inside this repo

db
called by 95
example/fshop/adapter/repository/generate.go
Prometheus
called by 89
app.go
New
called by 86
example/fshop/domain/dependency/dependency.go
OrmWithLabelValues
called by 83
internal/prometheus.go
Logger
called by 82
app.go
Error
called by 76
internal/logger.go
Log
called by 73
middleware/logger.go
Execute
called by 64
example/fshop/adapter/repository/generate.go

Shape

Method 849
Function 396
Struct 164
Interface 39
FuncType 4
TypeAlias 1

Languages

Go100%

Modules by API surface

example/fshop/adapter/repository/generate.go85 symbols
example/infra-example/adapter/repository/generate.go46 symbols
infra/requests/http_request.go45 symbols
internal/app.go44 symbols
internal/util.go33 symbols
infra/requests/request.go32 symbols
internal/entity.go29 symbols
example/fshop/domain/dependency/dependency.go28 symbols
internal/worker.go27 symbols
internal/core.go25 symbols
infra/store/entity_cache.go23 symbols
infra/kafka/consumer.go23 symbols

Dependencies from manifests, versioned

filippo.io/edwards25519v1.1.0 · 1×
github.com/8treenet/iris/v12v12.1.9 · 1×
github.com/CloudyKit/fastprinterv0.0.0-2020010918263 · 1×
github.com/CloudyKit/jet/v3v3.0.0 · 1×
github.com/IBM/saramav1.46.3 · 1×
github.com/Shopify/goreferrerv0.0.0-2018110622232 · 1×
github.com/aymerick/douceurv0.2.0 · 1×
github.com/aymerick/raymondv2.0.3-0.20180322193 · 1×
github.com/beorn7/perksv1.0.1 · 1×
github.com/cespare/xxhash/v2v2.3.0 · 1×

For agents

$ claude mcp add freedom \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact