Skip to main content

Lynx Project Template (Layout)

lynx-layout is the official service template repository aligned with the current Lynx runtime and plugin model.

What It Really Shows

lynx-layout is not itself a runtime plugin. It is an example application skeleton that demonstrates how current Lynx services are assembled.

Code-Backed Facts

From the repository:

  • startup entry uses boot.NewApplication(wireApp).Run()
  • HTTP server wiring uses github.com/go-lynx/lynx-http and GetHttpServer()
  • gRPC server wiring uses github.com/go-lynx/lynx-grpc and GetGrpcServer(nil)
  • data wiring already depends on concrete plugins such as MySQL and Redis rather than abstract placeholder packages
  • service registry wiring uses lynx.GetServiceRegistry()

Template Configuration That Matches Real Code

The template currently exposes two useful config views.

configs/bootstrap.local.yaml is the practical local-dev shape:

lynx:
http:
addr: 127.0.0.1:8000
grpc:
service:
addr: 127.0.0.1:9000
mysql:
driver: mysql
source: "..."
redis:
addrs:
- 127.0.0.1:6379

configs/bootstrap.yaml is the narrower governance-oriented shape:

lynx:
application:
name: user-service
polaris:
config_path: "configs/polaris.yaml"

This is the key thing many plugin documents fail to make obvious: the template does not start by enabling every plugin. It starts from a small runnable combination, then layers in governance-oriented config separately.

Template Code Path

The template also shows the real public integration entry points:

  • internal/server/http.go uses lynx-http.GetHttpServer()
  • internal/server/grpc.go uses lynx-grpc.GetGrpcServer(nil)
  • internal/data/data.go uses lynx-redis.GetRedis()
  • internal/data/data.go uses lynx-mysql.GetProvider()
  • cmd/user/wire_gen.go uses lynx.GetServiceRegistry()

That makes lynx-layout the most direct reference for how the current plugin family is meant to be consumed in a real service.

Structure

api      protocol definitions and generated code
biz business flow and domain logic
bo shared business objects
conf configuration structs and mapping
data repository and external dependency integration
service service-layer logic
server HTTP and gRPC registration
cmd application entry and Wire assembly

How To Use It

Install the Lynx CLI:

go install github.com/go-lynx/lynx/cmd/lynx@latest

Generate a project:

lynx new demo

Local Run Path

lynx-layout already includes a local bootstrap path and dependency compose file:

docker compose -f deployments/docker-compose.local.yml up -d
go run ./cmd/user -conf ./configs/bootstrap.local.yaml

The local config path is useful when you want to start from DB, Redis, HTTP, and gRPC first without introducing full governance dependencies immediately.