{"id":13600824,"url":"https://github.com/stack-labs/starter-kit","last_synced_at":"2025-04-11T01:30:24.802Z","repository":{"id":54410910,"uuid":"217045239","full_name":"stack-labs/starter-kit","owner":"stack-labs","description":"stack-rpc 快速开发包","archived":false,"fork":false,"pushed_at":"2023-03-07T00:58:41.000Z","size":2433,"stargazers_count":382,"open_issues_count":8,"forks_count":55,"subscribers_count":28,"default_branch":"master","last_synced_at":"2024-10-29T14:18:43.518Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","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/stack-labs.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}},"created_at":"2019-10-23T11:53:54.000Z","updated_at":"2024-07-15T08:22:11.000Z","dependencies_parsed_at":"2023-07-14T06:01:51.873Z","dependency_job_id":null,"html_url":"https://github.com/stack-labs/starter-kit","commit_stats":null,"previous_names":["micro-in-cn/starter-kit"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stack-labs%2Fstarter-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stack-labs%2Fstarter-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stack-labs%2Fstarter-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stack-labs%2Fstarter-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stack-labs","download_url":"https://codeload.github.com/stack-labs/starter-kit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248324943,"owners_count":21084837,"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-08-01T18:00:49.409Z","updated_at":"2025-04-11T01:30:24.591Z","avatar_url":"https://github.com/stack-labs.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Micro 快速开发工具包\n\n\u003e *项目进行中*\n\n本仓库旨在提供面向 stack-rpc 生产环境的快速开发包。\n\n## 目录\n\n- 快速开始示例\n    - [控制台示例](/console#目录)\n        - 以最常见的登录流程为例，实现一个场景简单，但包含微服务各种治理能力的示例\n    - [Hipster Shop示例](/hipstershop)\n        - 参考[GoogleCloudPlatform/microservices-demo](https://github.com/GoogleCloudPlatform/microservices-demo/)实现一个业务场景比较复杂的微服务应用\n- [架构设计](#架构设计)\n- [目录结构](#目录结构)\n- [目标功能](#目标功能)\n- [开发环境](#开发环境)\n- [部署环境](#部署环境)\n- [参与贡献](#参与贡献)\n\n## 架构设计\n\n### 系统架构图\n\u003cimg src=\"/doc/img/architecture.png\" width=\"50%\"\u003e\n\n### 业务架构图\n\n**[Console示例](/console)**\n\n\u003cimg src=\"/doc/img/console-design.png\" width=\"50%\"\u003e\n\n- [Hipster Shop示例](/hipstershop)\n    - 参考[GoogleCloudPlatform/microservices-demo](https://github.com/GoogleCloudPlatform/microservices-demo/)\n\n**领域模型\u0026整洁架构参考**\n- [Clean Architecture in go](https://medium.com/@hatajoe/clean-architecture-in-go-4030f11ec1b1)\n- [基于 DDD 的微服务设计和开发实战](https://www.infoq.cn/article/s_LFUlU6ZQODd030RbH9)\n- [当中台遇上 DDD，我们该如何设计微服务？](https://www.infoq.cn/article/7QgXyp4Jh3-5Pk6LydWw)\n\n## 目录结构\n\n```bash\n├── console             控制台示例\n│   ├── account         go.micro.srv.account，Account服务\n│   │   ├── domain              领域\n│   │   │   ├── model           模型\n│   │   │   ├── repository      存储接口\n│   │   │   │   └── persistence ①存储接口实现\n│   │   │   └── service         领域服务\n│   │   ├── interface           接口\n│   │   │   ├── handler         micro handler接口\n│   │   │   └── persistence     ②存储接口实现\n│   │   ├── registry            依赖注入，根据使用习惯，一般Go中不怎么喜欢这种方式\n│   │   └── usecase             应用用例\n│   │       ├── event           消息事件\n│   │       └── service         应用服务\n│   ├── api             go.micro.api.console，API服务\n│   ├── pb              服务协议统一.proto\n│   └── web             go.micro.api.console，Web服务，集成gin、echo、iris等web框架\n├── deploy              部署\n│   ├── docker\n│   └── k8s\n├── doc                 文档资源\n├── gateway             网关，自定义micro\n└── pkg                 公共资源包\n```\n\n## 目标功能\n\n- 自定义[micro网关](gateway)\n\t- [x] `JWT`认证\n\t- [x] `Casbin`鉴权\n\t- [x] Tracing\n\t- [ ] RequestID\n\t- [x] Metrics\n\t- [ ] Access Log\n\t- ...\n- API服务\n    - 网关使用默认处理器(`handler=meta`)，聚合服务通过`Endpoint`定义路由规则，实现统一网关管理`rpc`和`http`类型的聚合服务\n        - *注:`go-micro/web`服务注册不支持`Endpoint`定义，需要自定义`web.Service`([实现参考](https://github.com/hb-go/micro-plugins/tree/master/web))，[issue#1097](https://github.com/micro/go-micro/issues/1097)*\n\t- [x] api\n    - [x] rpc\n    - proxy/http/web\n        - [x] [静态资源](/console/web/statik)\n            - *前后端分离场景将静态资源独立更好，但不排除使用Web模板框架的应用加入微服务体系，尤其在已有单体逐步拆分的演进过程中*\n        - [x] [echo](/console/web/echo)\n        - [x] [gin](/console/web/gin)\n        - [x] [iris](/console/web/iris)\n        - [x] [beego](/console/web/beego)\n- 配置中心\n- 前后端分离`console`\n\t- [x] [PanJiaChen/vue-element-admin](https://github.com/PanJiaChen/vue-element-admin)，[示例](/console/web/vue)\n\t- [ ] [tookit/vue-material-admin](https://github.com/tookit/vue-material-admin)\n\t- [ ] [view-design/iview-admin](https://github.com/view-design/iview-admin)\n- 参数验证\n\t- [x] [protoc-gen-validate](https://github.com/envoyproxy/protoc-gen-validate)，适用于API`handler=rpc`的模式\n\t    - 规则配置[account.proto](/console/pb/api/account.proto#L21)\n\t    - 参数验证[account.go](/console/api/handler/account.go#L26)\n- 领域驱动\n\t- [x] 整洁架构\n- ORM\n\t- [x] gorm\n\t- [x] xorm\n- 发布\n\t- [x] 灰度\n\t- [x] 蓝绿\n\t- *注:由于micro默认的api和web网关均不支持服务筛选，需要自己改造，方案参考[微服务协作开发、灰度发布之流量染色](https://micro.mu/blog/cn/2019/12/09/go-micro-service-chain.html)*\n- 部署\n\t- [ ] K8S\n\t\t- [x] [helm](/deploy/k8s/helm)\n\t- [ ] Docker\n- 安全\n- CICD\n\t- [x] [Drone](https://drone.io/) [README](/deploy/docker/drone)\n\t    - [x] Go编译\n\t    - [x] Docker镜像\n\t    - [ ] Kubernetes发布\n\t- [ ] Jenkins\n- 基础服务\n\t- [ ] 日志收集\n\t\t- `stdout`标准输出\n\t\t- `log.file`日志文件\n\t\t- [log-pilot](https://github.com/AliyunContainerService/log-pilot)\n\t- [ ] 监控告警\n\t\t- Prometheus\n\t\t- Grafana\n\t- [ ] Tracing\n\t\t- Jaeger\n- ...\n\n## 开发环境\n\n*TODO*\n- 本地\n    - [x] [Docker Compose](/console#docker-compose启动)\n- 在线\n    - [ ] CICD\n    - [ ] Kubernetes\n    - 本地服务接入\n        - [ ] Network代理 + 流量染色\n\n## 部署环境\n\n[Kubernetes环境](/deploy/k8s)\n\n## 可选服务\n\n\u003cdetails\u003e\n  \u003csummary\u003e Jaeger \u003c/summary\u003e\n\n\u003e 浏览器访问:http://localhost:16686/\n```bash\n$ docker run -d --name=jaeger -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 -p5775:5775/udp -p6831:6831/udp -p6832:6832/udp   -p5778:5778 -p16686:16686 -p14268:14268 -p9411:9411 jaegertracing/all-in-one:latest\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e Prometheus \u003c/summary\u003e\n\n\u003e 浏览器访问:http://localhost:9090/\n\n\u003e `prometheus.yml`参考`gateway`插件`[metrics/prometheus.yml](/gateway/plugin/metrics/prometheus.yml)\n```bash\n$ docker run -d --name prometheus -p 9090:9090 -v ~/tmp/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e Grafana \u003c/summary\u003e\n\n\u003e 浏览器访问:http://localhost:3000/\n\n\u003e `Grafana`仪表盘`import`[metrics/grafan.json](/gateway/plugin/metrics/grafan.json)\n```bash\n$ docker run --name grafana -d -p 3000:3000 grafana/grafana\n```\n\n\u003c/details\u003e\n\n## 参与贡献\n\n### 代码格式\n- IDE IDEA/Goland，`Go-\u003eimports` 设置\n    - Sorting type `gofmt`\n    - [x] `Group stdlib imports`\n        - [x] `Move all stdlib imports in a single group`\n    - [x] `Move all imports in a single declaration`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstack-labs%2Fstarter-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstack-labs%2Fstarter-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstack-labs%2Fstarter-kit/lists"}