Introduction to the Sponge Project
Overview
The Sponge project is a cutting-edge development framework designed to significantly streamline the process of building high-performance back-end services. By integrating tools like automatic code generation
, Gin
, and GRPC
, Sponge effectively simplifies the entire development workflow. With a rich array of code generation commands, the framework allows developers to assemble different functional code segments into a complete service, analogous to how sponge cells naturally converge to form a whole. Sponge facilitates one-stop project development by supporting code generation, development, testing, API documentation, and deployment, thereby boosting efficiency and simplifying the coding process.
Core Philosophy
The main philosophy behind Sponge revolves around the reverse generation of modular code via SQL
or Protobuf
files. This code can be seamlessly combined to create various types of backend services. Consequently, Sponge drastically improves development efficiency while simplifying the complexities usually associated with backend service development. Its objectives include:
- For web and gRPC services with basic CRUD operations, developers can avoid writing any Go code. Sponge automates code generation by interfacing directly with databases, compiling the code for deployment on platforms like Linux servers, Docker, and Kubernetes.
- When utilizing Sponge for more complex setups like web, gRPC, hybrid http+gRPC, and gRPC gateway services, developers need to define three main aspects: database tables, API descriptions in Protobuf files, and application logic in the generated templates. Sponge then auto-generates the required Go code for these parts, including CRUD operations.
Code Generation Framework
Sponge's generation capability is largely powered by SQL
and Protobuf
files, supporting databases like MySQL, MongoDB, PostgreSQL, TiDB, and SQLite. It allows the creation of sophisticated code frameworks as depicted in the illustration below.
Microservice Framework
Sponge also functions as a robust microservices framework, depicted in a typical microservice hierarchical structure. This structure supports high performance and scalability and includes essential features for effective service governance. Users can effortlessly integrate or replace their own governance features within this framework.
To showcase its performance, Sponge-based http and gRPC services underwent rigorous testing. The framework's capabilities were validated under conditions of 50 concurrent users and a total of one million requests.
Key Features
Sponge is equipped with a rich set of features aimed at enhancing development and deployment processes, including:
- Web framework with Gin
- RPC framework using gRPC
- Configuration management through Viper and Nacos
- Logging with Zap
- Database ORM and driving support with GORM and Mongo Go Driver
- Caching capabilities via Redis and Ristretto
- Automated API documentation with Swagger and OpenAPI
- Authentication using JWT
- And many more, including support for WebSockets, Crontabs, Distributed Transactions, Message Queues, and more.
Project Structure
Sponge organizes project directories using the standard project-layout, whether it’s a monolithic application or a microservice assembly. This structure facilitates efficient development and maintenance by compartmentalizing various elements like APIs, configuration files, handlers, models, and third-party tools.
Quick Start
Installation
Sponge can be installed on a variety of platforms, including Windows, macOS, Linux, and Docker environments. Detailed installation instructions are available on the Sponge Installation Guide.
Running the UI Service
After installation, the Sponge UI service can be initiated using:
sponge run
This command launches a local UI interface accessible at http://localhost:24631
, facilitating user interaction with the code generation features of Sponge. For cross-host access, users may specify the host IP or domain when launching the UI service. Instructions for Docker setups are also provided in the installation guide.
Documentation and Examples
Sponge offers detailed documentation, including guides on step-by-step development, configuration, and deployment processes, accessible through the Sponge Development Documentation. Additionally, it provides comprehensive examples covering various service creations and complete projects.
Conclusion
Sponge is an innovative framework that revolutionizes back-end development for different application scenarios. By automating code generation and integrating essential service features, it empowers developers to produce high-quality applications efficiently and effectively. If you find it helpful, consider giving it a star on its repository.