đ sponge - Awesome Go Library for Distributed Systems

A distributed development framework that integrates automatic code generation, gin and grpc frameworks, base development frameworks
Detailed Description of sponge
English | įŽäŊ䏿
Introduction
Sponge is a powerful and easy-to-use Go development framework. Built on the core philosophy of "Definition is Code", it aims to reshape the backend development experience through automatic generation technology, unleashing productivity and boosting development efficiency.
Sponge deeply integrates a code generation engine, Gin (Web framework), and gRPC (microservice framework), covering the full software lifecycle from project generation, development, and testing to API documentation and deployment.
Core Features:
- Definition-Driven Development: Automatically parses SQL, Protobuf, and JSON configuration files to generate high-quality modular code.
- LEGO-style Assembly: Flexibly combines code modules in a loosely coupled manner, supporting the rapid construction of monolithic applications, microservice clusters, and gateway services, including
RESTful API,gRPC,HTTP+gRPC,gRPC Gateway, etc. - Low Code, High Efficiency: Eliminate the tedious, repetitive tasks of building underlying frameworks, developing CRUD operations, and configuring routing and governance. This allows developers to focus solely on core business logic and rapidly deliver standardized, high-quality backend services.
Why Choose Sponge?
- Extreme Development Efficiency: One-click generation of complete, production-ready backend services, including CRUD, routing, documentation, and service framework code, multiplying development efficiency.
- Out-of-the-box Toolchain: Provides a complete development toolchain (Generation â Business Logic â Testing â Deployment â Monitoring), eliminating the need to piece together fragmented tools.
- Industry Best Practices: Built on the mainstream Go community tech stack (Gin/GORM/gRPC/Protobuf, etc.), with a standardized architecture to reduce technology selection risks.
- Extremely Low Learning Curve: Easy to get started and beginner-friendly, while also meeting the customization needs of senior developers.
- Ideal for Team Collaboration: Unifies project structure, improving team collaboration efficiency and code maintainability.
- Flexible and Extensible: Supports custom templates, not limited to Go; capable of extending to frontend, test scripts, and other arbitrary code generation.
- AI-Driven Development (AI-Native):
- Sponge: automatically builds standardized infrastructure (API, data layer, service framework).
- AI Assistant: analyzes project context and generates code intelligently fill in core business logic based on project context, achieving "Infrastructure Automation, Business Intelligence".
Applicable Scenarios
Sponge is suitable for building high-performance, maintainable backend systems, specifically for:
- Rapid development of RESTful API services.
- Building large-scale microservice architectures.
- Cloud-native application development.
- Rapid refactoring and migration of legacy projects.
- Standardized engineering templates for Go beginners or teams.
Online Demo
No installation required, experience the code generation feature directly in your browser: Code Generation
Note: If you need to run the downloaded service code locally, you must first complete the local installation of Sponge.
Quick Start
-
Install Sponge: Supports Windows, macOS, Linux, and Docker environments. View the Sponge Installation Guide.
-
Open the Code Generation UI Page
sponge runAccess
http://localhost:24631in your local browser to generate code. -
Example: One-click Generation of Web Service Backend Code Based on SQL
- Operation Process:
- Fill Parameters: Connect to the database and select tables in the UI.
- Download Code: Click generate and download the complete project package.
- Generate Swagger Documentation: Execute
make docsin the project root directory. - Start Service: Execute
make run. - Test Interface: Access
http://localhost:8080/swagger/index.htmlin the browser to test APIs via the Swagger interface.
- Operation Process:
Tech Stack & Components
Sponge follows the "batteries included" principle, integrating 30+ mainstream Go ecosystem components, loaded on demand:
| Category | Component |
|---|---|
| Frameworks | Gin, gRPC |
| Database | GORM (MySQL, PostgreSQL, SQLite, etc.), MongoDB |
| Cache/Messaging | Redis, Kafka, RabbitMQ |
| Service Governance | Etcd, Consul, Nacos, Jaeger, Prometheus, OpenTelemetry |
| Others | DTM (Distributed Transaction), WebSocket, Swagger, PProf |
| ... | ... |
đ View the complete list of tech stacks and components.
Architecture & Principles
Code Generation Engine
Sponge provides multiple code generation engines, supporting built-in templates, custom templates, and AI-assisted generation.
- Code generation engine based on built-in templates, as shown below:
- Code generation engine based on custom templates, as shown below:
- Code generation engine based on AI-assisted business logic, as shown below:
Microservice Architecture
The code generated by Sponge follows a typical layered architecture with built-in service governance capabilities. The structure is clear and easy to maintain. The microservice framework structure of Sponge is shown below:
Performance Benchmarks
Based on tests with 50 concurrency and 1 million requests, services generated by Sponge demonstrate excellent performance:
-
HTTP Service
-
gRPC Service
đ View detailed test code and environment.
Directory Structure
The service code directory structure created by Sponge follows the project-layout, supporting Monolith, Multi-Repo, and Mono-Repo patterns.
1. Monolith / Multi-Repo Structure Details.
.
âââ api # Directory for protobuf files and generated *pb.go files
âââ assets # Directory for other assets used with the repository (images, logos, etc.)
âââ cmd # Main application entry directory
âââ configs # Directory for configuration files
âââ deployments # Deployment scripts directory for bare metal, docker, k8s
âââ docs # Directory for design documents and interface documentation
âââ internal # Private application and library code directory
â âââ cache # Cache directory wrapped based on business logic
â âââ config # Go structure configuration file directory
â âââ dao # Data access directory
â âââ database # Database directory
â âââ ecode # Custom business error code directory
â âââ handler # HTTP business functionality implementation directory
â âââ model # Database model directory
â âââ routers # HTTP routing directory
â âââ rpcclient # Client directory for connecting to gRPC services
â âââ server # Service entry, including http, grpc, etc.
â âââ service # gRPC business functionality implementation directory
â âââ types # HTTP request and response types directory
âââ pkg # Library directory that can be used by external applications
âââ scripts # Execution scripts directory
âââ test # Additional external test applications and test data
âââ third_party # Directory for dependent third-party protobuf files or other tools
âââ Makefile # Collection of commands related to development, testing, and deployment
âââ go.mod # Go module dependency and version control file
âââ go.sum # Go module dependency checksum file
2. Mono-Repo Structure Details.
.
âââ api
â âââ server1 # Protobuf files and generated *pb.go directory for Service 1
â âââ server2 # Protobuf files and generated *pb.go directory for Service 2
â âââ server3 # Protobuf files and generated *pb.go directory for Service 3
â âââ ...
âââ server1 # Code directory for Service 1, basically same structure as multi-repo
âââ server2 # Code directory for Service 2, basically same structure as multi-repo
âââ server3 # Code directory for Service 3, basically same structure as multi-repo
âââ ...
âââ third_party # Dependent third-party protobuf files
âââ go.mod # Go module dependency and version control file
âââ go.sum # Go module dependency checksum file
Documentation
Click to view the Official Sponge Documentation, covering core content such as development guides, components, service configuration, and deployment solutions.
Example Projects
Basic Examples
- Web Service (based on SQL, includes CRUD)
- gRPC Microservice (based on SQL, includes CRUD)
- Web Service (based on Protobuf)
- gRPC Microservice (based on Protobuf)
- gRPC Gateway Service (Gateway)
- gRPC+HTTP Microservice (based on Protobuf)
Advanced Projects
- Community Backend Service
- Community Service Microservice Split
- E-commerce Distributed Order System
- E-commerce Flash Sale System (DTM + FlashSale)
- E-shop System
- Appliance Store Management
Contribution
Issues and PRs are welcome! Contribution Guide.
If Sponge is helpful to you, please give it a â Star! This will be our motivation for continuous updates.