Build a POS register screen with the gRPC API

Step by step from the stilldeep.v1 .proto files to a first sale: generate the client, open a shift, fill a cart, take a payment and finalize.

Get the contract

The .proto files of the stilldeep.v1 package describe the services of the register, served over gRPC: sales and reservations, catalog, members, users, shifts, appointments, scheduling, rentals, inventory, reports and configuration. .NET clients use the StillDeep.Intelligence.Contracts package; other languages generate their code from the same files. Each .proto file is also served in plain text at /contracts/<file>.proto.

Generate the client

Use the gRPC tools of your language:

  • TypeScript and Node.js: @grpc/grpc-js with ts-proto or protoc-gen-ts.
  • Python: grpcio-tools.
  • Go: protoc-gen-go and protoc-gen-go-grpc.
  • .NET, Java, Kotlin, Rust, C++: the official gRPC generators.

Step-by-step guides with commands are in the reference: generate a client, TypeScript client, Python client, Go client.

Connect to the register

The register engine listens on the register itself (HTTP/2, port 50051 by default). The screen never talks to the business server: the register handles the proxy, the outbox and offline mode for it.

Make a first sale

Open a shift

UserService.Authenticate in password mode (if must_change_password, call ChangePassword first), then ShiftService.GetCurrentShift, or ShiftService.OpenShift when it returns NOT_FOUND. Send the shift id as gRPC metadata x-shift-id on every following call: refunds, discounts, payment refusals and closing the shift require it (UNAUTHENTICATED without it), and a cart needs an open shift on the register.

Open a cart and add items

SalesService.CreateCart (required: post_id, cashier_user_id, idempotency_key), then SalesService.AddItem with one of product_id, sku or barcode and a Quantity in thousandths (default one unit). Find products with CatalogService.SearchProducts or GetProductByBarcode. Optional: SalesService.AssociateMember for a customer. If the response contains a question, ask it and replay the call with answers.

Take the payment

Payment methods come from ConfigService.GetPostConfig (payment_methods). Optional SalesService.BeginPayment or SelectPaymentMethod, then ProcessPayment with method_code, amount in cents and an idempotency_key; repeat for split payments. A refusal arrives in the response with its refusal_guide, and ResolvePaymentRefusal handles it.

Finalize

SalesService.FinalizeTransaction (cart_id, idempotency_key): the engine writes the sale locally and sends it through the outbox. Display what the responses return; never compute a price, a tax or a total in the screen.

Handle refusals

Every refusal comes as a google.rpc.Status with a stable code (for example shift_paused or stock_short). Show the cashier a message based on the code; never retry blindly. The server re-checks every sale, so a refusal can come after the screen thought everything was fine.

Shift pause and inactivity

ConfigService.GetPostConfig returns shift_timeout_minutes (0: unlimited). The register keeps this delay itself, over gRPC as in-process: calls that change a sale or a shift count as activity, and the screen reports the rest through SessionService.ReportActivity (hold_seconds holds the pause during a long gesture, such as a drawer count). When the delay runs out, the register pauses the shift, settles its open sales and raises the notice shift_inactivity_paused; SessionState.idle_pause_at gives the time of the next pause.

Follow the cart

Read the cart again with SalesService.GetCart after each action: the screen always shows what the engine returns, prices, taxes and totals included.

Start from an example

Four complete examples have free screen source code: a pet store with grooming, a movie theater with its box office, snack bar, kiosk and online ticket shop, a campground and a train. They link the .NET libraries in-process; in another language, keep their screens as a model and call the same operations over gRPC.

Contract rules

  • Version 1 never receives a breaking change; a version 2 would be a separate package.
  • Money as int64 cents, percentages as millionths (100% = 1,000,000), quantities in thousandths.
  • Timestamps in UTC.
  • Never trust the screen: the engine and the server validate everything, so keep business rules out of the client.