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: Transport Management Platform API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: trucks description: Truck management - name: drivers description: Driver management - name: trips description: Trip management - name: photos description: Photo upload and verification - name: billing description: Billing and invoicing - name: clients description: Client company management - name: dashboard description: Dashboard summaries paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /trucks: get: operationId: listTrucks tags: [trucks] responses: "200": description: List of trucks content: application/json: schema: type: array items: $ref: "#/components/schemas/Truck" post: operationId: createTruck tags: [trucks] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateTruckBody" responses: "201": description: Truck created content: application/json: schema: $ref: "#/components/schemas/Truck" /trucks/{id}: get: operationId: getTruck tags: [trucks] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Truck detail content: application/json: schema: $ref: "#/components/schemas/Truck" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" patch: operationId: updateTruck tags: [trucks] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateTruckBody" responses: "200": description: Truck updated content: application/json: schema: $ref: "#/components/schemas/Truck" /drivers: get: operationId: listDrivers tags: [drivers] responses: "200": description: List of drivers content: application/json: schema: type: array items: $ref: "#/components/schemas/Driver" post: operationId: createDriver tags: [drivers] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateDriverBody" responses: "201": description: Driver created content: application/json: schema: $ref: "#/components/schemas/Driver" /drivers/{id}: get: operationId: getDriver tags: [drivers] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Driver detail content: application/json: schema: $ref: "#/components/schemas/Driver" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /trips: get: operationId: listTrips tags: [trips] parameters: - name: status in: query required: false schema: type: string - name: truckId in: query required: false schema: type: integer - name: driverId in: query required: false schema: type: integer responses: "200": description: List of trips content: application/json: schema: type: array items: $ref: "#/components/schemas/Trip" post: operationId: createTrip tags: [trips] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateTripBody" responses: "201": description: Trip created content: application/json: schema: $ref: "#/components/schemas/Trip" /trips/{id}: get: operationId: getTrip tags: [trips] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Trip detail content: application/json: schema: $ref: "#/components/schemas/Trip" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" patch: operationId: updateTrip tags: [trips] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateTripBody" responses: "200": description: Trip updated content: application/json: schema: $ref: "#/components/schemas/Trip" /trips/{id}/photos: get: operationId: listTripPhotos tags: [photos] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: List of photos content: application/json: schema: type: array items: $ref: "#/components/schemas/TripPhoto" post: operationId: uploadTripPhoto tags: [photos] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UploadPhotoBody" responses: "201": description: Photo uploaded content: application/json: schema: $ref: "#/components/schemas/TripPhoto" /photos/{photoId}/request-otp: post: operationId: requestPhotoOtp tags: [photos] parameters: - name: photoId in: path required: true schema: type: integer responses: "200": description: OTP sent content: application/json: schema: $ref: "#/components/schemas/OtpResponse" /photos/{photoId}/verify-otp: post: operationId: verifyPhotoOtp tags: [photos] parameters: - name: photoId in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/VerifyOtpBody" responses: "200": description: Photo verified content: application/json: schema: $ref: "#/components/schemas/TripPhoto" "400": description: Invalid OTP content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /clients: get: operationId: listClients tags: [clients] summary: List all clients responses: "200": description: List of clients content: application/json: schema: type: array items: $ref: "#/components/schemas/Client" post: operationId: createClient tags: [clients] summary: Create a client requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateClientBody" responses: "201": description: Client created content: application/json: schema: $ref: "#/components/schemas/Client" /clients/{id}: get: operationId: getClient tags: [clients] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Client detail content: application/json: schema: $ref: "#/components/schemas/Client" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" patch: operationId: updateClient tags: [clients] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateClientBody" responses: "200": description: Client updated content: application/json: schema: $ref: "#/components/schemas/Client" delete: operationId: deleteClient tags: [clients] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Client deleted content: application/json: schema: $ref: "#/components/schemas/SuccessResponse" /billing: get: operationId: listBills tags: [billing] parameters: - name: tripId in: query required: false schema: type: integer - name: status in: query required: false schema: type: string - name: clientId in: query required: false schema: type: integer responses: "200": description: List of bills content: application/json: schema: type: array items: $ref: "#/components/schemas/Bill" post: operationId: createBill tags: [billing] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateBillBody" responses: "201": description: Bill created content: application/json: schema: $ref: "#/components/schemas/Bill" /billing/{id}: get: operationId: getBill tags: [billing] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Bill detail content: application/json: schema: $ref: "#/components/schemas/Bill" patch: operationId: updateBill tags: [billing] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateBillBody" responses: "200": description: Bill updated content: application/json: schema: $ref: "#/components/schemas/Bill" /billing/{id}/payment: post: operationId: recordPayment tags: [billing] summary: Record a payment against a bill parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RecordPaymentBody" responses: "200": description: Payment recorded content: application/json: schema: $ref: "#/components/schemas/Bill" /billing/export/csv: get: operationId: exportBillsCsv tags: [billing] responses: "200": description: Bills CSV export data content: application/json: schema: $ref: "#/components/schemas/BillsExport" /billing/{id}/invoice-data: get: operationId: getInvoiceData tags: [billing] summary: Get full invoice data for PDF generation parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Invoice data content: application/json: schema: $ref: "#/components/schemas/InvoiceData" /dashboard/summary: get: operationId: getDashboardSummary tags: [dashboard] responses: "200": description: Dashboard summary content: application/json: schema: $ref: "#/components/schemas/DashboardSummary" /dashboard/recent-trips: get: operationId: getRecentTrips tags: [dashboard] responses: "200": description: Recent trips content: application/json: schema: type: array items: $ref: "#/components/schemas/Trip" /dashboard/pending-photos: get: operationId: getPendingPhotos tags: [dashboard] responses: "200": description: Pending photos content: application/json: schema: type: array items: $ref: "#/components/schemas/TripPhoto" /dashboard/driver-activity: get: operationId: getDriverActivity tags: [dashboard] summary: Get all drivers with their current active trip responses: "200": description: Driver activity list content: application/json: schema: type: array items: $ref: "#/components/schemas/DriverActivity" /auth/setup-owner: post: operationId: setupOwner tags: [health] summary: First-time owner setup (only works if no owner exists yet) responses: "200": description: Owner role set content: application/json: schema: $ref: "#/components/schemas/SuccessResponse" "400": description: Owner already exists content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/me: get: operationId: getMe tags: [health] summary: Get current user info and role responses: "200": description: Current user content: application/json: schema: $ref: "#/components/schemas/UserInfo" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/set-role: post: operationId: setUserRole tags: [health] summary: Set a user role (owner only) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SetRoleBody" responses: "200": description: Role updated content: application/json: schema: $ref: "#/components/schemas/SuccessResponse" components: schemas: HealthStatus: type: object properties: status: type: string required: - status ErrorResponse: type: object properties: error: type: string required: - error SuccessResponse: type: object properties: success: type: boolean message: type: string required: - success UserInfo: type: object properties: userId: type: string role: type: string email: type: ["string", "null"] required: - userId - role SetRoleBody: type: object properties: targetUserId: type: string role: type: string required: - targetUserId - role Truck: type: object properties: id: type: integer registrationNumber: type: string model: type: string capacity: type: number status: type: string driverId: type: ["integer", "null"] createdAt: type: string updatedAt: type: string required: - id - registrationNumber - model - capacity - status - driverId - createdAt - updatedAt CreateTruckBody: type: object properties: registrationNumber: type: string model: type: string capacity: type: number status: type: string driverId: type: ["integer", "null"] required: - registrationNumber - model - capacity UpdateTruckBody: type: object properties: registrationNumber: type: string model: type: string capacity: type: number status: type: string driverId: type: ["integer", "null"] Driver: type: object properties: id: type: integer name: type: string phone: type: string licenseNumber: type: string status: type: string createdAt: type: string updatedAt: type: string required: - id - name - phone - licenseNumber - status - createdAt - updatedAt CreateDriverBody: type: object properties: name: type: string phone: type: string licenseNumber: type: string status: type: string required: - name - phone - licenseNumber Trip: type: object properties: id: type: integer truckId: type: integer driverId: type: integer clientId: type: ["integer", "null"] origin: type: string destination: type: string clientCompany: type: string cargoDescription: type: string status: type: string startDate: type: ["string", "null"] endDate: type: ["string", "null"] notes: type: ["string", "null"] createdAt: type: string updatedAt: type: string required: - id - truckId - driverId - clientId - origin - destination - clientCompany - cargoDescription - status - startDate - endDate - notes - createdAt - updatedAt CreateTripBody: type: object properties: truckId: type: integer driverId: type: integer clientId: type: integer origin: type: string destination: type: string clientCompany: type: string cargoDescription: type: string startDate: type: string notes: type: string required: - truckId - driverId - origin - destination - clientCompany - cargoDescription UpdateTripBody: type: object properties: status: type: string endDate: type: string notes: type: string cargoDescription: type: string clientId: type: integer TripPhoto: type: object properties: id: type: integer tripId: type: integer photoType: type: string photoUrl: type: string photoDataUrl: type: ["string", "null"] verified: type: boolean verifiedAt: type: ["string", "null"] otpCode: type: ["string", "null"] otpExpiry: type: ["string", "null"] uploadedBy: type: string createdAt: type: string required: - id - tripId - photoType - photoUrl - photoDataUrl - verified - verifiedAt - otpCode - otpExpiry - uploadedBy - createdAt UploadPhotoBody: type: object properties: photoType: type: string photoDataUrl: type: string uploadedBy: type: string required: - photoType - photoDataUrl - uploadedBy OtpResponse: type: object properties: message: type: string otpSentTo: type: string required: - message - otpSentTo VerifyOtpBody: type: object properties: otp: type: string required: - otp Client: type: object properties: id: type: integer name: type: string contactName: type: ["string", "null"] phone: type: string email: type: ["string", "null"] address: type: ["string", "null"] gstNumber: type: ["string", "null"] notes: type: ["string", "null"] createdAt: type: string updatedAt: type: string required: - id - name - phone - contactName - email - address - gstNumber - notes - createdAt - updatedAt CreateClientBody: type: object properties: name: type: string contactName: type: string phone: type: string email: type: string address: type: string gstNumber: type: string notes: type: string required: - name - phone UpdateClientBody: type: object properties: name: type: string contactName: type: string phone: type: string email: type: string address: type: string gstNumber: type: string notes: type: string Bill: type: object properties: id: type: integer tripId: type: integer billNumber: type: string baseAmount: type: number fuelSurcharge: type: number tollCharges: type: number otherCharges: type: number totalAmount: type: number amountPaid: type: number paymentMethod: type: ["string", "null"] status: type: string issuedDate: type: ["string", "null"] dueDate: type: ["string", "null"] paidDate: type: ["string", "null"] notes: type: ["string", "null"] createdAt: type: string updatedAt: type: string required: - id - tripId - billNumber - baseAmount - fuelSurcharge - tollCharges - otherCharges - totalAmount - amountPaid - paymentMethod - status - issuedDate - dueDate - paidDate - notes - createdAt - updatedAt CreateBillBody: type: object properties: tripId: type: integer baseAmount: type: number fuelSurcharge: type: number tollCharges: type: number otherCharges: type: number dueDate: type: string notes: type: string required: - tripId - baseAmount UpdateBillBody: type: object properties: status: type: string paidDate: type: string notes: type: string fuelSurcharge: type: number tollCharges: type: number otherCharges: type: number dueDate: type: string paymentMethod: type: string RecordPaymentBody: type: object properties: amount: type: number paymentMethod: type: string paymentDate: type: string notes: type: string required: - amount - paymentMethod InvoiceData: type: object properties: bill: $ref: "#/components/schemas/Bill" trip: $ref: "#/components/schemas/Trip" client: $ref: "#/components/schemas/Client" truck: $ref: "#/components/schemas/Truck" driver: $ref: "#/components/schemas/Driver" required: - bill - trip - client - truck - driver BillsExport: type: object properties: headers: type: array items: type: string rows: type: array items: type: array items: type: string required: - headers - rows DriverActivity: type: object properties: driver: $ref: "#/components/schemas/Driver" currentTrip: oneOf: - $ref: "#/components/schemas/Trip" - type: "null" truck: oneOf: - $ref: "#/components/schemas/Truck" - type: "null" required: - driver - currentTrip - truck DashboardSummary: type: object properties: totalTrucks: type: integer activeTrucks: type: integer totalDrivers: type: integer activeTrips: type: integer completedTripsThisMonth: type: integer totalRevenueThisMonth: type: number pendingBills: type: integer pendingPhotoVerifications: type: integer totalClients: type: integer required: - totalTrucks - activeTrucks - totalDrivers - activeTrips - completedTripsThisMonth - totalRevenueThisMonth - pendingBills - pendingPhotoVerifications - totalClients