openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: StockFlow Pro API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: Auth description: Browser and mobile authentication endpoints. - name: dashboard description: Dashboard stats and activity - name: products description: Inventory products - name: orders description: Orders management - name: suppliers description: Suppliers management - name: adjustments description: Stock adjustments - name: reports description: Reports and analytics paths: /auth/user: get: tags: [Auth] operationId: getCurrentAuthUser summary: Get the currently authenticated user parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' responses: '200': description: Auth status resolved successfully. content: application/json: schema: $ref: '#/components/schemas/AuthUserEnvelope' /login: get: tags: [Auth] operationId: beginBrowserLogin summary: Start the browser OIDC login flow parameters: - name: returnTo in: query required: false schema: type: string responses: '302': description: Redirect to the OIDC authorization endpoint. /callback: get: tags: [Auth] operationId: handleBrowserLoginCallback summary: Complete the browser OIDC login flow parameters: - name: code in: query required: false schema: type: string - name: state in: query required: false schema: type: string responses: '302': description: Redirect to the returnTo path on success. /logout: get: tags: [Auth] operationId: logoutBrowserSession summary: Clear the session and begin OIDC logout parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' responses: '302': description: Redirect to the OIDC provider logout URL. /settings/users: get: tags: [Auth] operationId: listUsers summary: List all users (admin only) responses: '200': description: List of users content: application/json: schema: $ref: '#/components/schemas/UserList' /settings/users/{id}/role: patch: tags: [Auth] operationId: updateUserRole summary: Update a user role (admin only) parameters: - name: id in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UpdateUserRoleBody' responses: '200': description: Updated user content: application/json: schema: $ref: '#/components/schemas/AppUser' /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /dashboard/stats: get: operationId: getDashboardStats tags: [dashboard] summary: Get dashboard KPI stats responses: "200": description: Dashboard stats content: application/json: schema: $ref: "#/components/schemas/DashboardStats" /dashboard/inventory-movement: get: operationId: getInventoryMovement tags: [dashboard] summary: Get weekly inventory movement chart data responses: "200": description: Inventory movement content: application/json: schema: type: array items: $ref: "#/components/schemas/MovementDataPoint" /dashboard/recent-activity: get: operationId: getRecentActivity tags: [dashboard] summary: Get recent activity feed responses: "200": description: Recent activity content: application/json: schema: type: array items: $ref: "#/components/schemas/ActivityItem" /dashboard/low-stock: get: operationId: getLowStockAlerts tags: [dashboard] summary: Get low stock alerts responses: "200": description: Low stock items content: application/json: schema: type: array items: $ref: "#/components/schemas/LowStockAlert" /products: get: operationId: listProducts tags: [products] summary: List products with filters and pagination parameters: - name: search in: query schema: type: string - name: category in: query schema: type: string - name: warehouse in: query schema: type: string - name: status in: query schema: type: string - name: page in: query schema: type: integer - name: limit in: query schema: type: integer responses: "200": description: Product list content: application/json: schema: $ref: "#/components/schemas/ProductList" post: operationId: createProduct tags: [products] summary: Create a new product requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ProductInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Product" /products/{id}: get: operationId: getProduct tags: [products] summary: Get product by ID parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Product content: application/json: schema: $ref: "#/components/schemas/Product" "404": description: Not found patch: operationId: updateProduct tags: [products] summary: Update a product parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ProductUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/Product" "404": description: Not found delete: operationId: deleteProduct tags: [products] summary: Delete a product parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted "404": description: Not found /products/{id}/stock-history: get: operationId: getProductStockHistory tags: [products] summary: Get stock history for a product parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Stock history content: application/json: schema: type: array items: $ref: "#/components/schemas/StockHistoryEntry" /products/categories: get: operationId: getProductCategories tags: [products] summary: Get distinct product categories responses: "200": description: Categories list content: application/json: schema: type: array items: type: string /products/warehouses: get: operationId: getProductWarehouses tags: [products] summary: Get distinct warehouses responses: "200": description: Warehouses list content: application/json: schema: type: array items: type: string /orders: get: operationId: listOrders tags: [orders] summary: List orders with filters parameters: - name: search in: query schema: type: string - name: type in: query schema: type: string - name: status in: query schema: type: string - name: page in: query schema: type: integer - name: limit in: query schema: type: integer responses: "200": description: Order list content: application/json: schema: $ref: "#/components/schemas/OrderList" post: operationId: createOrder tags: [orders] summary: Create a new order requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/OrderInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Order" /orders/stats: get: operationId: getOrderStats tags: [orders] summary: Get order summary stats responses: "200": description: Order stats content: application/json: schema: $ref: "#/components/schemas/OrderStats" /orders/{id}: get: operationId: getOrder tags: [orders] summary: Get order by ID parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Order content: application/json: schema: $ref: "#/components/schemas/Order" "404": description: Not found patch: operationId: updateOrder tags: [orders] summary: Update order status parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/OrderUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/Order" /suppliers: get: operationId: listSuppliers tags: [suppliers] summary: List all suppliers responses: "200": description: Supplier list content: application/json: schema: type: array items: $ref: "#/components/schemas/Supplier" post: operationId: createSupplier tags: [suppliers] summary: Create a new supplier requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SupplierInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Supplier" /suppliers/{id}: get: operationId: getSupplier tags: [suppliers] summary: Get supplier by ID parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Supplier content: application/json: schema: $ref: "#/components/schemas/Supplier" "404": description: Not found patch: operationId: updateSupplier tags: [suppliers] summary: Update supplier parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SupplierUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/Supplier" /adjustments: get: operationId: listAdjustments tags: [adjustments] summary: List stock adjustments parameters: - name: productId in: query schema: type: integer responses: "200": description: Adjustments content: application/json: schema: type: array items: $ref: "#/components/schemas/Adjustment" post: operationId: createAdjustment tags: [adjustments] summary: Create a stock adjustment requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdjustmentInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Adjustment" /reports/supplier-performance: get: operationId: getSupplierPerformance tags: [reports] summary: Get supplier performance report responses: "200": description: Supplier performance data content: application/json: schema: $ref: "#/components/schemas/SupplierPerformanceReport" components: parameters: AuthorizationSessionHeader: name: Authorization in: header required: false description: Opaque session token — `Bearer `. schema: type: string SessionCookie: name: sid in: cookie required: false description: Browser session cookie. schema: type: string schemas: AuthUser: type: object required: [id, email, firstName, lastName, profileImageUrl, role] properties: id: type: string email: type: ["string", "null"] firstName: type: ["string", "null"] lastName: type: ["string", "null"] profileImageUrl: type: ["string", "null"] role: type: string AuthUserEnvelope: type: object required: [user] properties: user: oneOf: - $ref: '#/components/schemas/AuthUser' - type: 'null' AppUser: type: object required: [id, email, firstName, lastName, profileImageUrl, role, createdAt] properties: id: type: string email: type: ["string", "null"] firstName: type: ["string", "null"] lastName: type: ["string", "null"] profileImageUrl: type: ["string", "null"] role: type: string createdAt: type: string UserList: type: array items: $ref: '#/components/schemas/AppUser' UpdateUserRoleBody: type: object required: [role] properties: role: type: string description: "admin or user" HealthStatus: type: object required: [status] properties: status: type: string DashboardStats: type: object required: [totalItems, totalValue, lowStockCount, recentSales, totalItemsChange, recentSalesChange] properties: totalItems: type: integer totalValue: type: number lowStockCount: type: integer recentSales: type: integer totalItemsChange: type: number recentSalesChange: type: number MovementDataPoint: type: object required: [day, inbound, outbound] properties: day: type: string inbound: type: integer outbound: type: integer ActivityItem: type: object required: [id, type, description, sku, user, warehouse, createdAt] properties: id: type: integer type: type: string description: type: string sku: type: string user: type: string warehouse: type: string createdAt: type: string LowStockAlert: type: object required: [id, name, sku, currentStock, reorderPoint, status] properties: id: type: integer name: type: string sku: type: string currentStock: type: integer reorderPoint: type: integer status: type: string Product: type: object required: [id, sku, name, category, warehouse, quantity, reorderPoint, unitPrice, status, createdAt, updatedAt] properties: id: type: integer sku: type: string name: type: string description: type: ["string", "null"] category: type: string warehouse: type: string location: type: ["string", "null"] quantity: type: integer reorderPoint: type: integer unitPrice: type: number supplierId: type: ["integer", "null"] supplierName: type: ["string", "null"] leadTimeDays: type: ["integer", "null"] status: type: string committedQuantity: type: integer createdAt: type: string updatedAt: type: string ProductInput: type: object required: [sku, name, category, warehouse, quantity, reorderPoint, unitPrice] properties: sku: type: string name: type: string description: type: string category: type: string warehouse: type: string location: type: string quantity: type: integer reorderPoint: type: integer unitPrice: type: number supplierId: type: ["integer", "null"] ProductUpdate: type: object properties: name: type: string description: type: string category: type: string warehouse: type: string location: type: string quantity: type: integer reorderPoint: type: integer unitPrice: type: number supplierId: type: ["integer", "null"] ProductList: type: object required: [items, total, page, limit] properties: items: type: array items: $ref: "#/components/schemas/Product" total: type: integer page: type: integer limit: type: integer StockHistoryEntry: type: object required: [id, productId, type, quantity, user, createdAt] properties: id: type: integer productId: type: integer type: type: string quantity: type: integer user: type: string reason: type: ["string", "null"] notes: type: ["string", "null"] createdAt: type: string Order: type: object required: [id, orderNumber, type, customerSupplier, totalValue, status, createdAt] properties: id: type: integer orderNumber: type: string type: type: string customerSupplier: type: string totalValue: type: number status: type: string createdAt: type: string updatedAt: type: string OrderInput: type: object required: [type, customerSupplier, totalValue, status] properties: type: type: string customerSupplier: type: string totalValue: type: number status: type: string OrderUpdate: type: object properties: status: type: string customerSupplier: type: string totalValue: type: number OrderList: type: object required: [items, total, page, limit] properties: items: type: array items: $ref: "#/components/schemas/Order" total: type: integer page: type: integer limit: type: integer OrderStats: type: object required: [totalSales, activeOrders, purchaseOrders, avgDeliveryDays, totalSalesChange, avgDeliveryChange] properties: totalSales: type: number activeOrders: type: integer purchaseOrders: type: integer avgDeliveryDays: type: number totalSalesChange: type: number avgDeliveryChange: type: number pendingFulfillment: type: integer awaitingConfirmation: type: integer Supplier: type: object required: [id, name, type, performanceRating, activeOrders, avgLeadTimeDays, totalSpend, createdAt] properties: id: type: integer name: type: string type: type: string performanceRating: type: number activeOrders: type: integer avgLeadTimeDays: type: number lastDelivery: type: ["string", "null"] totalSpend: type: number contactEmail: type: ["string", "null"] contactPhone: type: ["string", "null"] createdAt: type: string SupplierInput: type: object required: [name, type] properties: name: type: string type: type: string contactEmail: type: string contactPhone: type: string SupplierUpdate: type: object properties: name: type: string type: type: string performanceRating: type: number activeOrders: type: integer avgLeadTimeDays: type: number contactEmail: type: string contactPhone: type: string Adjustment: type: object required: [id, productId, type, quantity, reason, user, createdAt] properties: id: type: integer productId: type: integer productName: type: ["string", "null"] productSku: type: ["string", "null"] type: type: string quantity: type: integer reason: type: string notes: type: ["string", "null"] user: type: string createdAt: type: string AdjustmentInput: type: object required: [productId, type, quantity, reason] properties: productId: type: integer type: type: string quantity: type: integer reason: type: string notes: type: string SupplierPerformanceReport: type: object required: [avgLeadTime, orderAccuracyRate, totalSpend, suppliersAtRisk, performanceTrends, spendDistribution, suppliers] properties: avgLeadTime: type: number orderAccuracyRate: type: number totalSpend: type: number suppliersAtRisk: type: integer avgLeadTimeChange: type: number performanceTrends: type: array items: $ref: "#/components/schemas/PerformanceTrendPoint" spendDistribution: type: array items: $ref: "#/components/schemas/SpendDistributionItem" suppliers: type: array items: $ref: "#/components/schemas/Supplier" PerformanceTrendPoint: type: object required: [month, leadTime, accuracy] properties: month: type: string leadTime: type: number accuracy: type: number SpendDistributionItem: type: object required: [name, amount, percentage] properties: name: type: string amount: type: number percentage: type: number