Skip to main content

Backend Service Generation

After completing the frontend page design, AI Builder can automatically generate corresponding cloud development backend services for your application, including data models and cloud functions. At this stage, you need to specify the required backend services for each page.

Overview

Backend service generation is a critical step in connecting frontend pages with cloud development backend capabilities. Based on your page feature requirements, AI Builder will automatically generate:

  • 📊 Data Model: Design the database table structure based on page data requirements.
  • Cloud Functions: Provide backend API interfaces for page features.
  • 🔗 Data Binding: Establish connections between frontend components and backend data.
  • 🛡️ Access Control: Configure data access permissions and security rules.

Service Configuration Process

1. Page Service Analysis

First, AI Builder will analyze your frontend pages to identify feature modules requiring backend services:

  • Data Display Components: Lists, tables, cards, and other components requiring a data source.
  • Form Components: Forms requiring data submission and processing.
  • Interactive Features: Search, filter, sort, and other features requiring backend logic.
  • User Operations: Login, registration, authentication, and other user-related features.

2. Service Requirements Input

For each identified feature module, you need to describe specific service requirements:

Data Model Requirements

Example: User Management Page
Required data fields:
- User ID (primary key)
- Username (string, unique)
- Email (string, unique)
- Creation Time (timestamp)
- User Status (enum: Active/Inactive)

Cloud Functions Requirements

Example: User List Page
Required interface features:
- Obtain user list (with pagination support)
- Search users (by username or email)
- Update user status
- Delete user

3. Automatic Generation Service

Based on your input, AI Builder will automatically generate:

Data Model

  • Database Table Structure: Create data tables based on field requirements.
  • Index Configuration: Automatically add indexes for query fields.
  • Relationships: Handle the relationships between tables.
  • Data Validation: Set field validation rules.

Cloud Function Code

  • CRUD Operations: Basic functions for creating, reading, updating, and deleting data.
  • Business Logic: Implement specific business logic based on feature requirements.
  • Data Processing: Data formatting, validation, conversion, and other processing logic.
  • Error Handling: Robust error handling and exception catching mechanisms.

3. Service Deployment

After creating the service, you need to deploy the service from this session to the cloud development environment.

  • Database Deployment: Deploy the data model to the database.
  • Cloud Function Deployment: Deploy the Cloud Function code to the cloud development environment.
  • Service Configuration: Configure trigger conditions, permission settings, and other configurations for Cloud Functions.

4. Application Access Service

After the service is released, you need to replace the mock data in the application with real services.

For example:

  • Data Model: Replace the XXX mock data model on the XXX page with a real database table structure.
  • Cloud Function: Replace the XXX mock function on the XXX page with real Cloud Function code.

Service Configuration Example

Example 1: Blog Post Management

Page Features: Article List, Article Details, Article Edit

Service Requirements Description:

Data Model:
- Article Table: ID, Title, Content, Author ID, Created At, Updated At, Status
- Category Table: ID, Category Name, Description
- Tag Table: ID, Tag Name

Cloud Function Requirements:
- Obtain article list (with pagination and category filtering support)
- Obtain article details
- Create/Update articles
- Delete article
- Obtain category list
- Obtain tag list

Example 2: E-commerce Product Management

Page Features: Product List, Product Details, Shopping Cart, Order Management

Service Requirements Description:

Data Model:
- Product Table: ID, Name, Price, Stock, Description, Image, Category ID
- Order Table: ID, UserID, Total Amount, Status, Creation Time
- Order Details Table: ID, OrderID, ProductID, Quantity, Unit Price

Cloud Function Requirements:
- Product list query (supporting search, category filtering, and price sorting)
- Obtain product details
- Shopping Cart Operations (Add, Delete, Update Quantity)
- Order Creation and Query
- Inventory Management

Key Points for Configuration

1. Data Model Design

  • Field Types: Specify the data type for each field (string, number, boolean, time, etc.)
  • Constraints: Set required, unique, length restrictions, etc.

2. Cloud Function Design

  • Parameter Validation: Strictly validate input parameters
  • Access Control: Control data access permissions based on user roles.

3. Security Considerations

  • Data Validation: Validate and filter all user inputs.
  • Access Control: Implement a fine-grained permissions control mechanism.
  • Data Encryption: Encrypt and store sensitive data.
  • Access Restrictions: Set reasonable access frequency limits.

Generated Results

After completing the service configuration, AI Builder will generate for you:

  1. Database Table Structure File: Containing complete table definitions and index configurations.
  2. Cloud Function Code: Deployable Cloud Function code files.
  3. API Documentation: Detailed interface documentation and usage instructions.
  4. Front-end Integration Code: Sample code for front-end to call back-end services.
  5. Deployment Configuration: Deployment configuration file for the cloud development environment.

Through this approach, you can quickly obtain a complete full-stack application, significantly improving development efficiency.