Skip to Content
Dev DocsYour First Project ★★★

Your First Project

This guide walks you through a practical scenario within a Homestay Management System—“Room Booking & Points Redemption.” It is designed to help you quickly master the core workflows of Toco AI and understand the philosophy of Model-Driven Development in the AI Era.

Business Context: Members add room types and quantities to a cart and place a single order. The system must verify room availability. Upon confirmation, it processes payment, generates a successful booking order, deducts points, and records consumption details.


Prerequisites


Create a New Toco Project

Toco’s unique Model-Driven Development (MDD) capabilities are exclusive to Toco Projects. Currently, the Java Spring ecosystem is supported, with more languages coming soon.

Note: In standard projects, Toco functions as a traditional AI Coding Assistant.

Input Requirements

Enter your requirements or upload your requirements document as an attachment in the Agent Chat window.

Domain Modeling

The Domain Architect will automatically generate the Domain Model (including ER Diagrams, Value Objects, Aggregates, etc.) based on your requirements.

  • Core Example: An aggregate object containing “Order Information” (comprising the main order table booking_order, order item table order_item, etc.).
  • Flexible Modification: You can request modifications via Chat or manually adjust the model directly within the visual editor.

Tip: View Design Models Anytime

Click the Toco Icon in the chat dialog to access and edit the Domain Models, Service Models, and more for all modules at any time.

Requirement Breakdown

The Toco Agent breaks down the requirements into multiple APIs.

  • You can choose to implement these APIs in a batch within the current session or add them to the To-Do List for later processing. APIs in the To-Do List support manual editing.

Tip: Manage To-Dos

Click the Issue Icon in the chat dialog to view all pending tasks at any time. Completed tasks need to be marked manually.

Start an Independent Session for API Implementation

Initiate an Independent Session from the To-Do List for the “Create Order from Cart” interface.

Note: While you can resolve multiple APIs in a single session, it is not recommended to include too many complex interfaces in one session. Keeping the context focused ensures better generation results.

Design Planning

  • The Planner Agent outlines preliminary details, including API input/output parameters, workflows, and initial read/write path designs.
  • Once confirmed, the Designer Agent completes the relevant service modeling based on the plan:
    • Read Model:
      • Toco-DTO (Data Transfer Object): A data structure formed by aggregating multiple tables using foreign keys. Example: Assembling the list of order items within the “Room Type Detail DTO” (extended via the foreign key room_type_id).
        Toco-DTO
      • Read Plan: Uses the DTO as the return value. Adopts an object-oriented query approach supporting efficient cross-table retrieval. Example:
        • Filter room types by ID, code, total quantity, etc.: id in #roomTypeIdList AND room_type_code in #roomTypeCodeIn AND total_quantity >= #totalQuantityBiggerThanEqual
        • Synchronously fetch valid order details for the room type within a specific date range: filter orderItemList: order_item_status in #orderItemListOrderItemStatusIn AND order.check_in_date >= checkInDateBiggerThanEqual AND order.check_out_date <= checkOutDateLessThanEqual
      • The Read Plan efficiently defines the Read Model: It simultaneously confirms the return value, query method, data assembly method, input parameters, and corresponding Service/API.
        Read Plan
    • Write Model: Defines business changes and transaction logic centered around aggregate objects. Example: In the “Place Order” workflow, execute operations like creating the order and its details (Write Plan 1), deducting points, and recording consumption details (Write Plan 2).
      • [Write Plan 1] Create Order and Details: Describes creating records for two tables (booking_order, order_item) simultaneously.
        Write Plan 1: Create Order with Items
        Write Plan 1: Write Plan Parameters
      • [Write Plan 2] Deduct Points and Record Consumption: Describes updating the member points while creating the corresponding points_transaction record.
        Write Plan 2: Deduct Points and Create Transaction
    • The Write Plan efficiently defines the Write Service Model: It simultaneously confirms input parameters, corresponding Service/API, target business objects, and modification methods.

Code Generation: The 80/20 Rule

Toco features a built-in M2C (Model To Code) Engine, dividing code into two parts:

  • Structural Code (~80%): Generated directly by the engine based on the modeling information above. It adheres to DDD and CQRS standards, ensuring architectural standardization and 100% accuracy. No manual review required.
  • Business Logic Code (~20%): The remaining business logic is written by the Developer Agent. You only need to review this “glue code” (e.g., verifying if the requested room quantity is available, checking for sufficient points, applying birthday logic, etc.).
M2C Structural Code vs AI Generated Glue Code

Run and Test

  • Database Synchronization: Automatically or manually perform Schema Synchronization and management.
  • Mock Testing: Verify API logic directly using Toco’s built-in tools.
Last updated on
Your First Project | Documentation | Toco AI