openapi: 3.1.0 info: title: Api version: 0.1.0 description: TiliGo Delivery Platform API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: auth description: Authentication - name: users description: User profile - name: businesses description: Business management - name: items description: Menu items - name: deals description: 24h combo deals - name: orders description: Order management - name: courier description: Courier operations - name: admin description: Admin operations paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" # AUTH /auth/register: post: operationId: register tags: [auth] summary: Register a new user requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RegisterInput" responses: "201": description: Registered content: application/json: schema: $ref: "#/components/schemas/AuthResponse" "400": description: Bad request /auth/login: post: operationId: login tags: [auth] summary: Login requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LoginInput" responses: "200": description: Logged in content: application/json: schema: $ref: "#/components/schemas/AuthResponse" "401": description: Unauthorized /auth/logout: post: operationId: logout tags: [auth] summary: Logout responses: "200": description: Logged out content: application/json: schema: $ref: "#/components/schemas/MessageResponse" /auth/me: get: operationId: getMe tags: [auth] summary: Get current user responses: "200": description: Current user content: application/json: schema: $ref: "#/components/schemas/User" "401": description: Unauthorized # USERS /users/profile: get: operationId: getProfile tags: [users] summary: Get own profile responses: "200": description: Profile content: application/json: schema: $ref: "#/components/schemas/User" patch: operationId: updateProfile tags: [users] summary: Update own profile requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ProfileUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/User" # BUSINESSES /businesses: get: operationId: listBusinesses tags: [businesses] summary: List all approved businesses parameters: - name: category in: query schema: type: string - name: search in: query schema: type: string responses: "200": description: Businesses list content: application/json: schema: type: array items: $ref: "#/components/schemas/Business" post: operationId: createBusiness tags: [businesses] summary: Register a new business requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/BusinessInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Business" /businesses/mine: get: operationId: getMyBusiness tags: [businesses] summary: Get the current user's business responses: "200": description: Business content: application/json: schema: $ref: "#/components/schemas/Business" "404": description: Not found /businesses/{businessId}: get: operationId: getBusiness tags: [businesses] summary: Get business by ID parameters: - name: businessId in: path required: true schema: type: number responses: "200": description: Business content: application/json: schema: $ref: "#/components/schemas/Business" patch: operationId: updateBusiness tags: [businesses] summary: Update business parameters: - name: businessId in: path required: true schema: type: number requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/BusinessUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/Business" /businesses/{businessId}/stats: get: operationId: getBusinessStats tags: [businesses] summary: Get business dashboard stats parameters: - name: businessId in: path required: true schema: type: number responses: "200": description: Stats content: application/json: schema: $ref: "#/components/schemas/BusinessStats" # ITEMS /businesses/{businessId}/items: get: operationId: listItems tags: [items] summary: List items for a business parameters: - name: businessId in: path required: true schema: type: number responses: "200": description: Items content: application/json: schema: type: array items: $ref: "#/components/schemas/Item" post: operationId: createItem tags: [items] summary: Add item to business parameters: - name: businessId in: path required: true schema: type: number requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ItemInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Item" /items/{itemId}: patch: operationId: updateItem tags: [items] summary: Update item parameters: - name: itemId in: path required: true schema: type: number requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ItemUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/Item" delete: operationId: deleteItem tags: [items] summary: Delete item parameters: - name: itemId in: path required: true schema: type: number responses: "200": description: Deleted content: application/json: schema: $ref: "#/components/schemas/MessageResponse" # DEALS /businesses/{businessId}/deals: get: operationId: listDeals tags: [deals] summary: List 24h combo deals for a business parameters: - name: businessId in: path required: true schema: type: number responses: "200": description: Deals content: application/json: schema: type: array items: $ref: "#/components/schemas/Deal" post: operationId: createDeal tags: [deals] summary: Create a 24h combo deal parameters: - name: businessId in: path required: true schema: type: number requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/DealInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Deal" /deals/{dealId}: delete: operationId: deleteDeal tags: [deals] summary: Delete a deal parameters: - name: dealId in: path required: true schema: type: number responses: "200": description: Deleted content: application/json: schema: $ref: "#/components/schemas/MessageResponse" # ORDERS /orders: get: operationId: listOrders tags: [orders] summary: List orders for the current user (role-filtered) parameters: - name: status in: query schema: type: string responses: "200": description: Orders content: application/json: schema: type: array items: $ref: "#/components/schemas/Order" post: operationId: createOrder tags: [orders] summary: Place a new order (customer) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/OrderInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Order" /orders/available: get: operationId: listAvailableOrders tags: [courier] summary: List orders available for couriers to accept responses: "200": description: Available orders content: application/json: schema: type: array items: $ref: "#/components/schemas/Order" /orders/{orderId}: get: operationId: getOrder tags: [orders] summary: Get order details parameters: - name: orderId in: path required: true schema: type: number responses: "200": description: Order content: application/json: schema: $ref: "#/components/schemas/Order" /orders/{orderId}/status: patch: operationId: updateOrderStatus tags: [orders] summary: Update order status parameters: - name: orderId in: path required: true schema: type: number requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/OrderStatusUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/Order" /orders/{orderId}/accept: post: operationId: acceptOrder tags: [courier] summary: Courier accepts an order parameters: - name: orderId in: path required: true schema: type: number responses: "200": description: Accepted content: application/json: schema: $ref: "#/components/schemas/Order" /orders/{orderId}/location: put: operationId: updateCourierLocation tags: [courier] summary: Courier updates their live location parameters: - name: orderId in: path required: true schema: type: number requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LocationUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/CourierLocation" get: operationId: getCourierLocation tags: [orders] summary: Get courier's live location for an order parameters: - name: orderId in: path required: true schema: type: number responses: "200": description: Location content: application/json: schema: $ref: "#/components/schemas/CourierLocation" /orders/{orderId}/rate: post: operationId: rateOrder tags: [orders] summary: Customer rates a delivered order parameters: - name: orderId in: path required: true schema: type: number requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RatingInput" responses: "200": description: Rated content: application/json: schema: $ref: "#/components/schemas/Order" # COURIER /courier/stats: get: operationId: getCourierStats tags: [courier] summary: Get courier dashboard stats responses: "200": description: Stats content: application/json: schema: $ref: "#/components/schemas/CourierStats" /courier/earnings: get: operationId: getCourierEarnings tags: [courier] summary: Get courier earnings breakdown responses: "200": description: Earnings content: application/json: schema: type: array items: $ref: "#/components/schemas/EarningEntry" # ADMIN /admin/stats: get: operationId: getAdminStats tags: [admin] summary: Platform-wide stats responses: "200": description: Stats content: application/json: schema: $ref: "#/components/schemas/AdminStats" /admin/users: get: operationId: listUsers tags: [admin] summary: List all users parameters: - name: role in: query schema: type: string - name: search in: query schema: type: string responses: "200": description: Users content: application/json: schema: type: array items: $ref: "#/components/schemas/User" /admin/users/{userId}: patch: operationId: adminUpdateUser tags: [admin] summary: Admin updates a user parameters: - name: userId in: path required: true schema: type: number requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminUserUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/User" delete: operationId: adminDeleteUser tags: [admin] summary: Admin deletes a user parameters: - name: userId in: path required: true schema: type: number responses: "200": description: Deleted content: application/json: schema: $ref: "#/components/schemas/MessageResponse" /admin/businesses: get: operationId: adminListBusinesses tags: [admin] summary: List all businesses (admin) responses: "200": description: Businesses content: application/json: schema: type: array items: $ref: "#/components/schemas/Business" /admin/businesses/{businessId}/status: patch: operationId: adminUpdateBusinessStatus tags: [admin] summary: Approve or suspend a business parameters: - name: businessId in: path required: true schema: type: number requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/BusinessStatusUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/Business" /admin/orders: get: operationId: adminListOrders tags: [admin] summary: List all orders (admin) parameters: - name: status in: query schema: type: string responses: "200": description: Orders content: application/json: schema: type: array items: $ref: "#/components/schemas/Order" /admin/activity: get: operationId: getAdminActivity tags: [admin] summary: Recent platform activity feed responses: "200": description: Activity content: application/json: schema: type: array items: $ref: "#/components/schemas/ActivityEntry" components: schemas: HealthStatus: type: object required: [status] properties: status: type: string MessageResponse: type: object required: [message] properties: message: type: string # AUTH SCHEMAS RegisterInput: type: object required: [email, password, role] properties: email: type: string password: type: string role: type: string enum: [customer, business, courier, admin] firstName: type: string lastName: type: string phone: type: string LoginInput: type: object required: [email, password] properties: email: type: string password: type: string AuthResponse: type: object required: [user, token] properties: user: $ref: "#/components/schemas/User" token: type: string # USER SCHEMAS User: type: object required: [id, email, role, createdAt] properties: id: type: number email: type: string role: type: string enum: [customer, business, courier, admin] firstName: type: ["string", "null"] lastName: type: ["string", "null"] phone: type: ["string", "null"] address: type: ["string", "null"] lat: type: ["number", "null"] lng: type: ["number", "null"] avatarUrl: type: ["string", "null"] isActive: type: boolean createdAt: type: string ProfileUpdate: type: object properties: firstName: type: string lastName: type: string phone: type: string address: type: string lat: type: number lng: type: number avatarUrl: type: string AdminUserUpdate: type: object properties: isActive: type: boolean role: type: string enum: [customer, business, courier, admin] # BUSINESS SCHEMAS Business: type: object required: [id, userId, name, status, createdAt] properties: id: type: number userId: type: number name: type: string description: type: ["string", "null"] category: type: ["string", "null"] imageUrl: type: ["string", "null"] address: type: ["string", "null"] phone: type: ["string", "null"] status: type: string enum: [pending, approved, suspended] rating: type: ["number", "null"] totalOrders: type: number deliveryFee: type: number estimatedMinutes: type: number createdAt: type: string BusinessInput: type: object required: [name] properties: name: type: string description: type: string category: type: string imageUrl: type: string address: type: string phone: type: string deliveryFee: type: number estimatedMinutes: type: number BusinessUpdate: type: object properties: name: type: string description: type: string category: type: string imageUrl: type: string address: type: string phone: type: string deliveryFee: type: number estimatedMinutes: type: number BusinessStats: type: object required: [totalOrders, todayOrders, totalRevenue, todayRevenue, pendingOrders, avgRating] properties: totalOrders: type: number todayOrders: type: number totalRevenue: type: number todayRevenue: type: number pendingOrders: type: number avgRating: type: number BusinessStatusUpdate: type: object required: [status] properties: status: type: string enum: [pending, approved, suspended] # ITEM SCHEMAS Item: type: object required: [id, businessId, name, price, available, createdAt] properties: id: type: number businessId: type: number name: type: string description: type: ["string", "null"] price: type: number imageUrl: type: ["string", "null"] category: type: ["string", "null"] available: type: boolean createdAt: type: string ItemInput: type: object required: [name, price] properties: name: type: string description: type: string price: type: number imageUrl: type: string category: type: string available: type: boolean ItemUpdate: type: object properties: name: type: string description: type: string price: type: number imageUrl: type: string category: type: string available: type: boolean # DEAL SCHEMAS Deal: type: object required: [id, businessId, name, price, originalPrice, expiresAt, createdAt] properties: id: type: number businessId: type: number name: type: string description: type: ["string", "null"] price: type: number originalPrice: type: number imageUrl: type: ["string", "null"] expiresAt: type: string isActive: type: boolean createdAt: type: string DealInput: type: object required: [name, price, originalPrice] properties: name: type: string description: type: string price: type: number originalPrice: type: number imageUrl: type: string expiresAt: type: string # ORDER SCHEMAS OrderItem: type: object required: [itemId, itemName, quantity, price] properties: itemId: type: number itemName: type: string quantity: type: number price: type: number Order: type: object required: [id, customerId, businessId, status, total, createdAt] properties: id: type: number customerId: type: number businessId: type: number courierId: type: ["number", "null"] status: type: string enum: [pending, confirmed, preparing, ready, picked_up, delivering, delivered, cancelled] items: type: array items: $ref: "#/components/schemas/OrderItem" total: type: number deliveryFee: type: number address: type: string lat: type: ["number", "null"] lng: type: ["number", "null"] notes: type: ["string", "null"] etaMinutes: type: ["number", "null"] rating: type: ["number", "null"] ratingNote: type: ["string", "null"] businessName: type: ["string", "null"] customerName: type: ["string", "null"] customerPhone: type: ["string", "null"] courierName: type: ["string", "null"] createdAt: type: string acceptedAt: type: ["string", "null"] deliveredAt: type: ["string", "null"] OrderInput: type: object required: [businessId, items, address, total] properties: businessId: type: number items: type: array items: type: object required: [itemId, quantity] properties: itemId: type: number quantity: type: number address: type: string lat: type: number lng: type: number notes: type: string total: type: number deliveryFee: type: number OrderStatusUpdate: type: object required: [status] properties: status: type: string enum: [pending, confirmed, preparing, ready, picked_up, delivering, delivered, cancelled] etaMinutes: type: number RatingInput: type: object required: [rating] properties: rating: type: number ratingNote: type: string # LOCATION LocationUpdate: type: object required: [lat, lng] properties: lat: type: number lng: type: number CourierLocation: type: object required: [courierId, lat, lng, updatedAt] properties: courierId: type: number orderId: type: number lat: type: number lng: type: number etaMinutes: type: ["number", "null"] updatedAt: type: string # COURIER STATS CourierStats: type: object required: [todayOrders, todayEarnings, totalOrders, totalEarnings, rating, activeOrder] properties: todayOrders: type: number todayEarnings: type: number totalOrders: type: number totalEarnings: type: number rating: type: number activeOrder: type: ["number", "null"] EarningEntry: type: object required: [date, orders, amount] properties: date: type: string orders: type: number amount: type: number # ADMIN SCHEMAS AdminStats: type: object required: [totalUsers, totalBusinesses, totalCouriers, totalOrders, todayOrders, totalRevenue, todayRevenue, pendingBusinesses, activeOrders] properties: totalUsers: type: number totalBusinesses: type: number totalCouriers: type: number totalOrders: type: number todayOrders: type: number totalRevenue: type: number todayRevenue: type: number pendingBusinesses: type: number activeOrders: type: number ActivityEntry: type: object required: [id, type, message, createdAt] properties: id: type: number type: type: string message: type: string createdAt: type: string