An open API service indexing awesome lists of open source software.

https://github.com/nhassl3/pizzaland

The backend of a pizza ordering app written in gRPC - github.com/LilBKb/pizza
https://github.com/nhassl3/pizzaland

api backend golang grpc pizza protocol-buffers sqlite web

Last synced: 2 months ago
JSON representation

The backend of a pizza ordering app written in gRPC - github.com/LilBKb/pizza

Awesome Lists containing this project

README

          

![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/nhassl3/pizzaland) ![GitHub contributors](https://img.shields.io/github/contributors/nhassl3/pizzaland)
![GitHub commit activity](https://img.shields.io/github/commit-activity/w/nhassl3/pizzaland) ![GitHub last commit](https://img.shields.io/github/last-commit/nhassl3/pizzaland)

# ๐Ÿ• PizzaLand Backend โ€” gRPC API

> **PizzaLand** is a modern backend for a pizza management system written in **Go**, using **gRPC** and **Protocol Buffers** for high-performance, type-safe communication.

This module represents the **API layer** of the project โ€” it contains:
- All `.proto` definitions (service contracts, messages)
- The Makefile for generating Go stubs
- Code generation utilities for validation, protobuf, and gRPC

---

## ๐Ÿš€ Overview

The **PizzaLand API** defines services and RPC methods for managing pizzas and categories in the system.
It is designed to be clean, scalable, and ready for production.

### ๐Ÿงฉ Service Definition

```markdown
service PizzaLand {
rpc Save(SaveRequest) returns (SaveResponse); // Save pizza procedure
rpc Get(GetRequest) returns (GetResponse); // Get pizza procedure
rpc List(ListRequest) returns (ListResponse); // Get list of the pizza procedure
rpc Update(UpdateRequest) returns (UpdateResponse); // Update pizza properties or price procedure
rpc Remove(RemoveRequest) returns (RemoveResponse); // Remove pizza from system procedure
rpc SaveCategory(SaveCategoryRequest) returns (SaveCategoryResponse); // Save category for pizza on the system procedure
rpc GetCategory(GetCategoryRequest) returns (GetCategoryResponse); // Get category object
rpc GetCategoryList(GetCategoryListRequest) returns (GetCategoryListResponse); // Get list of the category procedure
rpc UpdateCategory(UpdateCategoryRequest) returns (UpdateCategoryResponse); // Update category properties procedure
rpc RemoveCategory(RemoveCategoryRequest) returns (RemoveCategoryResponse); // Remove category from the system procedure
}
```

---

## ๐Ÿ› ๏ธ Project Structure

```
pizzaland/
โ”œโ”€โ”€ proto/
โ”‚ โ””โ”€โ”€ pizzaland/
โ”‚ โ””โ”€โ”€ pizzaland.proto # Main service and message definitions
โ”œโ”€โ”€ generated/
โ”‚ โ””โ”€โ”€ go/ # Generated Go source files
โ”œโ”€โ”€ Makefile # Code generation automation
โ””โ”€โ”€ README.md # You're here ๐Ÿ•
```

---

## โš™๏ธ Code Generation

All protobuf and gRPC Go stubs are generated via **Makefile** commands.

### ๐Ÿงฐ Prerequisites

Install the required tools (if not yet installed):

```bash
make install
```

This will install:

* `protoc-gen-go`
* `protoc-gen-go-grpc`
* `protoc-gen-validate`

### ๐Ÿ”„ Generate bin and run

Generate bin

```bash
make build
```

Run service:

```bash
make run
```

Run tests or bench

```bash
make test
```

```bash
make bench
```

---

## ๐Ÿงช Example Generation Output

After running `make genall`, your `generated/go/` directory will contain:

```
generated/go/
โ”œโ”€โ”€ pizzaland.pb.go
โ”œโ”€โ”€ pizzaland_grpc.pb.go
โ””โ”€โ”€ pizzaland_validate.pb.go
```

These files include:

* Go data structures for messages (`*.pb.go`)
* Server and client stubs for gRPC (`*_grpc.pb.go`)
* Validation logic from `protoc-gen-validate` (`*_validate.pb.go`)

---

## ๐Ÿ“ฆ Integration

You can import the generated Go code into your backend services:

```go
package client

import (
"context"
"fmt"
"log"
"net"

pizzalndv1 "github.com/nhassl3/pizzaland/api/generated/go/pizzaland"
)

func ExampleClient() {
// Example usage
conn, err := net.Dial("tcp", "localhost:44044")
if err != nil {
log.Fatal(err)
}

client := pizzalndv1.NewPizzaLandClient(conn)
res, err := client.Get(context.Background(), &pizzalndv1.GetRequest{
Identifier: &pizzalndv1.GetRequest_PizzaId{
PizzaId: 1,
},
})
if err != nil {
log.Fatal(err)
}
fmt.Println("Pizza:", res.Pizza)
}

// Somewhere in main file (_ = main for example)
func _() {
ExampleClient()
}
```

---

## ๐Ÿ’ก Tips

* Keep `.proto` files small and modular.
* Always re-run `make genall` after editing `.proto` files.
* Use `buf` or `protolint` to ensure protobuf consistency and style.
* Consider versioning API definitions (`pizzaland/v1/`, `pizzaland/v2/`, etc.) as your project grows.

---

## ๐Ÿง‘โ€๐Ÿณ Author & Links

**Author (frontend):** [LilBKb](https://github.com/LilBKb)\
**Author (backend):** [nhassl3](https://github.com/nhassl3)\
**Main Project:** [github.com/LilBKb/pizza](https://github.com/LilBKb/pizza)

---

## ๐Ÿงพ License

This project is licensed under the [MIT License](LICENSE).