How applikatla/cosmonic-grpc works
This repository is a small modular gRPC framework demonstrated by a Hello module. A client’s store or retrieve request enters the Gin-hosted HTTP gateway or the gRPC server, reaches the Hello handler, then the service and keeper, which read or write PostgreSQL-backed state. The app registers modules and exposes their gRPC and gateway registrations. The README also describes typed protobuf APIs, REST mappings, and database-backed modules. Security features are discussed as extension guidance, but the sampled runtime does not show their implementation.
Main entry points: main.go Server bootstrap · module.go Hello module wiring · hello.pb.gw.go Gateway bindings · hello.go RPC handler
Components 15
Runtime wiring
- Server bootstrap
cmd/server/main.go - App registry
app/app.go - Module interface
app/module.go
API transport
- HTTP ingress
cmd/server/main.go - Gateway bindings
x/hello/types/hello.pb.gw.go - gRPC server
cmd/server/main.go - Hello API contract
proto/hello/hello.proto
Hello module
- Hello module wiring
x/hello/module.go - RPC handler
x/hello/grpc/hello.go - Hello service
x/hello/service/hello.go - State keeper
x/hello/keeper/keeper.go
Persistence
- Database setup
internal/db/db.go - Hello model
internal/db/models.go
Other components
- API client
- PostgreSQL
Connections 20
- API client → HTTP ingress: sends HTTP
README.md - API client → gRPC server: calls RPC
README.md - HTTP ingress → Gateway bindings: wraps gateway
cmd/server/main.go - Gateway bindings → gRPC server: dials endpoint
- Hello API contract → Gateway bindings: defines HTTP mapping
- Server bootstrap → Database setup: opens database
cmd/server/main.go - Server bootstrap → Hello model: runs migration
cmd/server/main.go - Server bootstrap → App registry: creates registry
cmd/server/main.go - Server bootstrap → Hello module wiring: registers module
cmd/server/main.go - App registry → Module interface: stores modules
app/app.go - Server bootstrap → Module interface: dispatches registration
cmd/server/main.go - Hello module wiring → RPC handler: constructs handler
x/hello/module.go - Hello module wiring → gRPC server: registers service
x/hello/module.go - Hello module wiring → Gateway bindings: registers gateway
x/hello/module.go - gRPC server → RPC handler: dispatches RPC
- RPC handler → Hello service: calls service
x/hello/grpc/hello.go - Hello service → State keeper: calls state methods
x/hello/service/hello.go - State keeper → Hello model: reads and writes
x/hello/keeper/keeper.go - Database setup → PostgreSQL: connects
internal/db/db.go - Hello model → PostgreSQL: persists records