{"openapi":"3.0.0","info":{"title":"Blockchain OMS API","version":"2.0.0","description":"REST API for the Blockchain Order Management System. Use the production URL (block-chain-oms.vercel.app) in Swagger — preview deployment URLs require Vercel login and may fail with \"Failed to fetch\"."},"servers":[{"url":"https://block-chain-oms.vercel.app","description":"Current server"}],"tags":[{"name":"Health","description":"Server health"},{"name":"Authentication","description":"Registration, login, profile"},{"name":"Products","description":"Product catalog"},{"name":"Orders","description":"Orders and blockchain verification"},{"name":"Users","description":"Admin user management"},{"name":"Stats","description":"Dashboard analytics"},{"name":"Audit","description":"Order audit trail"},{"name":"Categories","description":"Product categories"},{"name":"Notifications","description":"User notifications"},{"name":"Inventory","description":"Stock movements and adjustments"},{"name":"Addresses","description":"Shipping addresses"},{"name":"Reviews","description":"Product reviews"},{"name":"Supplier","description":"Supplier portal"}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"User":{"type":"object","properties":{"id":{"type":"integer","example":1},"name":{"type":"string","example":"John Doe"},"email":{"type":"string","format":"email","example":"john@example.com"},"password":{"type":"string","format":"password","writeOnly":true},"role":{"type":"string","enum":["customer","supplier","admin"],"example":"customer"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"UserPublic":{"type":"object","properties":{"id":{"type":"integer","example":1},"name":{"type":"string","example":"John Doe"},"email":{"type":"string","format":"email","example":"john@example.com"},"role":{"type":"string","enum":["customer","supplier","admin"],"example":"customer"}}},"RegisterRequest":{"type":"object","required":["name","email","password"],"properties":{"name":{"type":"string","example":"John Doe"},"email":{"type":"string","format":"email","example":"john@example.com"},"password":{"type":"string","format":"password","example":"password123"},"role":{"type":"string","enum":["customer","supplier"],"default":"customer","example":"customer"}}},"UpdateProfileRequest":{"type":"object","properties":{"name":{"type":"string","example":"John Updated"},"email":{"type":"string","format":"email"},"password":{"type":"string","format":"password","minLength":8}}},"AdminCreateUserRequest":{"type":"object","required":["name","email","password","role"],"properties":{"name":{"type":"string"},"email":{"type":"string","format":"email"},"password":{"type":"string","format":"password","minLength":8},"role":{"type":"string","enum":["customer","supplier","admin"]}}},"AdminUpdateUserRequest":{"type":"object","properties":{"name":{"type":"string"},"email":{"type":"string","format":"email"},"password":{"type":"string","format":"password"},"role":{"type":"string","enum":["customer","supplier","admin"]}}},"LoginRequest":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string","format":"email","example":"john@example.com"},"password":{"type":"string","format":"password","example":"password123"}}},"LoginResponse":{"type":"object","properties":{"token":{"type":"string","description":"JWT bearer token (expires in 1 day)"},"role":{"type":"string","enum":["customer","supplier","admin"],"example":"customer"},"user":{"$ref":"#/components/schemas/UserPublic"}}},"RegisterResponse":{"type":"object","properties":{"message":{"type":"string","example":"User registered"},"user":{"$ref":"#/components/schemas/UserPublic"}}},"Product":{"type":"object","properties":{"id":{"type":"integer","example":1},"name":{"type":"string","example":"Laptop"},"description":{"type":"string","nullable":true,"example":"High-performance laptop"},"price":{"type":"number","format":"float","example":999.99},"stock_quantity":{"type":"integer","example":50},"createdBy":{"type":"integer","example":2}}},"CreateProductRequest":{"type":"object","required":["name","price"],"properties":{"name":{"type":"string","example":"Laptop"},"description":{"type":"string","example":"High-performance laptop"},"price":{"type":"number","format":"float","example":999.99},"stock_quantity":{"type":"integer","default":0,"example":50}}},"UpdateProductRequest":{"type":"object","properties":{"name":{"type":"string","example":"Laptop Pro"},"description":{"type":"string","example":"Updated high-performance laptop"},"price":{"type":"number","format":"float","example":1099.99},"stock_quantity":{"type":"integer","example":45}}},"Order":{"type":"object","properties":{"id":{"type":"integer","example":1},"item":{"type":"string","description":"Product name (must match an existing product)","example":"Laptop"},"quantity":{"type":"integer","example":2},"userId":{"type":"integer","example":1},"status":{"type":"string","enum":["pending","confirmed","shipped","delivered","cancelled"],"example":"pending"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"user":{"$ref":"#/components/schemas/User"}}},"CreateOrderRequest":{"type":"object","required":["item","quantity"],"properties":{"item":{"type":"string","description":"Product name (must exist in catalog)","example":"Laptop"},"quantity":{"type":"integer","minimum":1,"example":2},"userId":{"type":"integer","description":"Admin only — assign order to another user","example":1}}},"UpdateOrderRequest":{"type":"object","properties":{"item":{"type":"string","example":"Laptop"},"quantity":{"type":"integer","example":3},"userId":{"type":"integer","example":1},"status":{"type":"string","enum":["pending","confirmed","shipped","delivered","cancelled"],"description":"Status transitions: pending → confirmed/cancelled, confirmed → shipped/cancelled, shipped → delivered. Customers cannot change status.\n","example":"confirmed"}}},"OrderVerifyResponse":{"type":"object","properties":{"orderId":{"type":"integer","example":1},"dbHash":{"type":"string","example":"0xabc123..."},"blockchainHash":{"type":"string","example":"0xabc123..."},"verified":{"type":"boolean","example":true}}},"MessageResponse":{"type":"object","properties":{"message":{"type":"string","example":"Deleted"}}},"ErrorResponse":{"type":"object","properties":{"message":{"type":"string","example":"Error message"},"error":{"type":"string","example":"Detailed error description"}}},"HealthResponse":{"type":"object","properties":{"status":{"type":"string","example":"ok"},"database":{"type":"string","enum":["connected","disconnected"],"example":"connected"}}},"DashboardStats":{"type":"object","properties":{"users":{"type":"integer"},"products":{"type":"integer"},"orders":{"type":"integer"},"ordersByStatus":{"type":"object","additionalProperties":{"type":"integer"}},"estimatedRevenue":{"type":"number"},"lowStockProducts":{"type":"integer"},"blockchainDemoMode":{"type":"boolean"},"recentOrders":{"type":"array","items":{"$ref":"#/components/schemas/Order"}}}},"AuditLog":{"type":"object","properties":{"id":{"type":"integer"},"order_id":{"type":"integer"},"action":{"type":"string"},"performed_by":{"type":"integer"},"old_hash":{"type":"string","nullable":true},"new_hash":{"type":"string"},"blockchain_tx_id":{"type":"string","nullable":true},"timestamp":{"type":"string","format":"date-time"}}}},"parameters":{"IdParam":{"in":"path","name":"id","required":true,"schema":{"type":"integer"}}},"responses":{"Unauthorized":{"description":"Missing or invalid JWT token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"message":"No token provided"}}}},"Forbidden":{"description":"Insufficient permissions for this action","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"message":"Forbidden"}}}},"NotFound":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"InternalError":{"description":"Server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/api/ping":{"get":{"summary":"Ping check","description":"Simple connectivity check that returns plain text \"pong\"","tags":["Health"],"security":[],"responses":{"200":{"description":"Server is reachable","content":{"text/plain":{"schema":{"type":"string","example":"pong"}}}}}}},"/health":{"get":{"summary":"Health check","description":"Returns server health status","tags":["Health"],"security":[],"responses":{"200":{"description":"Server and database are healthy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"}}}},"503":{"description":"Database unreachable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"}}}}}}},"/api/categories":{"get":{"summary":"List categories","tags":["Categories"],"security":[],"responses":{"200":{"description":"Categories with product counts"}}},"post":{"summary":"Create category","tags":["Categories"],"security":[{"bearerAuth":[]}],"responses":{"201":{"description":"Created"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/categories/{id}":{"get":{"summary":"Get category","tags":["Categories"],"security":[],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Category"}}},"put":{"summary":"Update category","tags":["Categories"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Updated"}}},"delete":{"summary":"Delete category","tags":["Categories"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Deleted"}}}},"/api/categories/{id}/products":{"get":{"summary":"Products in category","tags":["Categories"],"security":[],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Products"}}}},"/api/notifications":{"get":{"summary":"List notifications","tags":["Notifications"],"security":[{"bearerAuth":[]}],"parameters":[{"in":"query","name":"unread","schema":{"type":"boolean"}},{"in":"query","name":"limit","schema":{"type":"integer"}}],"responses":{"200":{"description":"Notifications"}}}},"/api/notifications/unread-count":{"get":{"summary":"Unread notification count","tags":["Notifications"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Count"}}}},"/api/notifications/read-all":{"patch":{"summary":"Mark all as read","tags":["Notifications"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Updated"}}}},"/api/notifications/{id}/read":{"patch":{"summary":"Mark notification as read","tags":["Notifications"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Updated"}}}},"/api/inventory/summary":{"get":{"summary":"Inventory summary","tags":["Inventory"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Stock summary"}}}},"/api/inventory/movements":{"get":{"summary":"Stock movement history","tags":["Inventory"],"security":[{"bearerAuth":[]}],"parameters":[{"in":"query","name":"productId","schema":{"type":"integer"}}],"responses":{"200":{"description":"Movements"}}}},"/api/inventory/adjust":{"post":{"summary":"Manually adjust stock","tags":["Inventory"],"security":[{"bearerAuth":[]}],"responses":{"201":{"description":"Adjusted"}}}},"/api/addresses":{"get":{"summary":"List shipping addresses","tags":["Addresses"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Addresses"}}},"post":{"summary":"Add address","tags":["Addresses"],"security":[{"bearerAuth":[]}],"responses":{"201":{"description":"Created"}}}},"/api/addresses/{id}":{"get":{"summary":"Get address","tags":["Addresses"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Address"}}},"put":{"summary":"Update address","tags":["Addresses"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Updated"}}},"delete":{"summary":"Delete address","tags":["Addresses"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Deleted"}}}},"/api/addresses/{id}/default":{"patch":{"summary":"Set default address","tags":["Addresses"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Updated"}}}},"/api/reviews/product/{productId}":{"get":{"summary":"Product reviews and rating stats","tags":["Reviews"],"security":[],"parameters":[{"in":"path","name":"productId","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Reviews"}}}},"/api/reviews":{"post":{"summary":"Create review (delivered orders only)","tags":["Reviews"],"security":[{"bearerAuth":[]}],"responses":{"201":{"description":"Created"}}}},"/api/reviews/{id}":{"delete":{"summary":"Delete review","tags":["Reviews"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Deleted"}}}},"/api/supplier/dashboard":{"get":{"summary":"Supplier dashboard","tags":["Supplier"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Metrics"}}}},"/api/supplier/products":{"get":{"summary":"Supplier's products","tags":["Supplier"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Products"}}}},"/api/supplier/orders":{"get":{"summary":"Orders for supplier products","tags":["Supplier"],"security":[{"bearerAuth":[]}],"parameters":[{"in":"query","name":"status","schema":{"type":"string"}}],"responses":{"200":{"description":"Orders"}}}},"/api/supplier/products/{id}/sales":{"get":{"summary":"Sales stats for a product","tags":["Supplier"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Sales data"}}}},"/api/orders/{id}/cancel":{"post":{"summary":"Cancel an order","description":"Restores stock and notifies customer.","tags":["Orders"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Cancelled"}}}},"/api/auth/register":{"post":{"summary":"Register a new user","description":"Only customer or supplier roles allowed. Admin accounts must be created by an existing admin.","tags":["Authentication"],"security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisterRequest"}}}},"responses":{"201":{"description":"User registered","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisterResponse"}}}},"400":{"description":"Validation failed"},"409":{"description":"Email already registered"},"429":{"description":"Rate limited"}}}},"/api/auth/login":{"post":{"summary":"Login and receive JWT","tags":["Authentication"],"security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginRequest"}}}},"responses":{"200":{"description":"Login successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginResponse"}}}},"401":{"description":"Invalid credentials"},"429":{"description":"Rate limited"}}}},"/api/auth/me":{"get":{"summary":"Get current user profile","tags":["Authentication"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Profile","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserPublic"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}},"put":{"summary":"Update current user profile","tags":["Authentication"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateProfileRequest"}}}},"responses":{"200":{"description":"Updated profile","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserPublic"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"409":{"description":"Email already in use"}}}},"/api/products":{"get":{"summary":"List all products","tags":["Products"],"security":[],"responses":{"200":{"description":"Product list","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Product"}}}}}}},"post":{"summary":"Create a product","description":"Requires admin or supplier role.","tags":["Products"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateProductRequest"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"description":"Product name already exists"}}}},"/api/products/search":{"get":{"summary":"Search products by name or description","tags":["Products"],"security":[],"parameters":[{"in":"query","name":"q","required":true,"schema":{"type":"string"},"example":"laptop"}],"responses":{"200":{"description":"Matching products","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Product"}}}}}}}},"/api/products/low-stock":{"get":{"summary":"List products with low stock","tags":["Products"],"security":[],"parameters":[{"in":"query","name":"threshold","schema":{"type":"integer","default":10}}],"responses":{"200":{"description":"Low stock products","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Product"}}}}}}}},"/api/products/{id}":{"get":{"summary":"Get product by ID","tags":["Products"],"security":[],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Product","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"404":{"$ref":"#/components/responses/NotFound"}}},"put":{"summary":"Update a product","description":"Supplier can only update own products; admin can update any.","tags":["Products"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateProductRequest"}}}},"responses":{"200":{"description":"Updated product","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}},"delete":{"summary":"Delete a product","tags":["Products"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/orders":{"get":{"summary":"List orders","description":"Customers see only their own orders. Admin and supplier see all.","tags":["Orders"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Order list","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Order"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}},"post":{"summary":"Create an order","description":"Decrements stock atomically and stores hash on blockchain. Customers always order for themselves.","tags":["Orders"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateOrderRequest"}}}},"responses":{"201":{"description":"Order created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"400":{"description":"Insufficient stock"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"description":"Product not found"}}}},"/api/orders/my":{"get":{"summary":"Get current user's orders","tags":["Orders"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Own orders","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Order"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/api/orders/{id}":{"get":{"summary":"Get order by ID","tags":["Orders"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Order details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}},"put":{"summary":"Update an order","description":"Admin can update all fields. Customer can update own order (not status). Supplier can update status only.\n","tags":["Orders"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateOrderRequest"}}}},"responses":{"200":{"description":"Updated order","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"400":{"description":"Invalid status transition"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}},"delete":{"summary":"Delete an order","description":"Admin only.","tags":["Orders"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/orders/{id}/verify":{"get":{"summary":"Verify order blockchain hash","tags":["Orders"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Verification result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderVerifyResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/users":{"get":{"summary":"List all users","description":"Admin only. Passwords are never returned.","tags":["Users"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"User list","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/UserPublic"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}},"post":{"summary":"Create a user (admin)","description":"Admin only. Can assign any role including admin.","tags":["Users"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminCreateUserRequest"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserPublic"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"description":"Email already registered"}}}},"/api/users/{id}":{"get":{"summary":"Get user by ID","description":"Admin or the user themselves.","tags":["Users"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"User","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserPublic"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}},"put":{"summary":"Update a user","description":"Admin can update any user including role. Users can update own profile (not role).","tags":["Users"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUpdateUserRequest"}}}},"responses":{"200":{"description":"Updated user","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserPublic"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}},"delete":{"summary":"Delete a user","description":"Admin only. Cannot delete own account.","tags":["Users"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/stats/dashboard":{"get":{"summary":"Dashboard statistics","description":"Admin only. Returns counts, revenue estimate, and recent orders.","tags":["Stats"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Dashboard stats","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DashboardStats"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/audit-logs":{"get":{"summary":"List audit logs","description":"Admin only.","tags":["Audit"],"security":[{"bearerAuth":[]}],"parameters":[{"in":"query","name":"orderId","schema":{"type":"integer"}},{"in":"query","name":"limit","schema":{"type":"integer","default":50,"maximum":100}}],"responses":{"200":{"description":"Audit log entries","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AuditLog"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/audit-logs/{id}":{"get":{"summary":"Get audit log by ID","tags":["Audit"],"security":[{"bearerAuth":[]}],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Audit log entry","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuditLog"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}}}}