Giter VIP home page Giter VIP logo

sponge's Introduction

English | 简体中文

Go Report codecov Go Reference Go Awesome Go License: MIT

Sponge is a basic development framework that integrates code auto generation, Gin and GRPC, sponge has a rich set of code generation commands, generating different functional code can be combined into a complete service (similar to the way that artificially broken sponge cells can automatically recombine into a new sponge). The code is decoupled and modularly designed, it is easy to build a complete project from development to deployment, just fill in the business logic code on the generated template code, greatly improved development efficiency and reduced development difficulty, the use of Go can also be "low-code development".


If you are develop RESTful web service or microservice with a simple CRUD API interface, you don't need to write any Go code can be compiled and deployed to the linux server, docker, k8s, just need to connect to the database (mysql、mongodb、postgresql、tidb、sqlite) to generate a complete service code.

If you develop generic web or microservices, just focus on the three core parts of define database tables, define api interfaces in proto files, fill in business logic code in the generated template files, and the rest of the go code is automatically generated by sponge.


Sponge Generates the Code Framework

sponge is mainly based on SQL and Protobuf two ways to generate code, each way has to generate code for different functions. SQL supports databases mysql, mongodb, postgresql, tidb, sqlite.

Generate Code Framework


Generate Code Framework Corresponding UI Interface


Generate Service Code for Egg Model

The sponge code generation process strips away the business logic and non-business logic of the two major parts of the code. Sponge's code generation function as a hen, the generated service code is the egg, take the generated web service backend code as an example, egg model profiling diagram:

In addition to the egg model of web service backend code, there are egg models of grpc service code and grpc gateway service code, click here to view.


Services framework

Sponge is essentially a microservice framework that includes code generation capabilities. The microservice framework is shown in the following figure, which is a typical microservice hierarchical structure, with high performance, high scalability, contains commonly used service governance features, you can easily replace or add their own service governance features.


Key Features


Project Code Directory Structure

The project code directory structure created by sponge follows the project-layout convention and is structured as follows:

.
├── api            # Directory for exposing external API interfaces, typically containing proto files and generated *.pb.go files. The directory structure is typically in the form `api/xxx/v1`, where v1 indicates the version.
├── assets         # Store various static resources, such as images, markdown files, etc.
├── cmd            # Program entry directory
│    └── serviceName
│         ├── initial     # Program initialization, consisting of three files: initApp initializes configurations, registerServers registers services (HTTP or grpc), and registerClose registers resource cleanup.
│         └── main.go     # Program entry file
├── configs        # Directory for configuration files
├── deployments    # Directory for deployment scripts, supporting binary, Docker and Kubernetes deployments.
├─ docs            # Directory for API interface Swagger documentation.
├── internal       # Directory for code of private applications and libraries.
│    ├── cache        # Cache directory wrapped around business logic.
│    ├── config       # Directory for Go structure configuration files.
│    ├── dao          # Data access 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, including compilation, execution, code generation, and deployment scripts.
├── test           # Directory for scripts required for testing services  and test SQL.
└── third_party    # Directory for external helper programs, forked code, and other third-party tools.

Quick start

Installation sponge

sponge can be installed on Windows, macOS, Linux and Docker environments. Click here for instructions on installing sponge.

Starting UI service

After installing the sponge, start the UI service:

sponge run

Access http://localhost:24631 in a local browser and manipulate the generated code on the UI page.

If you want to access it on a cross-host browser, you need to specify the host ip or domain name when starting the UI, example sponge run -a http://your_host_ip:24631. It is also possible to start the UI service on docker to support cross-host access, Click for instructions on starting the sponge UI service in docker.


Sponge Development Documentation

Detailed instructions for operating, configuring, and deploying a project using sponge development, Click here to view the sponge development documentation


Examples of use

Simple examples

No specific business logic code is included.

Complete project examples

Distributed transaction examples


License

See the LICENSE file for licensing information.


How to contribute

You are more than welcome to join us, raise an Issue or Pull Request.

Pull Request instructions.

  1. Fork the code
  2. Create your own branch: git checkout -b feat/xxxx
  3. Commit your changes: git commit -am 'feat: add xxxxx'
  4. Push your branch: git push origin feat/xxxx
  5. Commit your pull request

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


sponge's People

Contributors

zhufuyi avatar gitter-badger avatar cbot918 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.