Thunder - A Minimalist Backend Framework in Go

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

Go Version License Stars Issues

🚀 Features

🏗️ Architecture Overview

421386849-54a1cead-6886-400a-a41a-f5eb4f375dc7(1)

📌 Use Cases

Thunder is designed for scalable microservices and high-performance API development, particularly suited for:

1. High-Performance API Development

2. Microservices Architecture

3. Database Management with Prisma

4. Lightweight Backend Alternative

5. Kubernetes & Cloud-Native Applications

When Not to Use Thunder

📌 Getting Started

Installation

git clone https://github.com/Raezil/Thunder.git
cd Thunder
chmod +x install-thunder.sh
./install-thunder.sh

Setup

Create a new Thunder application:

thunder new myapp
cd myapp

Install Dependencies

go mod tidy

Define Your gRPC Service

Create a .proto file (e.g., example.proto):

syntax = "proto3";

package example;

import "google/api/annotations.proto";

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

message HelloRequest {
	string name = 1;
}

message HelloResponse {
	string message = 1;
}

Add your service entry in services.json:

[
    {
      "ServiceName": "Example",
      "ServiceStruct": "ExampleServiceServer",
      "ServiceRegister": "RegisterExampleServer",
      "HandlerRegister": "RegisterExampleHandler"
    }
]

🛠️ Prisma Integration

Define your schema in schema.prisma:

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id    String @default(cuid()) @id
  name  String
  email String @unique
}

Generate the service implementation:

thunder generate --proto=example.proto

🚀 Running the Server

Start the server:

go run ./pkg/app/server/main.go

Server accessible via HTTP at localhost:8080 and gRPC at localhost:50051.

🚀 Running the Tests

Mocking Tests

cd backend
mockgen -source=yourservice_grpc.pb.go -destination=../tests/yourservice_mock.go

Run Tests

cd app/internal
go test ./tests/...

🔧 Kubernetes Deployment

Generate TLS Certificates

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"

Generate 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"

kubectl create secret generic postgres-secret   --from-literal=POSTGRES_USER=postgres   --from-literal=POSTGRES_PASSWORD=postgres   --from-literal=POSTGRES_DB=thunder

Build & Deploy Docker Image

thunder docker
thunder deploy

Check pod status:

kubectl get pods -n default
kubectl describe pod $NAME -n default

📡 API Testing

Register User

curl -k --http2 -X POST https://localhost:8080/v1/auth/register \
     -H "Content-Type: application/json" \
     -d '{
           "email": "newuser@example.com",
           "password": "password123",
           "name": "John",
           "surname": "Doe",
           "age": 30
         }'

User Login

curl -k --http2 -X POST https://localhost:8080/v1/auth/login \
     -H "Content-Type: application/json" \
     -d '{
           "email": "newuser@example.com",
           "password": "password123"
         }'

📜 Contributing

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature-new
  3. Commit changes: git commit -m "Added feature"
  4. Push to your branch: git push origin feature-new
  5. Submit a pull request.

🔗 References

📣 Stay Connected

⭐ Star the repository if you find it useful!
📧 For support, use GitHub Issues.

License

Thunder is released under the MIT License.

Join libs.tech

...and unlock some superpowers

GitHub

We won't share your data with anyone else.