A simple user management service built using Golang, ScyllaDB, gRPC and served through HTTP using gRPC-gateway which provides a RESTful API interface that proxies HTTP requests to compatible gRPC actions.
- Go: Primary programming language
- gRPC: High-performance RPC framework
- gRPC-Gateway: Proxies HTTP APIs to gRPC
- Protocol Buffers: Interface definition language
- ScyllaDB: Performant NoSQL database
- docker/docker-compose: Containerization and environment setup
- GitHub Actions: CI/CD pipeline for auto deployment
- Buf: Protocol buffer compiler and dependency management
.
├── buf.gen.yaml
├── buf.lock
├── buf.yaml
├── compose.yaml
├── Dockerfile
├── go.mod
├── go.sum
├── main.go
├── proto
│ └── users
│ ├── users_grpc.pb.go
│ ├── users.pb.go
│ ├── users.pb.gw.go
│ └── users.proto
├── README.md
└── src
├── db
│ └── db.go
├── models
│ └── User.go
└── services
└── userService.go
- Go 1.23.0 or later
- Docker and Docker Compose
- Buf CLI
- Git
git clone https://github.com/2k4sm/grpc-crud.git
cd grpc-crud
touch .env
echo "SDB_URI=localhost" >> .env
Then run
docker-compose up -d
This will start a ScyllaDB instance as defined in the compose.yaml
file.
go mod download
buf dep update
and
buf generate
go build -o grpc-crud .
./grpc-crud
Alternatively, you can use:
go run main.go
- grpc-gateway(Http) -> 6969
- grpc(tcp) -> 8080
This is configured for automatic deployment to EC2 using GitHub Actions. When changes are pushed to the main branch, the CI/CD pipeline will:
- Build the application
- Deploy to the EC2 instance
Deployed URL: https://grpc-crud.2k4sm.tech
grpc-crud.postman_collection.json
-
GET /users?email={email}&ph_number={ph_number}: Get a user by email or phone number
curl -X GET "http://localhost:6969/[email protected]"
or
curl -X GET "http://localhost:6969/users?ph_number=1234567890"
-
POST /users: Create a new user
curl -X POST http://localhost:6969/users \ -H "Content-Type: application/json" \ -d '{ "first_name": "John", "last_name": "Doe", "gender": "MALE", "dob": "1990-01-01", "ph_number": "1234567890", "email": "[email protected]", "access": "UNBLOCKED" }'
-
PUT /users/{email}: Update a user by email
curl -X PUT http://localhost:6969/users/[email protected] \ -H "Content-Type: application/json" \ -d '{ "first_name": "John", "last_name": "Doe", "gender": "MALE", "dob": "1990-01-01", "ph_number": "0987654321", }'
-
PATCH /users/{curr_email}: Update a user's email or phone number
curl -X PATCH http://localhost:6969/users/[email protected] \ -H "Content-Type: application/json" \ -d '{ "new_email": "[email protected]", "new_ph_number": "1122334455" }'
-
POST /users/{email}/block: Block a user
curl -X POST http://localhost:6969/users/[email protected]/block
-
POST /users/{email}/unblock: Unblock a user
curl -X POST http://localhost:6969/users/[email protected]/unblock