This project demonstrates a full-stack setup using gRPC as the backend service with a tRPC server acting as a bridge to expose gRPC methods to a Svelte frontend.
graph LR
subgraph Go_Server
A[gRPC Server - Engine]
end
subgraph Node_Server
B[gRPC Client - Node-TS]
C[tRPC Server - Node-TS]
end
subgraph Svelte_Frontend
D[tRPC Client - Svelte]
end
A -->|gRPC| B
B -->|tRPC| C
C -->|tRPC over HTTP/WebSocket| D
Architecture:
Data Flow:
remote
directory.go run server.go
to start the Go gRPC server.localhost:50051
).trpc
directory, install dependencies:npm install
client.ts
to connect to the Go server as a gRPC client using generated service_pb.js
and service_grpc_pb.js
files.router.ts
to expose methods via tRPC.node server.ts
http://localhost:4000
or via WebSocket if subscriptions are required).Install dependencies in the root Svelte project directory:
npm install
Configure client.ts
in src/lib/trpc
to connect to the tRPC server.
Use pages in src/routes
(e.g., GetStateInfo.svelte
, Chat.svelte
) to call tRPC methods.
Run the Go gRPC server by navigating to the remote
directory and using:
go run server.go
Run the tRPC server in the trpc
directory:
node server.ts
Run the Svelte client in the root directory:
npm run dev
protobuf_generate.sh
in remote/protobuf
to regenerate Go and Node.js protobuf files if .proto
files are updated.