How AI Can Auto‑Generate a Complete Java E‑Commerce Order System from 0 to 1
This tutorial walks through using the Lingma AI assistant to automatically create, configure, and run a full Java Maven e‑commerce order project—including environment setup, SQLite persistence, CRUD services, unit tests, and architecture visualization—showing each prompt, command, and generated code snippet.
Demo Overview
The demonstration shows how the Lingma AI assistant can automatically generate a complete Java Maven project for an e‑commerce order system, from an empty directory to a runnable application with SQLite persistence, unit tests, and architectural diagrams.
Prerequisites & Installation
JetBrains IDE (2020.3+). Install via the official package.
Maven build tool. Download from https://maven.apache.org/download.cgi or install with brew install maven .
Lingma IDE. Install the latest version from the official download page.
SQLite3. Install with brew install sqlite3 .
Python 3.12+ and pip install uvx (or use pipenv/poetry for environment management).
Install the mcp-server-sqlite agent: uvx install mcp-server-sqlite .
Project Directory & Database Setup
Create a demo folder and an empty SQLite database file:
mkdir /Users/yuxiao/Downloads/0713demo cd /Users/yuxiao/Downloads/0713demo touch test.dbAdd the following JSON configuration to the Lingma plugin to start the mcp-server-sqlite service:
{
"mcp-server-sqlite": {
"autoApprove": [],
"disabled": false,
"timeout": 60,
"command": "mcp-server-sqlite",
"args": ["--db-path", "/Users/yuxiao/Downloads/0713demo/test.db"],
"transportType": "stdio"
}
}Replace the absolute path with your own location.
Step‑by‑Step Demo
1. Create a New Empty Project
In IntelliJ IDEA (or another JetBrains IDE) create a new empty project.
2. Open Lingma and Select Agent Mode
Activate Lingma, choose agent mode , and select the model qwen3‑thinking (or qwen3 as an alternative).
3. Generate a Maven Project
Prompt: “Generate a Maven project”. The AI creates a standard Maven directory layout, a pom.xml with JUnit 5 dependency, a simple App.java main class, and a basic test class.
4. Create Order Entity
Prompt: “Create an Order entity class with basic fields.” The AI generates an Order class containing:
orderId – unique identifier
userId – reference to user system
productId – reference to product system
quantity – purchase amount
totalAmount – BigDecimal to avoid precision loss
status – enum‑style order status
creationTime, paymentTime, updateTime – timestamp fields
5. Generate Constructors
Prompt: “Generate initialization constructors.” The AI provides a full‑argument constructor and a convenience constructor for core fields, automatically initializing status to 0 (pending) and setting the creation timestamp.
6. Add CRUD Business Logic
Prompt: “Provide CRUD functions.” The AI creates: OrderDAO.java – an in‑memory Map based DAO (later extended for SQLite). OrderService.java – methods createOrder, getOrder, updateOrder, deleteOrder with basic validation (quantity > 0, amount > 0) and exception handling.
7. Persist Data to SQLite
Prompt: “Create an SQLite table order0713 in test.db.” The AI adds a DBUtil class for JDBC connections, updates OrderDAO to create the table, and inserts/queries data using the SQLite driver added to pom.xml.
8. Compile and Run
Prompt: “Compile and run.” The AI invokes mvn clean package, detects compilation errors, and automatically patches the code (e.g., missing imports, type mismatches). After several repair cycles the application runs successfully.
9. Generate Unit Tests According to Corporate Rules
Using the Lingma advanced settings, a project_rule.md file is added to define the test style. The AI then generates a test class for OrderService.createOrder, covering normal and exceptional branches (valid order, duplicate order, quantity ≤ 0, amount ≤ 0).
10. Architecture Review & PlantUML Diagram
The AI summarizes the project structure (standard Maven layout, core classes App, DatabaseConnection, Order, OrderDao, OrderService, and test class) and lists the technology stack (Java, Maven, SQLite via JDBC, JUnit 5). It then produces a simple PlantUML diagram illustrating the layered architecture.
Key Takeaways
The demonstration reveals that, with appropriate prompts, the Lingma AI agent can scaffold an entire backend Java application, handle dependency management, generate database integration code, produce unit tests, and even create visual architecture diagrams. However, multiple repair iterations may be required, highlighting the importance of refined prompts and occasional manual adjustments.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Alibaba Cloud Native
We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
