1 Star 5 Fork 6

zhufuyi/sponge

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

English | 简体中文

Go Report codecov Go Reference Go Awesome Go License: MIT

Sponge is a powerful Go development framework. Its core concept revolves around reverse-engineering modular code by parsing JSON, SQL, or Protobuf files. The generated code can be flexibly and seamlessly assembled into various types of complete backend services (similar to the characteristics of sponge cells, where disassembled sponge cells can automatically recombine into a new sponge).

Sponge provides an all-in-one solution for project development, covering code generation, development, testing, API documentation, and deployment, significantly enhancing development efficiency, reducing complexity, and enabling high-quality projects with a "low-code approach".


Applicable scenarios

Sponge is suitable for quickly developing various high-performance backend services, including but not limited to:

  • Web services (gin);
  • gRPC services;
  • HTTP+gRPC hybrid services;
  • gRPC Gateway API services;
  • cloud-native microservices.

Additionally, developers can use custom templates to generate various types of code to meet specific business needs.


Core Highlights

  1. One-click generation of complete backend service code
    For Web or gRPC services that only require CRUD APIs, no Go code needs to be written. Simply connect to a database (e.g., MySQL, MongoDB, PostgreSQL, SQLite) to one-click generate complete backend service code and easily deploy it to Linux servers, Docker, or Kubernetes.

  2. Efficient development of general-purpose services
    When developing general-purpose Web, gRPC, HTTP+gRPC, or gRPC Gateway services, you only need to focus on three aspects:

    • Defining database tables;
    • Defining API descriptions in Protobuf files;
    • Writing business logic code in the generated templates.

    The framework code and CRUD API code are all automatically generated by sponge.

  3. Support for custom templates, offering flexible extensibility
    sponge supports generating various types of project-specific code using custom templates, not limited to the Go language. For example:

    • Backend code;
    • Frontend code;
    • Configuration files;
    • Test code;
    • Build and deployment scripts, etc.
  4. Generate code on the page, simple and easy to use


Quick Start

  1. Install sponge

    Sponge supports installation on Windows, macOS, and Linux. Click to view the sponge installation guide.

  2. Open the code generation UI

    After installation, run the following command to open the sponge UI:

    sponge run
    

    Access http://localhost:24631 in a local browser to generate code through the UI interface, as shown below:

    To access from a browser on a different host, specify the host IP or domain when starting the UI, e.g., sponge run -a http://your_host_ip:24631. Alternatively, you can run the UI service in Docker to support cross-host access. Click to view the guide on running the sponge UI service in Docker.


Main Features

Sponge has built-in rich features (for on-demand use):


Generates Code Framework

Sponge supports generating code using both built-in templates and custom templates, as shown in the diagrams below.

  1. The code generation framework based on Sponge's built-in templates is shown below. There are two approaches: SQL and Protobuf.


  1. The code generation framework based on custom templates is shown below. There are three approaches: JSON, SQL, and Protobuf.


Microservice framework

Five of the six types of back-end services created by sponge are microservice architectures. The diagram below illustrates a typical layered microservice structure, featuring high performance, scalability, and built-in service governance capabilities.


Performance testing of http and grpc service code created by the microservices framework: 50 concurrent, 1 million total requests.

http-server

grpc-server

Click to view the test code.


Project Code Directory Structure

The project code directory structure created by sponge follows the project-layout.

Sponge supports creating three types of project code structures: Monolithic application monorepo (monolith), Microservices multi-repo (multi-repo), and Microservices monorepo (mono-repo).

  1. The code directory structure for creating a Monolithic application monorepo (monolith) or Microservices multi-repo (multi-repo) is as follows:

    .
    ├── api            # Protobuf files and generated * pb.go directory
    ├── assets         # Store various static resources, such as images, markdown files, etc.
    ├── cmd            # Program entry directory
    ├── configs        # Directory for configuration files
    ├── deployments    # Bare metal, docker, k8s deployment script directory.
    ├── docs           # Directory for API interface Swagger documentation.
    ├── internal       # Directory for business logic code.
    │    ├── cache        # Cache directory wrapped around business logic.
    │    ├── config       # Directory for Go structure configuration files.
    │    ├── dao          # Data access directory.
    │    ├── database     # database directory.
    │    ├── ecode        # Directory for system error codes and custom business error codes.
    │    ├── handler      # Directory for implementing HTTP business functionality (specific to web services).
    │    ├── model        # Database model directory.
    │    ├── routers      # HTTP routing directory.
    │    ├── rpcclient    # Directory for client-side code that connects to grpc services.
    │    ├── server       # Directory for creating services, including HTTP and grpc.
    │    ├── service      # Directory for implementing grpc business functionality (specific to grpc services).
    │    └── types        # Directory for defining request and response parameter structures for HTTP.
    ├── pkg            # Directory for shared libraries.
    ├── scripts        # Directory for scripts.
    ├── test           # Directory for scripts required for testing services  and test SQL.
    ├── third_party    # Directory for third-party protobuf files or external helper programs.
    ├── Makefile       # Develop, test, deploy related command sets .
    ├── go.mod         # Go module dependencies and version control file.
    └── go.sum         # Go module dependencies key and checksum file.
    

  1. The code directory structure for creating a Microservices monorepo (mono-repo) (large repository code directory structure) is as follows:

    .
    ├── 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, it has a similar structure to the microservice multi repo directory.
    ├── server2        # Code directory for Service 2, it has a similar structure to the microservice multi repo directory.
    ├── server3        # Code directory for Service 3, it has a similar structure to the microservice multi repo directory.
    ├── ...
    ├── third_party    # Third-party protobuf files.
    ├── go.mod         # Go module dependencies and version control file.
    └── go.sum         # Go module dependencies' checksums and hash keys.
    

Sponge Development Documentation

Click to view the detailed documentation for Sponge development project, including code generation, development, configuration, and deployment instructions, and more.


Examples of use

Examples of create services

Examples of develop complete project

Distributed transaction examples



If it's help to you, give it a star ⭐.


MIT License Copyright (c) 2022 zhuyasen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

sponge是一个强大的Go开发框架,提供一站式项目开发解决方案,涵盖代码生成、开发、测试、API 文档生成和部署,大幅提升开发效率,降低开发难度,实现以"低代码"方式开发RESTful API,gRPC和微服务项目。 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/zhufuyi/sponge.git
git@gitee.com:zhufuyi/sponge.git
zhufuyi
sponge
sponge
main

搜索帮助