⚠️ Deprecated: AI commands are no longer part of@objectql/cli. This tutorial is preserved for historical reference only.
This tutorial will guide you through using ObjectQL's AI-powered features to generate and validate enterprise applications.
- Install ObjectQL CLI globally:
npm install -g @objectql/cli-
Get an OpenAI API key from OpenAI Platform
-
Set your API key as an environment variable:
export OPENAI_API_KEY=sk-your-api-key-hereUse the AI generator to create a task management system:
objectql ai generate \
-d "A task management system with projects and tasks. Projects should have a name, description, status (planning, active, completed), and owner. Tasks belong to projects and have a title, description, priority (low, medium, high), status (todo, in_progress, done), and assignee." \
-t complete \
-o ./my-task-appThe AI will generate several metadata files:
cd my-task-app
ls -la
# Expected output:
# project.object.yml
# task.object.yml
# project.validation.yml (optional)
# task.validation.yml (optional)Validate the generated files to ensure they follow ObjectQL standards:
objectql ai validate .The validator will check for:
- YAML syntax errors
- ObjectQL specification compliance
- Business logic consistency
- Data modeling best practices
- Potential security issues
Start a development server to test your application:
objectql serve --dir .Visit http://localhost:3000 to interact with your application through the API.
For more complex applications, provide detailed requirements:
objectql ai generate \
-d "A comprehensive CRM system with the following modules:
1. Account Management: Companies with name, industry, revenue, employee count, and status
2. Contact Management: People working at accounts with name, email, phone, position, and role
3. Lead Management: Potential customers with source, qualification status, and score
4. Opportunity Management: Sales opportunities with amount, stage, probability, close date
5. Activity Tracking: Meetings, calls, emails associated with accounts/contacts
Include proper relationships:
- Contacts belong to accounts
- Opportunities belong to accounts
- Activities link to accounts, contacts, or opportunities
- Include validation rules for data quality
- Add status transitions for leads and opportunities" \
-t complete \
-o ./crm-systemcd crm-system
ls -la
# Review generated files:
# - account.object.yml
# - contact.object.yml
# - lead.object.yml
# - opportunity.object.yml
# - activity.object.yml
# - Various .validation.yml filesEdit any file to customize fields, validation rules, or relationships.
objectql ai validate .Address any warnings or errors identified by the AI validator.
Generate TypeScript interfaces for type-safe development:
objectql generate -s . -o ./typesGet help with ObjectQL concepts:
objectql ai chatExample conversation:
You: How do I create a many-to-many relationship?