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
- Host: GitHub
- URL: https://github.com/nhassl3/pizzaland
- Owner: nhassl3
- License: mit
- Created: 2025-10-29T14:17:04.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-11-18T15:23:20.000Z (8 months ago)
- Last Synced: 2025-11-18T16:38:47.364Z (8 months ago)
- Topics: api, backend, golang, grpc, pizza, protocol-buffers, sqlite, web
- Language: Go
- Homepage:
- Size: 43.3 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
 
 
# ๐ 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).