Thunder is a minimalist and powerful Go backend framework that effortlessly transforms gRPC services into fully functional REST and GraphQL APIs.
Key metrics and engagement data
Repository has been active for 8 months
⭐67
Want deeper insights? Explore GitObs.com
A scalable microservices framework powered by Go, gRPC-Gateway, Prisma, and Kubernetes. It exposes REST, gRPC and Graphql
zap
logging.Thunder is designed for scalable microservices and high-performance API development, particularly suited for:
bash1git clone https://github.com/Raezil/Thunder.git2cd Thunder3chmod +x install.sh4./install.sh
Remember to install prerequisites, there is tutorial for this https://github.com/Raezil/Thunder/issues/99
Create a new Thunder application:
bash1thunder init myapp2cd myapp
bash1go mod tidy
Create a .proto
file (e.g., example.proto
):
proto1syntax = "proto3";23package example;45import "google/api/annotations.proto";6import "graphql.proto";78service Example {9 rpc SayHello(HelloRequest) returns (HelloResponse) {10 option (google.api.http) = {11 get: "/v1/example/sayhello"12 };13 option (graphql.schema) = {14 type: QUERY // declare as Query15 name: "sayhello" // query name16 };17 };18}1920message HelloRequest {21 string name = 1 [(graphql.field) = {required: true}];22}2324message HelloResponse {25 string message = 1;26}
Use the new scaffold
command to spin up a full CRUD .proto
file—complete with gRPC, REST (gRPC-Gateway) and GraphQL annotations. Pass your fields as a comma-separated list of name:type
pairs:
bash1thunder scaffold -service UserService -entity User -fields "id:string,name:string,email:string,age:int32"
Add your service entry in services.json
:
go1[2 {3 "ServiceName": "Example",4 "ServiceStruct": "ExampleServiceServer",5 "ServiceRegister": "RegisterExampleServer",6 "HandlerRegister": "RegisterExampleHandler"7 "GraphqlHandlerRegister": "RegisterExampleGraphqlHandler"89 }10]
Define your schema in schema.prisma
:
prisma1datasource db {2 provider = "postgresql"3 url = env("DATABASE_URL")4}56model User {7 id String @default(cuid()) @id8 name String9 email String @unique10}
Generate the service implementation:
bash1thunder generate --proto=example.proto --graphql=true
Start the server:
bash1go run ./cmd/app/server/main.go
Server accessible via HTTP at localhost:8080
and gRPC at localhost:50051
.
bash1cd pkg/services/generated2mockgen -source=yourservice_grpc.pb.go -destination=./yourservice_mock.go
bash1go test ./pkg/db ./pkg/middlewares/ ./pkg/services/ ./pkg/services/generated
This setup configures PgBouncer to connect to a PostgreSQL database using Kubernetes resources.
userlist.txt
SecretTo regenerate and update the userlist.txt
secret, use the following command to encode the credentials:
bash1echo '"postgres" "postgres"' | base64
Now, update pgbouncer-all.yaml
under the Secret
section with the new base64-encoded value:
yaml1apiVersion: v12kind: Secret3metadata:4 name: pgbouncer-secret5type: Opaque6data:7 userlist.txt: <BASE64_ENCODED_VALUE> # "postgres" "postgres" in base64
bash1cd cmd2mkdir certs3openssl req -x509 -newkey rsa:4096 -keyout certs/server.key -out certs/server.crt -days 365 -nodes \4 -subj "/CN=localhost" \5 -addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
bash1kubectl create secret generic app-secret --from-literal=DATABASE_URL="postgres://postgres:postgres@pgbouncer-service:6432/thunder?sslmode=disable" --from-literal=JWT_SECRET="secret"23kubectl create secret generic postgres-secret --from-literal=POSTGRES_USER=postgres --from-literal=POSTGRES_PASSWORD=postgres --from-literal=POSTGRES_DB=thunder
bash1thunder build2thunder deploy
Check pod status:
bash1kubectl get pods -n default2kubectl describe pod $NAME -n default
git checkout -b feature-new
git commit -m "Added feature"
git push origin feature-new
⭐ Star the repository if you find it useful!
📧 For support, use GitHub Issues.
Thunder is released under the MIT License.