DEV Community

Cover image for Disrupting Traditional Development: DeepSeek R1 + Sponge for Rapidly Building Production-Level Backend Services from Scratch
zhuyasen
zhuyasen

Posted on

Disrupting Traditional Development: DeepSeek R1 + Sponge for Rapidly Building Production-Level Backend Services from Scratch

Background Introduction

Background of Technological Evolution

With the rise of open-source AI tools like DeepSeek, intelligent programming assistants are reshaping the software development process. For developers, AI-assisted coding has become a productivity tool. Although AI currently cannot directly generate complete production-level projects based on requirement documents and specified technology stacks, it has shown remarkable potential in specific scenarios: the accuracy of generating code snippets based on detailed logical descriptions can reach over 80%. At present, AI still lacks sufficient engineering capabilities for projects, while the Sponge framework excels in engineering capabilities, making them complementary to each other.

Sponge is a powerful Go language development framework that currently offers over 40 code generation commands. Its unique reverse engineering capability supports generating modular code by parsing SQL/Protobuf/JSON, which can flexibly combine to create various service architectures such as Web, gRPC, HTTP+gRPC, and gRPC gateways. Developers only need to fill in the business logic in the generated project code to quickly build production-level backend services. The code generation framework diagram of Sponge is shown below:

Image description

Sponge Github: https://github.com/go-dev-frame/sponge

Golden Combination

When the engineering capabilities of Sponge meet the intelligent generation of DeepSeek, a complete and efficient development solution is formed:

  • Sponge: Responsible for generating infrastructure code (service framework, CRUD API interfaces, custom API interfaces lacking business logic implementation, etc.).
  • DeepSeek: Focused on business logic implementation (table DDL design, custom API interface definitions, business logic implementation code).

It is worth mentioning that Sponge has integrated DeepSeek's API, allowing for simple command execution to automatically search for methods in the project code that require business logic completion, enabling DeepSeek to generate the business logic implementation code.

Project Practical Example: Building a Home Appliance Retail Management Platform from Scratch

Below is an example of building a product management platform for an offline home appliance store, illustrating how to use Sponge and DeepSeek to collaboratively develop backend services. The backend technology stack chosen for this example is Web Service (Gin + Gorm + Protobuf).

Tip: Here, the request and response data structures of the API interfaces are defined in Protobuf files, taking full advantage of Protobuf's benefits—parsing Protobuf to generate the necessary framework code and API interface documentation.

1. Generate Functional Requirements Document

First, generate a detailed functional requirements document using DeepSeek R1. Input the following prompt:

"Now, we need to implement the backend service for a product management platform of an offline home appliance store. Please list the detailed functional requirements."

DeepSeek R1 will generate a comprehensive requirements document. Developers can remove unnecessary functions based on actual needs, retain the required functional modules, or add additional functional modules. Click to view the Home Appliance Retail Management Platform Functional Requirements Document.

2. Generate MySQL Table Structure DDL

Next, generate the DDL for all MySQL table structures based on the functional requirements document. Input the following prompt:

"Based on the functional requirements document, generate the DDL for all MySQL table structures required by the backend service. The generated SQL should be directly importable into MySQL to create tables, and each column in the tables should include English comments."

DeepSeek R1 will generate the corresponding MySQL table structure DDL based on the requirements document. Developers need to verify whether it fully meets the requirements and make manual adjustments if necessary. Click to view the Home Appliance Retail Management Platform Table Structure DDL.

After importing the MySQL table structure DDL into MySQL, it provides data structure support for subsequent code generation. Sponge can generate various module codes based on these table structures, such as CRUD API code and CRUD Protobuf definitions.

3. API Interface Definition

3.1 Generate CRUD API Protobuf

On Sponge's code generation page, select: 【Public】→【Generate Protobuf CRUD Code】, fill in the parameters, and click the 【Download Code】 button to generate the code, as shown below:

Image description

Tip: If there are many generated proto files, it is recommended to merge them into one file because DeepSeek R1 has a limit on the number of files that can be uploaded.

3.2 Generate Custom API Protobuf

Standard CRUD APIs cannot cover all business requirements, so it is necessary to generate custom API Protobuf definitions based on the CRUD API Protobuf file and the functional requirements document.

Upload the CRUD API proto file and the home appliance retail management platform functional requirements document to DeepSeek R1, and input the following prompt:

All MySQL table standard CRUD API Protobuf definitions have been determined. These APIs only cover part of the backend service functions of the home appliance retail management platform. To cover all functions, please supplement custom API Protobuf definitions based on the CRUD API Protobuf definitions and the home appliance retail management platform functional requirements document. The requirements are as follows:
1. Each rpc method must include option (google.api.http).
2. The rpc method and its message fields must include English comments, and the rpc method must describe the logical implementation process in detail (as the basis for AI-generated business logic code).
3. The supplemented APIs need to identify their belonging Protobuf service.
Enter fullscreen mode Exit fullscreen mode

Tip: If the rpc method comments in the generated Protobuf description are not detailed enough (e.g., logical implementation process, specified technology stack), they can be manually supplemented and improved.

The generated custom API Protobuf, together with the CRUD API Protobuf, constitutes the complete API interface definition of the service, providing the basis for subsequent Sponge code generation.

4. Create Service Code

Take the Web service as an example (technology stack: Gin + Gorm + Protobuf) for subsequent code generation and integration.

4.1 Generate Service Base Code

On Sponge's code generation page, select: 【Protobuf】→【Create Web Service】, fill in the parameters, and click the 【Download Code】 button to generate the code. As shown below:

Image description

The generated code package includes the basic framework of the service. After decompressing, enter the code directory.

4.2 Generate CRUD API Code

Similarly, on Sponge's code generation page, select: 【Public】→【Generate Handler CRUD Code】, fill in the parameters, and click the 【Download Code】 button to generate the code, as shown below:

Image description

Decompress the file and move the generated api and internal directories to the service code directory.

Open the project code using VS Code or Goland, and manually merge the custom API Protobuf files generated earlier by DeepSeek R1 into the corresponding proto files in the api/store/v1 directory.

Then, execute the following command in the project root directory to generate the code:

make proto
Enter fullscreen mode Exit fullscreen mode

Tip: Whenever the proto file is modified, the make proto command needs to be re-executed. Code generation can be specified by the proto file name.

5. Business Logic Code Completion

Sponge integrates the DeepSeek API, which can automatically locate the method functions that need to be supplemented with business logic, allowing the AI assistant to generate business logic implementation code. Execute the following command:

sponge assistant generate --type=deepseek --model=deepseek-reasoner --api-key=xxxx --dir=.
Enter fullscreen mode Exit fullscreen mode

The generated business logic code will be saved in the corresponding directory with a .assistant suffix. Developers only need to copy it into the corresponding method functions. The reason for not using automatic filling here is that DeepSeek R1 output may include markdown and other non-pure Go code, so manual verification and copying are required.

6. Test and Verify API Functions

At this point, most of the code has been automatically generated through the collaboration of Sponge and DeepSeek. If the AI assistant cannot meet the requirements based on detailed prompts to generate business logic implementation code, manual coding is required. The complete web service code egg model is as follows:

Image description

Next, developers debug and verify the API functions, start the service:

make run
Enter fullscreen mode Exit fullscreen mode

Use a browser to access the Swagger interface for API debugging: http://localhost:8080/apis/swagger/index.html

Image description

This is the backend service example code generated by Sponge and DeepSeek collaboration.

Summary

This article demonstrates the entire process of how to leverage Sponge and DeepSeek R1 for collaborative backend service development through a case study of an appliance retail management platform:

  1. Requirement Analysis: Utilize DeepSeek R1 to generate detailed functional requirement documents.
  2. Database Design: Generate MySQL table structure DDL based on requirements and import it into the database.
  3. Interface Definition: First generate Protobuf for standard CRUD APIs, then use DeepSeek R1 to generate Protobuf definition information for custom APIs.
  4. Service Code Generation: Use Sponge to generate basic service code, CRUD API code, and Protobuf code for custom APIs (only lacking business logic implementation).
  5. Business Logic Code Completion: Automatically generate business logic code using Sponge's built-in AI tools, and integrate and verify it by developers.
  6. Debugging and Validation: Start the service and debug and validate API interfaces using tools like Swagger.

This collaborative development based on Sponge and DeepSeek R1 can rapidly build a fully functional and logically clear backend service project, achieving the goal of "writing less code to accomplish most tasks," allowing individual developers to easily undertake team-level tasks. It is also redefining the efficiency boundaries of software development:

  1. Transformation of Development Roles: Engineers focus more on architecture design and quality control.
  2. Increased Agility: Prototype development cycles are shortened from weeks to days.
  3. Knowledge Accumulation: AI-generated standardized code is easier to maintain and iterate.

Top comments (0)