{
    "openapi": "3.1.0",
    "info": {
        "title": "BuyFlex BD Public API",
        "version": "1.0.0",
        "description": "Public product and storefront endpoints for BuyFlex BD — Bangladesh's premium footwear store. Includes product catalog, sitemap, order creation, and informational endpoints.",
        "contact": {
            "email": "support@buyflexbd.com",
            "url": "https://buyflexbd.com"
        },
        "license": {
            "name": "Proprietary"
        },
        "termsOfService": "https://buyflexbd.com/policies.html#terms"
    },
    "servers": [
        {
            "url": "https://buyflexbd.com",
            "description": "Production"
        }
    ],
    "tags": [
        {
            "name": "Catalog",
            "description": "Public product catalog endpoints"
        },
        {
            "name": "SEO",
            "description": "Search engine discovery endpoints"
        },
        {
            "name": "Orders",
            "description": "Order creation and management"
        },
        {
            "name": "Info",
            "description": "Public informational pages"
        },
        {
            "name": "AI",
            "description": "AI discovery and policy endpoints"
        }
    ],
    "paths": {
        "/api/products": {
            "get": {
                "summary": "List active products",
                "operationId": "listProducts",
                "tags": [
                    "Catalog"
                ],
                "description": "Returns all active products from the BuyFlex BD catalog with pricing in BDT.",
                "parameters": [
                    {
                        "name": "category",
                        "in": "query",
                        "required": false,
                        "description": "Filter by category",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "men",
                                "women",
                                "kids",
                                "unisex"
                            ]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Array of products",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "$ref": "#/components/schemas/Product"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/sitemap.xml": {
            "get": {
                "summary": "XML sitemap",
                "operationId": "getSitemap",
                "tags": [
                    "SEO"
                ],
                "description": "Returns the XML sitemap listing all public BuyFlex BD pages.",
                "responses": {
                    "200": {
                        "description": "Sitemap XML"
                    }
                }
            }
        },
        "/api/orders": {
            "post": {
                "summary": "Create a new order",
                "operationId": "createOrder",
                "tags": [
                    "Orders"
                ],
                "description": "Creates a new BuyFlex BD order. Requires authenticated session cookie.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/OrderRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Order created"
                    },
                    "400": {
                        "description": "Invalid request"
                    },
                    "401": {
                        "description": "Authentication required"
                    }
                }
            }
        },
        "/robots.txt": {
            "get": {
                "summary": "Robots.txt directives",
                "operationId": "getRobots",
                "tags": [
                    "SEO",
                    "AI"
                ],
                "description": "Returns crawler directives for search engines and AI agents.",
                "responses": {
                    "200": {
                        "description": "Robots.txt content"
                    }
                }
            }
        },
        "/llms.txt": {
            "get": {
                "summary": "LLM index",
                "operationId": "getLlmsIndex",
                "tags": [
                    "AI"
                ],
                "description": "Returns the BuyFlex BD llms.txt index — a curated list of important pages and deep links.",
                "responses": {
                    "200": {
                        "description": "Llms.txt markdown"
                    }
                }
            }
        },
        "/auth.md": {
            "get": {
                "summary": "Auth documentation",
                "operationId": "getAuthDoc",
                "tags": [
                    "AI"
                ],
                "description": "Returns the auth.md document describing public endpoints and agent usage policy.",
                "responses": {
                    "200": {
                        "description": "Auth markdown"
                    }
                }
            }
        },
        "/.well-known/ai-catalog.json": {
            "get": {
                "summary": "AI agent catalog",
                "operationId": "getAiCatalog",
                "tags": [
                    "AI"
                ],
                "description": "Returns the machine-readable AI agent catalog for BuyFlex BD.",
                "responses": {
                    "200": {
                        "description": "AI catalog JSON",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/AiCatalog"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/.well-known/ai.txt": {
            "get": {
                "summary": "AI content policy",
                "operationId": "getAiPolicy",
                "tags": [
                    "AI"
                ],
                "description": "Returns the AI content policy for BuyFlex BD.",
                "responses": {
                    "200": {
                        "description": "AI policy text"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "Product": {
                "type": "object",
                "required": [
                    "code",
                    "name",
                    "price"
                ],
                "properties": {
                    "code": {
                        "type": "string",
                        "example": "P001"
                    },
                    "name": {
                        "type": "string",
                        "example": "Heritage Trainer — Black"
                    },
                    "price": {
                        "type": "number",
                        "example": 6490
                    },
                    "currency": {
                        "type": "string",
                        "example": "BDT"
                    },
                    "category": {
                        "type": "string",
                        "enum": [
                            "men",
                            "women",
                            "kids",
                            "unisex"
                        ]
                    },
                    "image": {
                        "type": "string",
                        "format": "uri"
                    },
                    "description": {
                        "type": "string",
                        "example": "Lightweight BuyFlex sneaker built for peak performance."
                    },
                    "availability": {
                        "type": "string",
                        "enum": [
                            "InStock",
                            "OutOfStock",
                            "PreOrder"
                        ],
                        "example": "InStock"
                    },
                    "sku": {
                        "type": "string",
                        "example": "BF-P001-BLK"
                    }
                }
            },
            "OrderRequest": {
                "type": "object",
                "required": [
                    "items",
                    "customer"
                ],
                "properties": {
                    "items": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "required": [
                                "code",
                                "qty"
                            ],
                            "properties": {
                                "code": {
                                    "type": "string",
                                    "example": "P001"
                                },
                                "qty": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "example": 1
                                }
                            }
                        }
                    },
                    "customer": {
                        "type": "object",
                        "required": [
                            "name",
                            "phone",
                            "address"
                        ],
                        "properties": {
                            "name": {
                                "type": "string",
                                "example": "Arif Hossain"
                            },
                            "phone": {
                                "type": "string",
                                "example": "01897204672"
                            },
                            "address": {
                                "type": "string",
                                "example": "House 12, Road 5, Dhanmondi, Dhaka 1205"
                            },
                            "email": {
                                "type": "string",
                                "format": "email",
                                "example": "arif@example.com"
                            }
                        }
                    },
                    "payment": {
                        "type": "object",
                        "properties": {
                            "method": {
                                "type": "string",
                                "enum": [
                                    "bkash",
                                    "nagad",
                                    "rocket",
                                    "upay"
                                ]
                            },
                            "transactionId": {
                                "type": "string",
                                "example": "8N7A2B4C9D"
                            }
                        }
                    }
                }
            },
            "AiCatalog": {
                "type": "object",
                "properties": {
                    "specVersion": {
                        "type": "string",
                        "example": "1.0"
                    },
                    "host": {
                        "type": "object",
                        "properties": {
                            "displayName": {
                                "type": "string"
                            },
                            "identifier": {
                                "type": "string"
                            },
                            "documentationUrl": {
                                "type": "string",
                                "format": "uri"
                            },
                            "logoUrl": {
                                "type": "string",
                                "format": "uri"
                            }
                        }
                    },
                    "entries": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    }
                }
            }
        }
    }
}