High Performance

Thunder

A Minimalist Backend Framework in Go

A gRPC-Gateway-powered framework with Prisma, Kubernetes, and Go for building scalable microservices.

$ ./install.sh

$ thunder init myproject

Creating new Thunder project: myproject

Setting up project structure...

✓ Project created successfully!

$ cd myproject

$ go mod tidy

$ thunder serve

Starting gRPC server on port 50051

Starting REST gateway on port 8080

✓ Server is running!

Key Features

gRPC + REST

Automatically expose RESTful APIs from gRPC services with gRPC-Gateway.

Prisma Integration

Efficient database management and migrations with Prisma ORM.

Kubernetes Ready

Easily deploy and scale your services with Kubernetes.

TLS Security

Secure gRPC communications with TLS for enhanced security.

Structured Logging

Built-in zap logging for better insights into your application.

Rate Limiting & Auth

Pre-configured middleware for rate limiting and authentication.

Modular & Extensible

Easily extend Thunder for custom use cases and requirements.

Thunder CLI

Generate, deploy, and create new projects effortlessly.

Use Cases

High-Performance API Development

  • gRPC-first APIs with RESTful interfaces
  • Critical performance and low latency applications
  • Strongly-typed APIs with protobufs

Microservices Architecture

  • Efficient inter-service communication
  • Kubernetes deployments with built-in service discovery
  • Automatic scaling and load balancing

Database Management with Prisma

  • Type-safe queries and easy migrations
  • Support for multiple databases
  • Efficient database management

Lightweight Backend Alternative

  • Minimalist and powerful framework
  • Alternative to Gin or Echo
  • Fast, simple, and modular backend

Kubernetes & Cloud-Native

  • Containerized environments using Docker.
  • Automatic service scaling and load balancing.

Getting Started


# Create a Protobuf file (example.proto)
syntax = "proto3";

package example;

import "google/api/annotations.proto";

service Example {
  rpc SayHello(HelloRequest) returns (HelloResponse) {
    option (google.api.http) = {
      get: "/v1/example/sayhello"
    };
  };
}

message HelloRequest {
  string name = 1;
}

message HelloResponse {
  string message = 1;
}

# Define the service in services.json
[
  {
    "ServiceName": "Example",
    "ServiceStruct": "ExampleServiceServer",
    "ServiceRegister": "RegisterExampleServer",
    "HandlerRegister": "RegisterExampleHandler"
  }
]

# Generate the service implementation
thunder generate --proto=example.proto
            

Deploy on Kubernetes

Follow these steps to deploy Thunder on Kubernetes:


$ # PgBouncer Secret Configuration
$ echo '"postgres" "postgres"' | base64
InBvc3RncmVzIiAicG9zdGdyZXMiCg==
$ # Update the pgbouncer-all.yaml with the new base64 value

$ # Generate TLS Certificates
$ cd cmd
$ mkdir certs
$ openssl req -x509 -newkey rsa:4096 -keyout certs/server.key -out certs/server.crt -days 365 -nodes \
  -subj "/CN=localhost" \
  -addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
Generating a RSA private key
...............+++++
...+++++
writing new private key to 'certs/server.key'
-----

$ # Create Kubernetes Secrets
$ kubectl create secret generic app-secret \
  --from-literal=DATABASE_URL="postgres://postgres:postgres@pgbouncer-service:6432/thunder?sslmode=disable" \
  --from-literal=JWT_SECRET="secret"
secret/app-secret created

$ kubectl create secret generic postgres-secret \
  --from-literal=POSTGRES_USER=postgres \
  --from-literal=POSTGRES_PASSWORD=postgres \
  --from-literal=POSTGRES_DB=thunder
secret/postgres-secret created

$ # Build & Deploy Docker Image
$ thunder build
Building Thunder container image...
✓ Successfully built thunder:latest

$ thunder deploy
Deploying Thunder to Kubernetes...
✓ Deployment successful!

$ # Check pod status
$ kubectl get pods -n default
NAME                        READY   STATUS    RESTARTS   AGE
thunder-5f7b849d8d-x2jtl    1/1     Running   0          30s
postgres-0                  1/1     Running   0          30s
pgbouncer-7c8b6d5b4-rmvp9  1/1     Running   0          30s

$ kubectl describe pod thunder-5f7b849d8d-x2jtl -n default
Name:         thunder-5f7b849d8d-x2jtl
Namespace:    default
Priority:     0
...