> For the complete documentation index, see [llms.txt](https://eric-lo.gitbook.io/lab-grpc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eric-lo.gitbook.io/lab-grpc/write-your-.proto-file.md).

# Write your .proto file

.proto is a file which contains all definition of the gRPC *service* and the method *request* and *response* types using the format of [protocol buffers](https://developers.google.com/protocol-buffers/docs/overview).

Under the workspace, we create folders `src/main/proto` and create our .proto file, `calculator.proto`.

```
cd ~/grpclab
mkdir -p src/main/proto
nano src/main/proto/calculator.proto
```

{% code title="calculator.proto" %}

```
syntax = "proto3";

package calculator;
option java_package = "cslab.grpclab";

// define 2 rpcs for Calculator service
service Calculator {
    rpc Sum(CalculationRequest) returns(CalculationRespond) {};
    rpc Product(CalculationRequest) returns(CalculationRespond) {};
}

//Define the structure of `CalculationRequest` which is the input of the rpcs
message CalculationRequest {
    float a = 1;
    float b = 2;
}

//Define the structure of `CalculationRequest` which is the output of the rpcs
message CalculationRespond {
    float result = 1;
}
```

{% endcode %}
