openapi: 3.1.0 info: title: Api version: 0.1.0 description: Pharmacy Management System API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: medicines description: Medicine inventory management - name: categories description: Medicine categories - name: suppliers description: Supplier management - name: purchases description: Purchase orders management - name: customers description: Customer management - name: sales description: Sales and POS management - name: prescriptions description: Prescription management - name: dashboard description: Dashboard and analytics paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" # ─── Categories ─────────────────────────────────────────────── /categories: get: operationId: listCategories tags: [categories] summary: List all categories responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/Category" post: operationId: createCategory tags: [categories] summary: Create a category requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CategoryInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Category" /categories/{id}: get: operationId: getCategory tags: [categories] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Category" patch: operationId: updateCategory tags: [categories] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CategoryUpdate" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Category" delete: operationId: deleteCategory tags: [categories] parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted # ─── Medicines ──────────────────────────────────────────────── /medicines: get: operationId: listMedicines tags: [medicines] summary: List all medicines parameters: - name: search in: query schema: type: string - name: categoryId in: query schema: type: integer - name: lowStock in: query schema: type: boolean responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/Medicine" post: operationId: createMedicine tags: [medicines] summary: Add a medicine requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/MedicineInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Medicine" /medicines/{id}: get: operationId: getMedicine tags: [medicines] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Medicine" patch: operationId: updateMedicine tags: [medicines] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/MedicineUpdate" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Medicine" delete: operationId: deleteMedicine tags: [medicines] parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted /medicines/expiring-soon: get: operationId: listExpiringSoon tags: [medicines] summary: List medicines expiring within 30 days responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/Medicine" # ─── Suppliers ──────────────────────────────────────────────── /suppliers: get: operationId: listSuppliers tags: [suppliers] summary: List all suppliers responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/Supplier" post: operationId: createSupplier tags: [suppliers] summary: Create a 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] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Supplier" patch: operationId: updateSupplier tags: [suppliers] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SupplierUpdate" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Supplier" delete: operationId: deleteSupplier tags: [suppliers] parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted # ─── Purchases ──────────────────────────────────────────────── /purchases: get: operationId: listPurchases tags: [purchases] summary: List all purchase orders responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/Purchase" post: operationId: createPurchase tags: [purchases] summary: Create a purchase order requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PurchaseInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Purchase" /purchases/{id}: get: operationId: getPurchase tags: [purchases] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Purchase" # ─── Customers ──────────────────────────────────────────────── /customers: get: operationId: listCustomers tags: [customers] summary: List all customers parameters: - name: search in: query schema: type: string responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/Customer" post: operationId: createCustomer tags: [customers] summary: Create a customer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CustomerInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Customer" /customers/{id}: get: operationId: getCustomer tags: [customers] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Customer" patch: operationId: updateCustomer tags: [customers] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CustomerUpdate" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Customer" delete: operationId: deleteCustomer tags: [customers] parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted /customers/{id}/sales: get: operationId: getCustomerSales tags: [customers] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/Sale" # ─── Sales ──────────────────────────────────────────────────── /sales: get: operationId: listSales tags: [sales] summary: List all sales parameters: - name: startDate in: query schema: type: string - name: endDate in: query schema: type: string responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/Sale" post: operationId: createSale tags: [sales] summary: Create a sale (POS) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SaleInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Sale" /sales/{id}: get: operationId: getSale tags: [sales] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Sale" # ─── Prescriptions ──────────────────────────────────────────── /prescriptions: get: operationId: listPrescriptions tags: [prescriptions] summary: List all prescriptions responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/Prescription" post: operationId: createPrescription tags: [prescriptions] summary: Create a prescription record requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PrescriptionInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Prescription" /prescriptions/{id}: get: operationId: getPrescription tags: [prescriptions] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Prescription" patch: operationId: updatePrescription tags: [prescriptions] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PrescriptionUpdate" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Prescription" # ─── Dashboard ──────────────────────────────────────────────── /dashboard/summary: get: operationId: getDashboardSummary tags: [dashboard] summary: Get dashboard KPI summary responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/DashboardSummary" /dashboard/sales-chart: get: operationId: getSalesChart tags: [dashboard] summary: Get daily sales data for chart (last 30 days) responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/SalesChartPoint" /dashboard/top-medicines: get: operationId: getTopMedicines tags: [dashboard] summary: Get top selling medicines responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/TopMedicine" /dashboard/recent-sales: get: operationId: getRecentSales tags: [dashboard] summary: Get last 10 sales responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/Sale" /dashboard/low-stock: get: operationId: getLowStockAlerts tags: [dashboard] summary: Get medicines with low stock responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/Medicine" components: schemas: HealthStatus: type: object properties: status: type: string required: - status # ── Category ───────────────────────────────────────────────── Category: type: object required: [id, name, createdAt] properties: id: type: integer name: type: string description: type: ["string", "null"] createdAt: type: string CategoryInput: type: object required: [name] properties: name: type: string minLength: 1 description: type: string CategoryUpdate: type: object properties: name: type: string minLength: 1 description: type: string # ── Medicine ────────────────────────────────────────────────── Medicine: type: object required: [id, name, genericName, quantity, minQuantity, purchasePrice, sellingPrice, createdAt] properties: id: type: integer name: type: string genericName: type: string barcode: type: ["string", "null"] categoryId: type: ["integer", "null"] categoryName: type: ["string", "null"] supplierId: type: ["integer", "null"] supplierName: type: ["string", "null"] quantity: type: integer minQuantity: type: integer purchasePrice: type: number sellingPrice: type: number expiryDate: type: ["string", "null"] location: type: ["string", "null"] description: type: ["string", "null"] requiresPrescription: type: boolean createdAt: type: string MedicineInput: type: object required: [name, genericName, quantity, minQuantity, purchasePrice, sellingPrice] properties: name: type: string minLength: 1 genericName: type: string barcode: type: string categoryId: type: integer supplierId: type: integer quantity: type: integer minQuantity: type: integer purchasePrice: type: number sellingPrice: type: number expiryDate: type: string location: type: string description: type: string requiresPrescription: type: boolean MedicineUpdate: type: object properties: name: type: string genericName: type: string barcode: type: string categoryId: type: integer supplierId: type: integer quantity: type: integer minQuantity: type: integer purchasePrice: type: number sellingPrice: type: number expiryDate: type: string location: type: string description: type: string requiresPrescription: type: boolean # ── Supplier ────────────────────────────────────────────────── Supplier: type: object required: [id, name, createdAt] properties: id: type: integer name: type: string contactPerson: type: ["string", "null"] phone: type: ["string", "null"] email: type: ["string", "null"] address: type: ["string", "null"] createdAt: type: string SupplierInput: type: object required: [name] properties: name: type: string minLength: 1 contactPerson: type: string phone: type: string email: type: string address: type: string SupplierUpdate: type: object properties: name: type: string contactPerson: type: string phone: type: string email: type: string address: type: string # ── Purchase ────────────────────────────────────────────────── PurchaseItem: type: object required: [medicineId, medicineName, quantity, unitPrice, totalPrice] properties: id: type: integer medicineId: type: integer medicineName: type: string quantity: type: integer unitPrice: type: number totalPrice: type: number expiryDate: type: ["string", "null"] PurchaseItemInput: type: object required: [medicineId, quantity, unitPrice] properties: medicineId: type: integer quantity: type: integer unitPrice: type: number expiryDate: type: string Purchase: type: object required: [id, supplierId, supplierName, totalAmount, status, items, createdAt] properties: id: type: integer supplierId: type: integer supplierName: type: string invoiceNumber: type: ["string", "null"] totalAmount: type: number status: type: string enum: [pending, received, cancelled] notes: type: ["string", "null"] items: type: array items: $ref: "#/components/schemas/PurchaseItem" createdAt: type: string PurchaseInput: type: object required: [supplierId, items] properties: supplierId: type: integer invoiceNumber: type: string notes: type: string items: type: array items: $ref: "#/components/schemas/PurchaseItemInput" # ── Customer ────────────────────────────────────────────────── Customer: type: object required: [id, name, createdAt] properties: id: type: integer name: type: string phone: type: ["string", "null"] email: type: ["string", "null"] address: type: ["string", "null"] dateOfBirth: type: ["string", "null"] notes: type: ["string", "null"] totalPurchases: type: number createdAt: type: string CustomerInput: type: object required: [name] properties: name: type: string minLength: 1 phone: type: string email: type: string address: type: string dateOfBirth: type: string notes: type: string CustomerUpdate: type: object properties: name: type: string phone: type: string email: type: string address: type: string dateOfBirth: type: string notes: type: string # ── Sale ────────────────────────────────────────────────────── SaleItem: type: object required: [medicineId, medicineName, quantity, unitPrice, totalPrice] properties: id: type: integer medicineId: type: integer medicineName: type: string quantity: type: integer unitPrice: type: number totalPrice: type: number SaleItemInput: type: object required: [medicineId, quantity, unitPrice] properties: medicineId: type: integer quantity: type: integer unitPrice: type: number Sale: type: object required: [id, totalAmount, paymentMethod, status, items, createdAt] properties: id: type: integer customerId: type: ["integer", "null"] customerName: type: ["string", "null"] prescriptionId: type: ["integer", "null"] totalAmount: type: number discount: type: number paymentMethod: type: string enum: [cash, card, insurance] status: type: string enum: [completed, refunded, pending] notes: type: ["string", "null"] items: type: array items: $ref: "#/components/schemas/SaleItem" createdAt: type: string SaleInput: type: object required: [items, paymentMethod] properties: customerId: type: integer prescriptionId: type: integer items: type: array items: $ref: "#/components/schemas/SaleItemInput" discount: type: number paymentMethod: type: string enum: [cash, card, insurance] notes: type: string # ── Prescription ────────────────────────────────────────────── Prescription: type: object required: [id, doctorName, createdAt] properties: id: type: integer customerId: type: ["integer", "null"] customerName: type: ["string", "null"] doctorName: type: string doctorSpecialty: type: ["string", "null"] status: type: string enum: [pending, dispensed, cancelled] notes: type: ["string", "null"] createdAt: type: string PrescriptionInput: type: object required: [doctorName] properties: customerId: type: integer doctorName: type: string minLength: 1 doctorSpecialty: type: string notes: type: string PrescriptionUpdate: type: object properties: doctorName: type: string doctorSpecialty: type: string status: type: string enum: [pending, dispensed, cancelled] notes: type: string # ── Dashboard ───────────────────────────────────────────────── DashboardSummary: type: object required: - todaySales - todayRevenue - totalMedicines - lowStockCount - expiringSoonCount - totalCustomers - monthRevenue - totalSalesToday properties: todaySales: type: integer todayRevenue: type: number totalMedicines: type: integer lowStockCount: type: integer expiringSoonCount: type: integer totalCustomers: type: integer monthRevenue: type: number totalSalesToday: type: integer SalesChartPoint: type: object required: [date, revenue, salesCount] properties: date: type: string revenue: type: number salesCount: type: integer TopMedicine: type: object required: [medicineId, medicineName, totalQuantity, totalRevenue] properties: medicineId: type: integer medicineName: type: string totalQuantity: type: integer totalRevenue: type: number