{"id":16619516,"url":"https://github.com/java-edge/ddd-mall","last_synced_at":"2025-12-24T06:30:28.389Z","repository":{"id":247791210,"uuid":"823189503","full_name":"Java-Edge/ddd-mall","owner":"Java-Edge","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-30T08:38:09.000Z","size":4035,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-17T21:44:23.153Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Java-Edge.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-02T14:51:27.000Z","updated_at":"2024-12-25T10:14:13.000Z","dependencies_parsed_at":"2024-11-17T04:01:57.152Z","dependency_job_id":null,"html_url":"https://github.com/Java-Edge/ddd-mall","commit_stats":null,"previous_names":["java-edge/ddd-mall"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Java-Edge%2Fddd-mall","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Java-Edge%2Fddd-mall/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Java-Edge%2Fddd-mall/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Java-Edge%2Fddd-mall/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Java-Edge","download_url":"https://codeload.github.com/Java-Edge/ddd-mall/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242988054,"owners_count":20217539,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T02:42:09.231Z","updated_at":"2025-12-24T06:30:28.349Z","avatar_url":"https://github.com/Java-Edge.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 1 项目描述\n\nDDD商城是个从零到一的 C2C 商城项目，包含商城核心业务和基础架构两大模块。\n\n包含商城系统用户、消息、商品、订单、优惠券、支付、网关、购物车等业务模块，通过商城系统中复杂场景，给出对应解决方案。使用 DDD 模型开发系统功能，帮助对 DDD 一知半解的开发者树立正确地开发思路。\n\n![](https://images-machen.oss-cn-beijing.aliyuncs.com/1673165270664-5d0c4381-96ef-427b-a58d-9b21140eabe0-20230306173625527.png)\n\n该系统总结了我从事后端以来，在实际工作中遇到各种场景问题的“疑难杂症”汇总，包含解决方案和代码实战。\n\n提供了完整可运行的普惠版商城业务，也提供了偏架构层面有用的工具和参考，能帮助大家在实际项目中更好地解决问题。\n\n## 2 你将学到\n\n- 基于 DDD 实现的商品、购物车、订单、用户、消息及支付服务\n- 掌握分布式锁、分布式事务、分布式搜索、分布式缓存、分布式限流以及分库分表等核心技术\n- 完成基础组件抽象，规约、缓存、幂等、分布式 ID、数据持久层、脱敏以及日志等底层组件库。\n- 基于 Agent 开发字节码流量监控，监控项目接口 QPS、响应时间和异常请求等核心指标。\n- 掌握常用设计模式实战场景，策略、责任链、装饰器、观察者以及适配器等设计模式。\n\n## 3 如何开始\n\nDDD商城核心有两块，认真学习分别可以收获：\n\n- 商城业务：通过学习DDD商城中复杂业务处理场景，增加自己的复杂业务处理能力。\n- 基础架构：尝试跟着基础架构部分自己把轮子都造一遍，以此提高自己方案设计和公共代码开发能力。\n\n### 3.1 商城核心业务\n\n学习流程：\n\n1. 初始化数据库，如商品库、订单库、用户库、支付库、购物车库等\n2. 安装Nacos、MySQL、Seata、RocketMQ 等\n3. 学习接口调用流程\n4. 查看不同微服务之间的依赖关系，并根据文档中的描述进行修改指定参数\n5. 找到自己感兴趣的模块功能 Debug 源代码，参考代码设计\n\n![](https://my-img.javaedge.com.cn/javaedge-blog/2024/07/6a22ca0407bb54c80f0a85db0e68fb9f.png)\n\n### 3.2 基础架构\n\n基础架构相关代码都在 `dddmall-framework-all` 模块，本专栏教你如何开发基础架构代码。\n\n![](https://my-img.javaedge.com.cn/javaedge-blog/2024/07/e4bf3e96b095b778becc2e67aa2e3028.png)\n\n\n\n## 4 接口文档\n\n已开发的接口已汇总至下述接口文档中，本地启动对应项目，通过接口文档访问查看效果。\n\n[https://www.apifox.cn/web/project/1038592/apis/api-50106328-run(opens new window)](https://www.apifox.cn/web/project/1038592/apis/api-50106328-run)\n\n如果需要通过 Apifox 直接调用，需要安装对应浏览器内网插件，考虑到一部分同学没有科学上网，这里把插件安装包带上，跟着教程安装即可使用。\n\n安装文档：[https://www.apifox.cn/help/app/web/browser-extension(opens new window)](https://www.apifox.cn/help/app/web/browser-extension)\n\n\n\n![](https://images-machen.oss-cn-beijing.aliyuncs.com/1673619450701-2c7d5fe3-bf39-4c79-84e8-2ae4f0211a79.png)\n\n## 5 服务列表\n\n\n\n|      | 模块名称              | 服务名称                          | 访问地址                                                     |\n| ---- | --------------------- | --------------------------------- | ------------------------------------------------------------ |\n| 1    | dddmall-message       | 消息发送 eg：邮件、公众号、短信等 | [http://localhost:8001(opens new window)](http://localhost:8001/) |\n| 2    | dddmall-customer-user | C 端用户                          | [http://localhost:8002(opens new window)](http://localhost:8002/) |\n| 3    | dddmall-gateway       | 外部网关                          | [http://localhost:8003(opens new window)](http://localhost:8003/) |\n| 4    | dddmall-product       | 商品服务                          | [http://localhost:8004(opens new window)](http://localhost:8004/) |\n| 5    | dddmall-product-job   | 商品 Job 服务                     | [http://localhost:9001(opens new window)](http://localhost:9001/) |\n| 6    | dddmall-cart          | 购物车服务                        | [http://localhost:8005(opens new window)](http://localhost:8005/) |\n| 7    | dddmall-order         | 订单服务                          | [http://localhost:8006(opens new window)](http://localhost:8006/) |\n| 8    | dddmall-pay           | 支付服务                          | [http://localhost:8007(opens new window)](http://localhost:8007/) |\n| 9    | dddmall-basic-data    | 基础数据服务                      | [http://localhost:8008(opens new window)](http://localhost:8008/) |\n| 10   | dddmall-bff           | BFF 商城聚合层                    | [http://localhost:8009(opens new window)](http://localhost:8009/) |\n\n## 6 技术架构选型\n\n\n\n|      | 技术                | 名称                   | 官网                                                         |\n| ---- | ------------------- | ---------------------- | ------------------------------------------------------------ |\n| 1    | Spring Boot         | 基础框架               | [https://spring.io/projects/spring-boot(opens new window)](https://spring.io/projects/spring-boot) |\n| 2    | MyBatis-Plus        | 持久层框架             | [https://baomidou.com(opens new window)](https://baomidou.com/) |\n| 3    | HikariCP            | 数据库连接池           | [https://github.com/brettwooldridge/HikariCP(opens new window)](https://github.com/brettwooldridge/HikariCP) |\n| 4    | Redis               | 分布式缓存数据库       | [https://redis.io(opens new window)](https://redis.io/)      |\n| 5    | RocketMQ            | 消息队列               | [https://rocketmq.apache.org(opens new window)](https://rocketmq.apache.org/) |\n| 6    | ShardingSphere      | 数据库生态系统         | [https://shardingsphere.apache.org(opens new window)](https://shardingsphere.apache.org/) |\n| 7    | SpringCloud Alibaba | 分布式框架             | [https://github.com/alibaba/spring-cloud-alibaba(opens new window)](https://github.com/alibaba/spring-cloud-alibaba) |\n| 8    | SpringCloud Gateway | 网关框架               | [https://spring.io/projects/spring-cloud-gateway(opens new window)](https://spring.io/projects/spring-cloud-gateway) |\n| 9    | Seata               | 分布式事务框架         | [http://seata.io/zh-cn/index.html(opens new window)](http://seata.io/zh-cn/index.html) |\n| 10   | Canal               | MySQL 订阅 BinLog 组件 | [https://github.com/alibaba/canal(opens new window)](https://github.com/alibaba/canal) |\n| 11   | MinIO               | 文件存储框架           | [https://min.io(opens new window)](https://min.io/)          |\n| 12   | Swagger3            | 项目 API 文档框架      | [http://swagger.io(opens new window)](http://swagger.io/)    |\n| 13   | Knife4j             | Swagger 增强框架       | [https://doc.xiaominfo.com(opens new window)](https://doc.xiaominfo.com/) |\n| 14   | Maven               | 项目构建管理           | [http://maven.apache.org(opens new window)](http://maven.apache.org/) |\n| 15   | Redisson            | Redis Java 客户端      | [https://redisson.org(opens new window)](https://redisson.org/) |\n| 16   | Sentinel            | 流控防护框架           | [https://github.com/alibaba/Sentinel(opens new window)](https://github.com/alibaba/Sentinel) |\n| 17   | Hippo4j             | 动态线程池框架         | [https://hippo4j.cn(opens new window)](https://hippo4j.cn/)  |\n| 18   | XXL-Job             | 分布式定时任务框架     | [http://www.xuxueli.com/xxl-job(opens new window)](http://www.xuxueli.com/xxl-job) |\n| 19   | SkyWalking          | 分布式链路追踪框架     | [https://skywalking.apache.org(opens new window)](https://skywalking.apache.org/) |\n| 20   | JetCache            | Java 缓存框架          | [https://github.com/alibaba/jetcache(opens new window)](https://github.com/alibaba/jetcache) |\n\n## 7 项目结构说明\n\n\n\n```txt\n├── dddmall-basic-data  || -- # 基础数据服务\n│   ├── dddmall-basic-data-application\n│   ├── dddmall-basic-data-domain\n│   ├── dddmall-basic-data-infrastructure\n│   ├── dddmall-basic-data-interface\n├── dddmall-bff  || -- # 商城 BFF 聚合层\n│   ├── dddmall-bff-biz\n│   ├── dddmall-bff-remote\n│   ├── dddmall-bff-web\n├── dddmall-cart  || -- # 购物车服务\n│   ├── dddmall-cart-application\n│   ├── dddmall-cart-domain\n│   ├── dddmall-cart-infrastructure\n│   ├── dddmall-cart-interface\n├── dddmall-coupon  || -- # 优惠券服务\n├── dddmall-customer-user  || -- # C端用户服务\n│   ├── dddmall-customer-user-application\n│   ├── dddmall-customer-user-domain\n│   ├── dddmall-customer-user-infrastructure\n│   ├── dddmall-customer-user-interface\n│   ├── dddmall-customer-user-mock\n├── dddmall-framework-all  || -- # 基础组件\n│   ├── dddmall-base-spring-boot-starter  || -- # 顶层抽象基础组件\n│   ├── dddmall-cache-spring-boot-starter  || -- # 缓存组件\n│   ├── dddmall-common-spring-boot-starter  || -- # 公共工具包组件\n│   ├── dddmall-convention-spring-boot-starter  || -- # 项目规约组件\n│   ├── dddmall-database-spring-boot-starter  || -- # 数据库持久层组件\n│   ├── dddmall-ddd-framework-core  || -- # DDD抽象接口组件\n│   ├── dddmall-designpattern-spring-boot-starter  || -- # 设计模式抽象组件\n│   ├── dddmall-distributedid-spring-boot-starter  || -- # 分布式ID组件\n│   ├── dddmall-flow-monitor-agent  || -- # 微服务流量监控组件\n│   ├── dddmall-httputil-spring-boot-starter  || -- # Http网络调用组件\n│   ├── dddmall-idempotent-spring-boot-starter  || -- # 分布式幂等组件\n│   ├── dddmall-log-spring-boot-starter  || -- # 日志打印组件\n│   ├── dddmall-minio-spring-boot-starter  || -- # 文件存储组件\n│   ├── dddmall-openfeign-spring-boot-starter  || -- # 微服务调用组件\n│   ├── dddmall-rocketmq-spring-boot-starter  || -- # 分布式消息队列组件\n│   ├── dddmall-sensitive-spring-boot-starter  || -- # 前端返回数据脱敏组件\n│   ├── dddmall-swagger-spring-boot-starter  || -- # 文档API组件\n│   ├── dddmall-web-spring-boot-starter  || -- # Web组件\n│   ├── dddmall-xxljob-spring-boot-starter  || -- # 定时任务组件\n├── dddmall-gateway  || -- # 网关服务\n├── dddmall-message  || -- # 消息服务\n│   ├── dddmall-message-application\n│   ├── dddmall-message-domain\n│   ├── dddmall-message-infrastructure\n│   ├── dddmall-message-interface\n├── dddmall-order  || -- # 订单服务\n│   ├── dddmall-order-application\n│   ├── dddmall-order-domain\n│   ├── dddmall-order-infrastructure\n│   ├── dddmall-order-interface\n├── dddmall-pay  || -- # 支付服务\n│   ├── dddmall-pay-application\n│   ├── dddmall-pay-domain\n│   ├── dddmall-pay-infrastructure\n│   ├── dddmall-pay-interface\n├── dddmall-product  || -- # 商品服务\n│   ├── dddmall-product-application\n│   ├── dddmall-product-domain\n│   ├── dddmall-product-infrastructure\n│   ├── dddmall-product-interface\n│   ├── dddmall-product-job\n├── dddmall-test-all  || -- # 测试用例\n│   ├── dddmall-flow-monitor-agent-test\n│   ├── dddmall-h2-test\n│   ├── dddmall-oom-test\n│   ├── dddmall-smooth-sharding-test\n│   ├── dddmall-yaml-test\n├── dev-support  || -- # 开发工具包\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjava-edge%2Fddd-mall","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjava-edge%2Fddd-mall","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjava-edge%2Fddd-mall/lists"}