# luca5lima/grpc-calculator architecture

> Architecture diagram of the GitHub repository luca5lima/grpc-calculator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/luca5lima/grpc-calculator
- Repository: https://github.com/luca5lima/grpc-calculator

## Overview

This is a small distributed calculator: a terminal user selects an operation and enters three numbers, the client builds a protobuf request and makes a unary gRPC call, and the server computes a result or reports division-by-zero before returning a response. The proto defines the RPC and message contract; generated Python bindings support both endpoints. README documents the HTTP/2 client-server exchange and generated-code relationship. The generated binding files are present in the tree but were not excerpted, so their internal behavior is not expanded here.

Main entry points: [`cliente.py`](https://github.com/luca5lima/grpc-calculator/blob/main/cliente.py) (Interactive client), [`servidor.py`](https://github.com/luca5lima/grpc-calculator/blob/main/servidor.py) (RPC server and operations), [`calculadora_pb2.py`](https://github.com/luca5lima/grpc-calculator/blob/main/calculadora_pb2.py) (Message bindings), [`calculadora_pb2_grpc.py`](https://github.com/luca5lima/grpc-calculator/blob/main/calculadora_pb2_grpc.py) (RPC bindings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_client_app["Interactive client<br/>[cliente.py]"]
end

subgraph group_contract["RPC contract"]
  node_message_bindings["Message bindings<br/>[calculadora_pb2.py]"]
  node_rpc_bindings["RPC bindings"]
  node_service_contract["Calculator contract<br/>[calculadora.proto]"]
end

subgraph group_server["Server"]
  node_calculator_service["RPC server and operations<br/>[servidor.py]"]
end

node_user(("Terminal user"))
node_grpc_transport{{"gRPC over HTTP/2"}}

node_user -->|"enters values"| node_client_app
node_client_app -->|"builds request"| node_message_bindings
node_client_app -->|"calls stub"| node_rpc_bindings
node_client_app -->|"sends RPC"| node_grpc_transport
node_grpc_transport -->|"routes RPC"| node_calculator_service
node_calculator_service -->|"builds response"| node_message_bindings
node_calculator_service -->|"registers servicer"| node_rpc_bindings
node_service_contract -->|"defines messages"| node_message_bindings
node_service_contract -->|"defines RPCs"| node_rpc_bindings
node_calculator_service -->|"serves calls"| node_grpc_transport
node_grpc_transport -->|"returns result"| node_client_app

click node_client_app "https://github.com/luca5lima/grpc-calculator/blob/main/cliente.py"
click node_message_bindings "https://github.com/luca5lima/grpc-calculator/blob/main/calculadora_pb2.py"
click node_rpc_bindings "https://github.com/luca5lima/grpc-calculator/blob/main/calculadora_pb2_grpc.py"
click node_service_contract "https://github.com/luca5lima/grpc-calculator/blob/main/calculadora.proto"
click node_calculator_service "https://github.com/luca5lima/grpc-calculator/blob/main/servidor.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_app,node_user toneBlue
class node_message_bindings,node_rpc_bindings,node_service_contract toneAmber
class node_calculator_service toneMint
class node_grpc_transport toneIndigo
```

## Components

### Client

- [Interactive client](https://github.com/luca5lima/grpc-calculator/blob/main/cliente.py): `cliente.py`

### RPC contract

- [Message bindings](https://github.com/luca5lima/grpc-calculator/blob/main/calculadora_pb2.py): `calculadora_pb2.py`
- [RPC bindings](https://github.com/luca5lima/grpc-calculator/blob/main/calculadora_pb2_grpc.py): `calculadora_pb2_grpc.py`
- [Calculator contract](https://github.com/luca5lima/grpc-calculator/blob/main/calculadora.proto): `calculadora.proto`

### Server

- [RPC server and operations](https://github.com/luca5lima/grpc-calculator/blob/main/servidor.py): `servidor.py`

### Other components

- **Terminal user**
- **gRPC over HTTP/2**

## Connections

- Terminal user → Interactive client: enters values (evidence: `README.md`)
- Interactive client → Message bindings: builds request (evidence: `cliente.py`)
- Interactive client → RPC bindings: calls stub (evidence: `cliente.py`)
- Interactive client → gRPC over HTTP/2: sends RPC (evidence: `README.md`)
- gRPC over HTTP/2 → RPC server and operations: routes RPC (evidence: `README.md`)
- RPC server and operations → Message bindings: builds response (evidence: `servidor.py`)
- RPC server and operations → RPC bindings: registers servicer (evidence: `servidor.py`)
- Calculator contract → Message bindings: defines messages (evidence: `README.md`)
- Calculator contract → RPC bindings: defines RPCs (evidence: `README.md`)
- RPC server and operations → gRPC over HTTP/2: serves calls (evidence: `servidor.py`)
- gRPC over HTTP/2 → Interactive client: returns result (evidence: `README.md`)
