Workflow Recipes

Ready-to-use Aexol patterns for common development scenarios. Copy and adapt these recipes to jumpstart your projects.

🎯 What are Workflow Recipes?

Workflow recipes are proven Aexol patterns for:

  • State machines and business workflows
  • CRUD operations and data flows
  • Authentication and authorization
  • Multi-step processes
  • Real-world application patterns

📝 Todo App Workflow

A simple task management workflow with three states.

type Task {
  id: string
  title: string
  description: string
  status: TaskStatus
  assigneeId: string
}

enum TaskStatus {
  todo
  in_progress
  done
}

workflow TaskFlow {
  initial: todo
  todo -> in_progress
  in_progress -> done
  in_progress -> todo when reverted
}

visitor TaskManager {
  "create tasks"
  "view tasks"
  "edit tasks"
  "delete tasks"
  "assign tasks"
}

visitor TeamMember {
  "view tasks"
  "update own tasks"
}

visitor TeamMember {
  "view tasks"
  "update own tasks"
}
✨ Edit in Studio

Use case: Project management, issue tracking, task boards


🛒 E-commerce Order Flow

Complete order processing workflow with payments and fulfillment.

type Order {
  id: string
  customerId: string
  items: OrderItem[]
  total: number
  status: OrderStatus
}

type OrderItem {
  productId: string
  quantity: number
  price: number
}

enum OrderStatus {
  pending
  payment_received
  processing
  shipped
  delivered
  cancelled
}

workflow OrderProcessing {
  initial: pending
  pending -> payment_received when payment_confirmed
  payment_received -> processing
  processing -> shipped when items_packed
  shipped -> delivered when customer_confirms
  pending -> cancelled when timeout
  payment_received -> cancelled when refund_requested
}

visitor Customer {
  "create orders"
  "view own orders"
  "cancel own pending orders"
}

visitor Merchant {
  "view all orders"
  "process orders"
  "update order status"
  "handle refunds"
}

agent OrderProcessor {
  "validate order"
  "process payment"
  "notify customer"
  "update inventory"
}

visitor Merchant {
  "view all orders"
  "process orders"
  "update order status"
  "handle refunds"
}

agent OrderProcessor {
  "validate order"
  "process payment"
  "notify customer"
  "update inventory"
}
✨ Edit in Studio

Use case: Online stores, marketplaces, subscription services


📄 Document Approval Workflow

Multi-stage document review and approval process.

type Document {
  id: string
  title: string
  content: string
  authorId: string
  status: DocumentStatus
  reviewers: string[]
}

enum DocumentStatus {
  draft
  pending_review
  approved
  rejected
  published
}

workflow DocumentApproval {
  initial: draft
  draft -> pending_review when submitted
  pending_review -> approved when all_reviewers_approve
  pending_review -> rejected when reviewer_rejects
  rejected -> draft when author_revises
  approved -> published when author_publishes
}

visitor Author {
  "create documents"
  "edit own draft documents"
  "submit for review"
  "revise rejected documents"
}

visitor Reviewer {
  "view pending documents"
  "approve documents"
  "reject documents"
  "add comments"
}

visitor Publisher {
  "view approved documents"
  "publish documents"
  "unpublish documents"
}

visitor Reviewer {
  "view pending documents"
  "approve documents"
  "reject documents"
  "add comments"
}

visitor Publisher {
  "view approved documents"
  "publish documents"
  "unpublish documents"
}

visitor Reviewer {
  "view pending documents"
  "approve documents"
  "reject documents"
  "add comments"
}

visitor Publisher {
  "view approved documents"
  "publish documents"
  "unpublish documents"
}
✨ Edit in Studio

Use case: Content management, legal docs, approval flows


🎫 Support Ticket System

Customer support ticket lifecycle with SLA tracking.

type Ticket {
  id: string
  customerId: string
  subject: string
  description: string
  priority: Priority
  status: TicketStatus
  assignedTo: string
}

enum Priority {
  low
  medium
  high
  urgent
}

enum TicketStatus {
  open
  assigned
  in_progress
  waiting_customer
  resolved
  closed
}

workflow TicketLifecycle {
  initial: open
  open -> assigned when agent_assigned
  assigned -> in_progress when agent_starts
  in_progress -> waiting_customer when info_needed
  waiting_customer -> in_progress when customer_responds
  in_progress -> resolved when issue_fixed
  resolved -> closed when customer_confirms
  resolved -> in_progress when customer_reopens
}

visitor Customer {
  "create tickets"
  "view own tickets"
  "respond to tickets"
  "close own tickets"
}

visitor Agent {
  "view all tickets"
  "assign tickets"
  "update ticket status"
  "respond to tickets"
  "resolve tickets"
}

visitor Manager {
  "view all tickets"
  "reassign tickets"
  "view reports"
  "manage agents"
}

agent TicketRouter {
  "classify ticket"
  "assign based on priority"
  "escalate urgent tickets"
  "send notifications"
}

visitor Agent {
  "view all tickets"
  "assign tickets"
  "update ticket status"
  "respond to tickets"
  "resolve tickets"
}

visitor Manager {
  "view all tickets"
  "reassign tickets"
  "view reports"
  "manage agents"
}

agent TicketRouter {
  "classify ticket"
  "assign based on priority"
  "escalate urgent tickets"
  "send notifications"
}

visitor Agent {
  "view all tickets"
  "assign tickets"
  "update ticket status"
  "respond to tickets"
  "resolve tickets"
}

visitor Manager {
  "view all tickets"
  "reassign tickets"
  "view reports"
  "manage agents"
}

agent TicketRouter {
  "classify ticket"
  "assign based on priority"
  "escalate urgent tickets"
  "send notifications"
}
✨ Edit in Studio

Use case: Help desk, customer support, IT ticketing


👤 User Onboarding Flow

Multi-step user registration and verification process.

type User {
  id: string
  email: string
  name: string
  status: UserStatus
  emailVerified: boolean
  profileCompleted: boolean
}

enum UserStatus {
  pending
  email_sent
  email_verified
  profile_setup
  active
  suspended
}

workflow UserOnboarding {
  initial: pending
  pending -> email_sent when registration_submitted
  email_sent -> email_verified when email_confirmed
  email_verified -> profile_setup when user_continues
  profile_setup -> active when profile_completed
  active -> suspended when violation_detected
  suspended -> active when appeal_approved
}

visitor NewUser {
  "register"
  "verify email"
  "complete profile"
}

visitor User {
  "view own profile"
  "update own profile"
  "deactivate own account"
}

visitor Admin {
  "view all users"
  "suspend users"
  "activate users"
  "delete users"
}

agent OnboardingBot {
  "send welcome email"
  "send verification email"
  "send reminder emails"
  "track completion"
}

visitor User {
  "view own profile"
  "update own profile"
  "deactivate own account"
}

visitor Admin {
  "view all users"
  "suspend users"
  "activate users"
  "delete users"
}

agent OnboardingBot {
  "send welcome email"
  "send verification email"
  "send reminder emails"
  "track completion"
}

visitor User {
  "view own profile"
  "update own profile"
  "deactivate own account"
}

visitor Admin {
  "view all users"
  "suspend users"
  "activate users"
  "delete users"
}

agent OnboardingBot {
  "send welcome email"
  "send verification email"
  "send reminder emails"
  "track completion"
}
✨ Edit in Studio

Use case: SaaS onboarding, user registration, KYC flows


💰 Payment Processing Workflow

Secure payment handling with refunds and disputes.

type Payment {
  id: string
  orderId: string
  amount: number
  currency: string
  status: PaymentStatus
  method: PaymentMethod
}

enum PaymentStatus {
  pending
  processing
  succeeded
  failed
  refunded
  disputed
}

enum PaymentMethod {
  credit_card
  debit_card
  paypal
  bank_transfer
}

workflow PaymentFlow {
  initial: pending
  pending -> processing when payment_submitted
  processing -> succeeded when payment_confirmed
  processing -> failed when payment_declined
  failed -> pending when retry_allowed
  succeeded -> refunded when refund_issued
  succeeded -> disputed when customer_disputes
}

visitor Merchant {
  "process payments"
  "issue refunds"
  "view transactions"
}

visitor Customer {
  "submit payments"
  "view own payments"
  "dispute payments"
}

agent PaymentProcessor {
  "validate payment details"
  "charge payment method"
  "handle webhooks"
  "send receipts"
}

visitor Customer {
  "submit payments"
  "view own payments"
  "dispute payments"
}

agent PaymentProcessor {
  "validate payment details"
  "charge payment method"
  "handle webhooks"
  "send receipts"
}

visitor Customer {
  "submit payments"
  "view own payments"
  "dispute payments"
}

agent PaymentProcessor {
  "validate payment details"
  "charge payment method"
  "handle webhooks"
  "send receipts"
}
✨ Edit in Studio

Use case: Payment gateways, billing systems, transaction processing


📦 Inventory Management

Product inventory tracking with stock alerts.

type Product {
  id: string
  name: string
  sku: string
  quantity: number
  status: StockStatus
  reorderLevel: number
}

enum StockStatus {
  in_stock
  low_stock
  out_of_stock
  discontinued
}

workflow InventoryManagement {
  initial: in_stock
  in_stock -> low_stock when quantity_below_threshold
  low_stock -> out_of_stock when quantity_zero
  out_of_stock -> in_stock when stock_replenished
  low_stock -> in_stock when stock_replenished
  in_stock -> discontinued when product_discontinued
}

visitor WarehouseManager {
  "add products"
  "update stock levels"
  "set reorder levels"
  "discontinue products"
}

visitor PurchasingAgent {
  "view low stock items"
  "create purchase orders"
  "receive inventory"
}

agent StockMonitor {
  "check stock levels"
  "send low stock alerts"
  "auto-create purchase orders"
  "notify suppliers"
}

visitor PurchasingAgent {
  "view low stock items"
  "create purchase orders"
  "receive inventory"
}

agent StockMonitor {
  "check stock levels"
  "send low stock alerts"
  "auto-create purchase orders"
  "notify suppliers"
}

visitor PurchasingAgent {
  "view low stock items"
  "create purchase orders"
  "receive inventory"
}

agent StockMonitor {
  "check stock levels"
  "send low stock alerts"
  "auto-create purchase orders"
  "notify suppliers"
}
✨ Edit in Studio

Use case: Warehouse management, retail inventory, supply chain


🏥 Appointment Booking System

Medical or service appointment scheduling workflow.

type Appointment {
  id: string
  patientId: string
  providerId: string
  datetime: string
  status: AppointmentStatus
  duration: number
}

enum AppointmentStatus {
  requested
  confirmed
  checked_in
  in_progress
  completed
  cancelled
  no_show
}

workflow AppointmentFlow {
  initial: requested
  requested -> confirmed when provider_accepts
  requested -> cancelled when patient_cancels
  confirmed -> checked_in when patient_arrives
  checked_in -> in_progress when appointment_starts
  in_progress -> completed when appointment_ends
  confirmed -> no_show when patient_absent
  confirmed -> cancelled when provider_cancels
}

visitor Patient {
  "request appointments"
  "view own appointments"
  "cancel own appointments"
  "check in"
}

visitor Provider {
  "view own schedule"
  "confirm appointments"
  "cancel appointments"
  "mark completed"
}

visitor Receptionist {
  "view all appointments"
  "check in patients"
  "reschedule appointments"
  "handle walk-ins"
}

agent AppointmentReminder {
  "send confirmation"
  "send reminder 24h before"
  "send reminder 1h before"
  "handle responses"
}

visitor Provider {
  "view own schedule"
  "confirm appointments"
  "cancel appointments"
  "mark completed"
}

visitor Receptionist {
  "view all appointments"
  "check in patients"
  "reschedule appointments"
  "handle walk-ins"
}

agent AppointmentReminder {
  "send confirmation"
  "send reminder 24h before"
  "send reminder 1h before"
  "handle responses"
}

visitor Provider {
  "view own schedule"
  "confirm appointments"
  "cancel appointments"
  "mark completed"
}

visitor Receptionist {
  "view all appointments"
  "check in patients"
  "reschedule appointments"
  "handle walk-ins"
}

agent AppointmentReminder {
  "send confirmation"
  "send reminder 24h before"
  "send reminder 1h before"
  "handle responses"
}
✨ Edit in Studio

Use case: Healthcare, consulting, service bookings


🎓 Course Enrollment Workflow

Online learning platform enrollment and progress tracking.

type Enrollment {
  id: string
  studentId: string
  courseId: string
  status: EnrollmentStatus
  progress: number
  grade: number
}

enum EnrollmentStatus {
  pending
  active
  in_progress
  completed
  dropped
  failed
}

workflow EnrollmentFlow {
  initial: pending
  pending -> active when payment_received
  active -> in_progress when student_starts
  in_progress -> completed when all_modules_finished
  in_progress -> failed when deadline_passed
  active -> dropped when student_withdraws
  pending -> dropped when payment_expired
}

visitor Student {
  "browse courses"
  "enroll in courses"
  "view own enrollments"
  "drop courses"
  "access course materials"
}

visitor Instructor {
  "view enrolled students"
  "grade assignments"
  "post announcements"
  "provide feedback"
}

visitor Admin {
  "manage courses"
  "manage enrollments"
  "process refunds"
  "generate reports"
}

agent ProgressTracker {
  "track completion"
  "calculate grades"
  "send progress updates"
  "award certificates"
}

visitor Instructor {
  "view enrolled students"
  "grade assignments"
  "post announcements"
  "provide feedback"
}

visitor Admin {
  "manage courses"
  "manage enrollments"
  "process refunds"
  "generate reports"
}

agent ProgressTracker {
  "track completion"
  "calculate grades"
  "send progress updates"
  "award certificates"
}

visitor Instructor {
  "view enrolled students"
  "grade assignments"
  "post announcements"
  "provide feedback"
}

visitor Admin {
  "manage courses"
  "manage enrollments"
  "process refunds"
  "generate reports"
}

agent ProgressTracker {
  "track completion"
  "calculate grades"
  "send progress updates"
  "award certificates"
}
✨ Edit in Studio

Use case: E-learning platforms, training programs, certifications


🔄 CI/CD Pipeline Workflow

Automated build, test, and deployment pipeline.

type Build {
  id: string
  commitHash: string
  branch: string
  status: BuildStatus
  startTime: string
  endTime: string
}

enum BuildStatus {
  queued
  building
  testing
  deploying
  succeeded
  failed
  cancelled
}

workflow CICDPipeline {
  initial: queued
  queued -> building when runner_available
  building -> testing when build_succeeds
  building -> failed when build_fails
  testing -> deploying when tests_pass
  testing -> failed when tests_fail
  deploying -> succeeded when deploy_succeeds
  deploying -> failed when deploy_fails
  queued -> cancelled when user_cancels
  building -> cancelled when user_cancels
}

visitor Developer {
  "trigger builds"
  "view build logs"
  "cancel builds"
}

visitor DevOps {
  "view all builds"
  "trigger deployments"
  "rollback deployments"
  "configure pipelines"
}

agent PipelineRunner {
  "checkout code"
  "run build commands"
  "execute tests"
  "deploy artifacts"
  "send notifications"
}

visitor DevOps {
  "view all builds"
  "trigger deployments"
  "rollback deployments"
  "configure pipelines"
}

agent PipelineRunner {
  "checkout code"
  "run build commands"
  "execute tests"
  "deploy artifacts"
  "send notifications"
}

visitor DevOps {
  "view all builds"
  "trigger deployments"
  "rollback deployments"
  "configure pipelines"
}

agent PipelineRunner {
  "checkout code"
  "run build commands"
  "execute tests"
  "deploy artifacts"
  "send notifications"
}
✨ Edit in Studio

Use case: DevOps automation, continuous delivery, deployment pipelines


🎯 Best Practices

1. Keep States Minimal

Use only necessary states. More states = more complexity.

# ❌ Too many states
enum Status { created, validated, processed, verified, approved, published, archived }

# ✅ Just enough states
enum Status { draft, approved, published }
✨ Edit in Studio

2. Name States Clearly

Use descriptive names that indicate the state of the entity.

# ❌ Unclear
enum Status { s1, s2, s3 }

# ✅ Clear
enum Status { pending, processing, completed }
✨ Edit in Studio

3. Model Conditions Explicitly

Make transition conditions explicit in your workflow.

workflow OrderFlow {
  pending -> processing when payment_confirmed
  processing -> shipped when items_ready
  processing -> cancelled when out_of_stock
}
✨ Edit in Studio

4. Separate Concerns

Use different visitors for different roles.

visitor Customer {
  "view orders"
  "create orders"
}

visitor Admin {
  "view all orders"
  "cancel orders"
  "issue refunds"
}

visitor Admin {
  "view all orders"
  "cancel orders"
  "issue refunds"
}

visitor Admin {
  "view all orders"
  "cancel orders"
  "issue refunds"
}
✨ Edit in Studio

5. Use Agents for Automation

Let agents handle automated tasks.

agent NotificationService {
  "send email"
  "send sms"
  "send push notification"
}
✨ Edit in Studio

Quick Start Tips

  1. Start with types - Define your data structures first
  2. Add workflows - Model state transitions
  3. Define visitors - Specify who can do what
  4. Add agents - Automate repetitive tasks
  5. Implement with AI - Use aexol implement to create implementation

📚 Next Steps


Need a custom recipe? Ask your AI assistant or check out more workflow recipes.