Quick Start
Generate a complete REST API in 5 minutes.
Step 1: Create SQL Schema
Create a file schema.sql:
sql
CREATE TABLE users (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
email VARCHAR(255) NOT NULL UNIQUE,
username VARCHAR(100) NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE products (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(200) NOT NULL,
description TEXT,
price DECIMAL(10, 2) NOT NULL,
stock INTEGER DEFAULT 0,
user_id BIGINT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id)
);
CREATE TABLE orders (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
user_id BIGINT NOT NULL,
total DECIMAL(10, 2) NOT NULL,
status VARCHAR(50) DEFAULT 'PENDING',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id)
);
CREATE TABLE order_items (
order_id BIGINT,
product_id BIGINT,
quantity INTEGER NOT NULL,
price DECIMAL(10, 2) NOT NULL,
PRIMARY KEY (order_id, product_id),
FOREIGN KEY (order_id) REFERENCES orders(id),
FOREIGN KEY (product_id) REFERENCES products(id)
);Step 2: Generate the API
Using CLI
bash
./gradlew :generator:cli:run --args="generate \
--input schema.sql \
--language java-spring \
--package com.example.shop \
--output ./shop-api"Using REST API
bash
# Start the server
./gradlew :generator:server:bootRun
# Generate via API
curl -X POST http://localhost:8080/api/generate \
-H "Content-Type: application/json" \
-d '{
"schema": "CREATE TABLE users (...)",
"language": "java-spring",
"packageName": "com.example.shop"
}'Using MCP (AI-assisted)
Configure Claude Desktop with the MCP server and ask:
"Generate a REST API for an e-commerce system with users, products, and orders using Java Spring Boot"
Step 3: Explore Generated Code
shop-api/
├── src/main/java/com/example/shop/
│ ├── users/
│ │ ├── domain/entity/User.java
│ │ ├── application/
│ │ │ ├── dto/UserDTO.java
│ │ │ ├── mapper/UserMapper.java
│ │ │ └── service/UserService.java
│ │ └── infrastructure/
│ │ ├── repository/UserRepository.java
│ │ └── controller/UserController.java
│ ├── products/
│ │ └── ... (same structure)
│ └── orders/
│ └── ... (same structure)
├── src/main/resources/
│ ├── application.yml
│ └── db/migration/
│ └── V1__create_tables.sql
├── src/test/java/
│ └── ... (unit and integration tests)
├── build.gradle
└── docker-compose.ymlStep 4: Run the Generated API
bash
cd shop-api
# Start database
docker-compose up -d
# Run the API
./gradlew bootRunStep 5: Test the Endpoints
Create a User
bash
curl -X POST http://localhost:8080/api/users \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"username": "john",
"passwordHash": "hashed_password"
}'List Users with Filtering
bash
# All users
curl http://localhost:8080/api/users
# Filter by username
curl "http://localhost:8080/api/users?username[like]=john"
# Pagination
curl "http://localhost:8080/api/users?page=0&size=10&sort=createdAt,desc"Create a Product
bash
curl -X POST http://localhost:8080/api/products \
-H "Content-Type: application/json" \
-d '{
"name": "Laptop",
"description": "High-performance laptop",
"price": 999.99,
"stock": 50,
"userId": 1
}'Filter Products
bash
# Products under $500
curl "http://localhost:8080/api/products?price[lt]=500"
# Products in stock
curl "http://localhost:8080/api/products?stock[gt]=0"
# Combined filters
curl "http://localhost:8080/api/products?price[gte]=100&price[lte]=500&stock[gt]=0"Supported Filter Operators
| Operator | Description | Example |
|---|---|---|
eq | Equals | ?status[eq]=ACTIVE |
ne | Not equals | ?status[ne]=DELETED |
like | Contains | ?name[like]=phone |
gt | Greater than | ?price[gt]=100 |
gte | Greater or equal | ?price[gte]=100 |
lt | Less than | ?price[lt]=500 |
lte | Less or equal | ?price[lte]=500 |
in | In list | ?status[in]=ACTIVE,PENDING |
between | Range | ?price[between]=100,500 |
isNull | Is null | ?description[isNull]=true |
Next Steps
- CRUD Operations - Customize CRUD behavior
- Security - Add JWT authentication
- Multi-language - Generate for other languages