Why I chose gRPC for the UI of my POS
I spent seven years building a point of sale and adapting it to different customers. Changing the screens was a recurring part of the work.
With StillDeep, I wanted to be able to build a different interface for a business while keeping the same engine underneath. That led me to use a public gRPC contract between the UI and the engine.
A screen asks for an operation and works with the result. It does not need access to the engine's internal classes or database.
A client generated from the contract
The contract describes the available services, their requests and their responses in Protocol Buffers files. gRPC tooling uses those definitions to generate a client.
In C#, that gives me typed requests and responses. When I write a screen, I can see what an operation expects and what it returns. The compiler catches type mismatches while I'm working on the client.
It also leaves room for someone to build an interface in another language supported by gRPC. They can generate their client from the same definitions without needing to port the engine to their stack.
For me, that is useful when adapting the product to a business. A developer can spend time on the employee's workflow and the layout, then call the operations the screen needs. Prices, taxes and the resulting cart still come from the engine.
Specialized rules can stay behind that boundary too. In the animal care example, Pets adds the animal-specific records and rules alongside the engine's shared operations. The UI uses the public contract to work with them.
Keeping that boundary in Blazor
The web example uses Blazor's interactive server model. Its C# screen code runs on the server, where the host starts the POS library locally. The screens access the public contract through the .NET client.
The contract and the transport are separate concerns here. Using a gRPC contract does not mean that every browser click opens a native gRPC connection. I keep the same API boundary even when the host runs the POS library in the same process.
That also gives me room to change the engine internally. As long as I preserve an operation's contract, a screen can keep using it. I still have to maintain that compatibility; choosing gRPC does not do that work for me.
I plan to release the Blazor UI as open source so developers and resellers can adapt the screens to their customers and branding. The engine remains proprietary and is still in development. The contract gives them a way to use it without needing its source.
The Blazor files are not public yet. The gRPC introduction covers service definitions and generated clients. You can also try the StillDeep pet store demo to see an interface built on this boundary.
Comments
No comments yet. Start the discussion.