A Go-based high-concurrency demo system built on go-zero, showcasing service decomposition, RPC communication, and an HTTP API gateway for user, trade, and promotion domains.
- Language: Go
- Framework: go-zero
- RPC: gRPC + go-zero
zrpc - Config: YAML
- Others: Snowflake ID, MQ, Prometheus (introduced gradually in submodules)
cmd/api/user-api/: User HTTP API entrypoint, routing, and minimal business logic.rpc/user-rpc/: User RPC service entrypoint.- Other services’ API/RPC entrypoints follow the same pattern.
service/user/rpc/: User-domain RPC service (business logic, config, server wiring).trade/rpc/: Trade-domain RPC service (place order, cancel order, etc.).promotion/rpc/: Promotion / inventory-related RPC service.
common/: Shared middleware, MQ wrappers, Snowflake ID generator, etc.deploy/: Docker / K8s / Prometheus and other deployment-related configs.doc/: Architecture design, coding standards, performance guidelines, etc.
- Go 1.22+ (recommended to manage via
goenvorgvm). protocand go-zero codegen plugins installed (only needed if you regenerate proto code).
From the project root:
go run ./cmd/rpc/user-rpcBy default it loads service/user/rpc/etc/user.yaml and listens on 0.0.0.0:8080.
From the project root:
go run ./service/user/api/cmd/user-apiIt loads service/user/api/etc/user-api.yaml, listens on 0.0.0.0:8888,
and calls the local user.rpc directly.
curl "http://localhost:8888/v1/users/1"You should see a JSON response containing userId, username, and mobile.
For now this is a deterministic stub user; persistence and real data sources will
be added in future iterations.
From the project root:
go test ./...Core business logic (user, trade, promotion RPC logic) is covered by unit tests that validate input and basic flows.
- Coding standards, commit/PR workflow and review rules: see
doc/coding-standards/. - Overall architecture, service boundaries and design principles: see
doc/design/.
When adding new services or endpoints, please follow the patterns used in
user, trade, and promotion services to keep layering and style consistent.