Code Generation Engine
Sponge provides powerful code generation capabilities, supporting rapid generation of required project code using both built-in and custom templates, and integrating an AI assistant to help generate business logic code.
Generate Code Based on Built-in Templates
Sponge primarily supports generating code frameworks based on SQL and Protobuf. The SQL method supports common databases like MySQL, MongoDB, PostgreSQL, and SQLite. The code generation framework is shown in the figure below:

Feature Overview: Provides a complete solution for Web backend services from development to deployment.
Key Features:
- Supports multiple databases: MySQL, MongoDB, PostgreSQL, SQLite
- Zero-code startup: Generates complete project code just by connecting to the database, ready to use out-of-the-box
- Rich components: Supports logging, rate limiting, circuit breaking, tracing, monitoring, etc.
- Modular design: Supports seamlessly embedding generated
routers
,handler
,dao
,model
,types
module code into service code - Custom API support: Retains traditional Web development methods for adding custom APIs
Applicable Scenarios: Suitable for Web project development primarily based on standardized CRUD APIs.
Feature Overview: Provides a complete solution for gRPC backend services from development to deployment.
Key Features:
- Supports multiple databases: MySQL, MongoDB, PostgreSQL, SQLite
- Automatic proto file generation: Automatically generates API descriptions by parsing SQL
- Rich components: Supports logging, rate limiting, circuit breaking, tracing, service registration and discovery, authentication, monitoring, etc.
- Testing support: Automatically generates gRPC client testing and stress testing code
- Automatic code merging: Newly added APIs are automatically merged into existing code
- Modular design: Supports seamlessly embedding generated
service
,dao
,model
module code into service code
Applicable Scenarios: Suitable for gRPC service project development primarily based on standardized CRUD APIs.
Feature Overview: Provides a complete solution for gRPC+HTTP hybrid backend services from development to deployment.
Key Features:
- Supports multiple databases: MySQL, MongoDB, PostgreSQL, SQLite
- Automatic proto file generation: Automatically generates API descriptions by parsing SQL
- Dual protocol support: APIs simultaneously expose gRPC and HTTP interfaces
- Rich components: Supports logging, rate limiting, circuit breaking, tracing, service registration and discovery, authentication, monitoring, etc.
- Testing support: Automatically generates gRPC client testing and stress testing code
- Automatic code merging: Newly added APIs are automatically merged into existing code
- Modular design: Supports seamlessly embedding generated
router
,handler
,service
,dao
,model
module code into service code
Applicable Scenarios: Suitable for gRPC+HTTP hybrid backend service project development primarily based on standardized CRUD APIs.
Feature Overview: Provides a complete solution for general web backend development.
Key Features:
- Flexible storage selection: Supports integration with any database
- Rich components: Supports logging, rate limiting, circuit breaking, tracing, monitoring, etc.
- Automatic code merging: Newly added APIs are automatically merged into existing code
- Modular design: Supports seamlessly embedding generated
routers
,handler
,dao
,model
module code into service code
Applicable Scenarios: General-purpose Web project backend development, especially for complex business scenarios requiring flexible API interface definitions.
Feature Overview: Provides a complete solution for general gRPC service development.
Key Features:
- Flexible storage: Supports integration with any database
- Rich components: Supports logging, rate limiting, circuit breaking, tracing, service registration and discovery, authentication, monitoring, etc.
- Testing support: Automatically generates gRPC client testing and stress testing code
- Automatic code merging: Newly added APIs are automatically merged into existing code
- Modular design: Supports seamlessly embedding generated
service
,dao
,model
module code into service code
Applicable Scenarios: General-purpose gRPC service projects.
Feature Overview: Provides a complete solution for general gRPC+HTTP hybrid service development.
Key Features:
- Flexible storage: Supports integration with any database
- Dual protocol support: APIs simultaneously expose gRPC and HTTP interfaces
- Rich components: Supports logging, rate limiting, circuit breaking, tracing, service registration and discovery, authentication, monitoring, etc.
- Testing support: Automatically generates gRPC client testing and stress testing code
- Automatic code merging: Newly added APIs are automatically merged into existing code
- Modular design: Supports seamlessly embedding generated
router
,handler
,service
,dao
,model
module code into service code
Applicable Scenarios: Suitable for general backend service projects that support both gRPC and HTTP protocols.
Feature Overview: Provides a complete solution for general gRPC gateway service development.
Key Features:
- Service aggregation: Unified management of multiple gRPC services
- Rich components: Supports logging, rate limiting, circuit breaking, tracing, service registration and discovery, authentication, monitoring, etc.
- Comprehensive features: Supports gateway functionalities like routing and authentication
- Efficient development: Automatically generates API templates
Applicable Scenarios:
- Services that expose RESTful APIs externally and use gRPC internally.
- Aggregating APIs from multiple microservices.
- Gradual migration from systems using REST to new services using gRPC, via the gateway.
Generate Code Based on Custom Templates
In addition to using the built-in templates provided by Sponge to generate code, users can also generate code based on their own templates to meet various business needs. The structure of the generated code is shown in the diagram below:

Sponge supports generating various types of code based on JSON, SQL, and Protobuf using custom templates, including but not limited to:
- Project scaffolding and microservice base code
- Frontend and backend CRUD related code
- CRUD implementations for various ORMs
- gRPC server and client code
- HTTP service API, router, service, etc. code
Generate Code Based on AI Assistants
Sponge also provides an AI assistant to help generate code, enabling users to quickly create business logic code. The structure of the generated code is shown in the diagram below:

sponge's built-in AI assistant provides:
- Concurrent generation of business logic code
- Multi-model code comparison
- One-click code synthesis functionality
More Built-in Code Generation Commands
In addition to the UI interface, sponge also provides rich code generation commands via Makefile, including:
- API template code generation
- gRPC client test code generation
- Router registration code generation
- Error code definition generation
- Automatic code merging
- Protobuf compilation
The code generated by these commands can be seamlessly integrated into the project, truly achieving a "low-code" development experience in Go language.