openapi: 3.1.0 info: title: Api version: 0.1.0 description: API specification for GameHub PS Rental Management servers: - url: /api description: Base API path tags: - name: health - name: auth - name: users - name: units - name: products - name: productCategories - name: stockAdjustments - name: rentals - name: transactions - name: dashboard - name: rentalPackages - name: expenses - name: settings - name: reports - name: admin - name: attendance - name: shifts paths: /healthz: get: operationId: healthCheck tags: [health] responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /auth/login: post: operationId: login tags: [auth] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LoginBody" responses: "200": description: Login successful content: application/json: schema: $ref: "#/components/schemas/LoginResponse" /auth/me: get: operationId: getMe tags: [auth] responses: "200": description: Current user content: application/json: schema: $ref: "#/components/schemas/AuthUser" /users: get: operationId: listUsers tags: [users] responses: "200": description: List of users content: application/json: schema: type: array items: $ref: "#/components/schemas/AuthUser" post: operationId: createUser tags: [users] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateUserBody" responses: "201": description: User created content: application/json: schema: $ref: "#/components/schemas/AuthUser" /users/{id}: put: operationId: updateUser tags: [users] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateUserBody" responses: "200": description: User updated content: application/json: schema: $ref: "#/components/schemas/AuthUser" delete: operationId: deleteUser tags: [users] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: User deleted content: application/json: schema: $ref: "#/components/schemas/DeleteResult" /units: get: operationId: listUnits tags: [units] responses: "200": description: List of units content: application/json: schema: type: array items: $ref: "#/components/schemas/Unit" post: operationId: createUnit tags: [units] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateUnitBody" responses: "201": description: Unit created content: application/json: schema: $ref: "#/components/schemas/Unit" /units/{id}: get: operationId: getUnit tags: [units] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Unit details content: application/json: schema: $ref: "#/components/schemas/Unit" put: operationId: updateUnit tags: [units] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateUnitBody" responses: "200": description: Unit updated content: application/json: schema: $ref: "#/components/schemas/Unit" delete: operationId: deleteUnit tags: [units] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Unit deleted content: application/json: schema: $ref: "#/components/schemas/DeleteResult" /product-categories: get: operationId: listProductCategories tags: [productCategories] responses: "200": description: List of product categories content: application/json: schema: type: array items: $ref: "#/components/schemas/ProductCategory" post: operationId: createProductCategory tags: [productCategories] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateProductCategoryBody" responses: "201": description: Category created content: application/json: schema: $ref: "#/components/schemas/ProductCategory" /product-categories/{id}: delete: operationId: deleteProductCategory tags: [productCategories] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Category deleted content: application/json: schema: $ref: "#/components/schemas/DeleteResult" /products: get: operationId: listProducts tags: [products] parameters: - name: categoryId in: query schema: type: integer responses: "200": description: List of products content: application/json: schema: type: array items: $ref: "#/components/schemas/Product" post: operationId: createProduct tags: [products] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateProductBody" responses: "201": description: Product created content: application/json: schema: $ref: "#/components/schemas/Product" /products/{id}: get: operationId: getProduct tags: [products] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Product details content: application/json: schema: $ref: "#/components/schemas/Product" put: operationId: updateProduct tags: [products] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateProductBody" responses: "200": description: Product updated content: application/json: schema: $ref: "#/components/schemas/Product" delete: operationId: deleteProduct tags: [products] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Product deleted content: application/json: schema: $ref: "#/components/schemas/DeleteResult" /stock-adjustments: get: operationId: listStockAdjustments tags: [stockAdjustments] parameters: - name: productId in: query schema: type: integer - name: limit in: query schema: type: integer default: 50 responses: "200": description: List of stock adjustments content: application/json: schema: type: array items: $ref: "#/components/schemas/StockAdjustment" post: operationId: createStockAdjustment tags: [stockAdjustments] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateStockAdjustmentBody" responses: "201": description: Stock adjusted content: application/json: schema: $ref: "#/components/schemas/StockAdjustment" /rental-packages: get: operationId: listRentalPackages tags: [rentalPackages] responses: "200": description: List of rental packages content: application/json: schema: type: array items: $ref: "#/components/schemas/RentalPackage" post: operationId: createRentalPackage tags: [rentalPackages] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateRentalPackageBody" responses: "201": description: Package created content: application/json: schema: $ref: "#/components/schemas/RentalPackage" /rental-packages/{id}: put: operationId: updateRentalPackage tags: [rentalPackages] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateRentalPackageBody" responses: "200": description: Package updated content: application/json: schema: $ref: "#/components/schemas/RentalPackage" delete: operationId: deleteRentalPackage tags: [rentalPackages] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Package deleted content: application/json: schema: $ref: "#/components/schemas/DeleteResult" /rentals: get: operationId: listRentals tags: [rentals] parameters: - name: status in: query schema: type: string enum: [active, completed] - name: date in: query schema: type: string responses: "200": description: List of rentals content: application/json: schema: type: array items: $ref: "#/components/schemas/Rental" post: operationId: startRental tags: [rentals] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/StartRentalBody" responses: "201": description: Rental started content: application/json: schema: $ref: "#/components/schemas/Rental" /rentals/active: get: operationId: listActiveRentals tags: [rentals] responses: "200": description: Active rentals with countdown content: application/json: schema: type: array items: $ref: "#/components/schemas/ActiveRental" /rentals/{id}/stop: post: operationId: stopRental tags: [rentals] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/StopRentalBody" responses: "200": description: Rental stopped content: application/json: schema: $ref: "#/components/schemas/Rental" /rentals/{id}/pay: post: operationId: payRental tags: [rentals] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PayRentalBody" responses: "200": description: Rental paid content: application/json: schema: $ref: "#/components/schemas/Rental" /rentals/{id}/extend: post: operationId: extendRental tags: [rentals] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ExtendRentalBody" responses: "200": description: Rental extended content: application/json: schema: $ref: "#/components/schemas/Rental" /attendance: get: operationId: listAttendance tags: [attendance] parameters: - name: date in: query schema: type: string - name: userId in: query schema: type: integer responses: "200": description: List attendance content: application/json: schema: type: array items: $ref: "#/components/schemas/AttendanceRecord" /attendance/today: get: operationId: getTodayAttendance tags: [attendance] responses: "200": description: Today's attendance for current user (null if not checked in) content: application/json: schema: oneOf: - $ref: "#/components/schemas/AttendanceRecord" - type: "null" /attendance/checkin: post: operationId: checkIn tags: [attendance] responses: "200": description: Checked in content: application/json: schema: $ref: "#/components/schemas/AttendanceRecord" /attendance/checkout: post: operationId: checkOut tags: [attendance] responses: "200": description: Checked out content: application/json: schema: $ref: "#/components/schemas/AttendanceRecord" /transactions: get: operationId: listTransactions tags: [transactions] parameters: - name: date in: query schema: type: string - name: type in: query schema: type: string enum: [rental, product] responses: "200": description: List of transactions content: application/json: schema: type: array items: $ref: "#/components/schemas/Transaction" post: operationId: createTransaction tags: [transactions] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateTransactionBody" responses: "201": description: Transaction recorded content: application/json: schema: $ref: "#/components/schemas/Transaction" /transactions/batch: post: operationId: createTransactionBatch tags: [transactions] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateTransactionBatchBody" responses: "201": description: Transactions recorded content: application/json: schema: type: array items: $ref: "#/components/schemas/Transaction" /transactions/{id}: delete: operationId: deleteTransaction tags: [transactions] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Transaction deleted content: application/json: schema: type: object properties: success: type: boolean required: [success] /transactions/recent: get: operationId: listRecentTransactions tags: [transactions] parameters: - name: limit in: query schema: type: integer default: 10 responses: "200": description: Recent transactions content: application/json: schema: type: array items: $ref: "#/components/schemas/Transaction" /expenses: get: operationId: listExpenses tags: [expenses] parameters: - name: date in: query schema: type: string responses: "200": description: List of expenses content: application/json: schema: type: array items: $ref: "#/components/schemas/Expense" post: operationId: createExpense tags: [expenses] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateExpenseBody" responses: "201": description: Expense created content: application/json: schema: $ref: "#/components/schemas/Expense" /expenses/{id}: delete: operationId: deleteExpense tags: [expenses] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Expense deleted content: application/json: schema: $ref: "#/components/schemas/DeleteResult" /settings: get: operationId: getSettings tags: [settings] responses: "200": description: Shop settings content: application/json: schema: $ref: "#/components/schemas/ShopSettings" put: operationId: updateSettings tags: [settings] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateSettingsBody" responses: "200": description: Settings updated content: application/json: schema: $ref: "#/components/schemas/ShopSettings" /dashboard: get: operationId: getDashboard tags: [dashboard] responses: "200": description: Dashboard stats content: application/json: schema: $ref: "#/components/schemas/DashboardStats" /reports/financial: get: operationId: getFinancialReport tags: [reports] parameters: - name: period in: query required: true schema: type: string enum: [daily, weekly, monthly, 3month, 6month, yearly] - name: startDate in: query schema: type: string - name: endDate in: query schema: type: string responses: "200": description: Financial report content: application/json: schema: $ref: "#/components/schemas/FinancialReport" /admin/reset-balance: post: operationId: resetBalance tags: [admin] responses: "200": description: Balance reset content: application/json: schema: $ref: "#/components/schemas/DeleteResult" /shifts: get: operationId: listShifts tags: [shifts] parameters: - name: date in: query schema: type: string responses: "200": description: List of shifts content: application/json: schema: type: array items: $ref: "#/components/schemas/Shift" /shifts/active: get: operationId: getActiveShift tags: [shifts] responses: "200": description: Active shift for current user or null content: application/json: schema: $ref: "#/components/schemas/Shift" nullable: true /shifts/start: post: operationId: startShift tags: [shifts] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/StartShiftBody" responses: "201": description: Shift started content: application/json: schema: $ref: "#/components/schemas/Shift" /shifts/{id}/transactions: get: operationId: getShiftTransactions tags: [shifts] parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Transactions during this shift content: application/json: schema: type: array items: $ref: "#/components/schemas/Transaction" /shifts/{id}/end: put: operationId: endShift tags: [shifts] parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/EndShiftBody" responses: "200": description: Shift ended content: application/json: schema: $ref: "#/components/schemas/ShiftSummary" components: schemas: HealthStatus: type: object properties: status: type: string required: [status] LoginBody: type: object properties: username: type: string password: type: string required: [username, password] LoginResponse: type: object properties: token: type: string user: $ref: "#/components/schemas/AuthUser" required: [token, user] AuthUser: type: object properties: id: type: integer username: type: string name: type: string role: type: string enum: [superadmin, admin, owner, karyawan] active: type: boolean createdAt: type: string format: date-time required: [id, username, name, role, active, createdAt] CreateUserBody: type: object properties: username: type: string password: type: string name: type: string role: type: string enum: [superadmin, admin, owner, karyawan] required: [username, password, name, role] UpdateUserBody: type: object properties: name: type: string password: type: string nullable: true role: type: string enum: [superadmin, admin, owner, karyawan] active: type: boolean Unit: type: object properties: id: type: integer name: type: string status: type: string enum: [available, occupied] hourlyRate: type: integer createdAt: type: string format: date-time required: [id, name, status, hourlyRate, createdAt] CreateUnitBody: type: object properties: name: type: string hourlyRate: type: integer required: [name, hourlyRate] UpdateUnitBody: type: object properties: name: type: string hourlyRate: type: integer status: type: string enum: [available, occupied] ProductCategory: type: object properties: id: type: integer name: type: string createdAt: type: string format: date-time required: [id, name, createdAt] CreateProductCategoryBody: type: object properties: name: type: string required: [name] Product: type: object properties: id: type: integer name: type: string categoryId: type: integer nullable: true categoryName: type: string nullable: true price: type: integer costPrice: type: integer stock: type: integer unitLabel: type: string packSize: type: integer nullable: true packLabel: type: string nullable: true packPrice: type: integer nullable: true packCostPrice: type: integer nullable: true createdAt: type: string format: date-time required: [id, name, price, costPrice, stock, unitLabel, createdAt] CreateProductBody: type: object properties: name: type: string categoryId: type: integer nullable: true price: type: integer costPrice: type: integer stock: type: integer unitLabel: type: string packSize: type: integer nullable: true packLabel: type: string nullable: true packPrice: type: integer nullable: true packCostPrice: type: integer nullable: true required: [name, price, stock] UpdateProductBody: type: object properties: name: type: string categoryId: type: integer nullable: true price: type: integer costPrice: type: integer stock: type: integer unitLabel: type: string packSize: type: integer nullable: true packLabel: type: string nullable: true packPrice: type: integer nullable: true packCostPrice: type: integer nullable: true StockAdjustment: type: object properties: id: type: integer productId: type: integer productName: type: string type: type: string enum: [add, reduce] quantity: type: integer reason: type: string nullable: true createdAt: type: string format: date-time required: [id, productId, productName, type, quantity, createdAt] CreateStockAdjustmentBody: type: object properties: productId: type: integer type: type: string enum: [add, reduce] quantity: type: integer reason: type: string nullable: true required: [productId, type, quantity] RentalPackage: type: object properties: id: type: integer label: type: string durationMinutes: type: integer price: type: integer costPrice: type: integer sortOrder: type: integer createdAt: type: string format: date-time required: [id, label, durationMinutes, price, costPrice, sortOrder, createdAt] CreateRentalPackageBody: type: object properties: label: type: string durationMinutes: type: integer price: type: integer costPrice: type: integer sortOrder: type: integer required: [label, durationMinutes, price] UpdateRentalPackageBody: type: object properties: label: type: string durationMinutes: type: integer price: type: integer costPrice: type: integer sortOrder: type: integer Rental: type: object properties: id: type: integer unitId: type: integer unitName: type: string customerName: type: string packageId: type: integer nullable: true packageLabel: type: string nullable: true startTime: type: string format: date-time endTime: type: string format: date-time nullable: true durationMinutes: type: integer nullable: true totalCost: type: integer nullable: true status: type: string enum: [active, completed] paymentStatus: type: string enum: [paid, unpaid] paymentMethod: type: string enum: [cash, qris] nullable: true createdAt: type: string format: date-time required: [id, unitId, unitName, customerName, startTime, status, paymentStatus, createdAt] ActiveRental: type: object properties: id: type: integer unitId: type: integer unitName: type: string customerName: type: string packageLabel: type: string startTime: type: string format: date-time endTime: type: string format: date-time remainingSeconds: type: integer totalCost: type: integer paymentStatus: type: string enum: [paid, unpaid] required: [id, unitId, unitName, customerName, packageLabel, startTime, endTime, remainingSeconds, totalCost, paymentStatus] StartRentalBody: type: object properties: unitId: type: integer packageId: type: integer payNow: type: boolean paymentMethod: type: string enum: [cash, qris] nullable: true required: [unitId, packageId] StopRentalBody: type: object properties: paymentMethod: type: string enum: [cash, qris] required: [paymentMethod] PayRentalBody: type: object properties: paymentMethod: type: string enum: [cash, qris] required: [paymentMethod] ExtendRentalBody: type: object properties: packageId: type: integer payNow: type: boolean paymentMethod: type: string enum: [cash, qris] nullable: true required: [packageId] AttendanceRecord: type: object properties: id: type: integer userId: type: integer userName: type: string date: type: string checkInTime: type: string format: date-time nullable: true checkOutTime: type: string format: date-time nullable: true notes: type: string nullable: true createdAt: type: string format: date-time required: [id, userId, userName, date, createdAt] Transaction: type: object properties: id: type: integer type: type: string enum: [rental, product] description: type: string amount: type: integer costAmount: type: integer discountAmount: type: integer paymentMethod: type: string enum: [cash, qris] rentalId: type: integer nullable: true productId: type: integer nullable: true quantity: type: integer nullable: true createdAt: type: string format: date-time required: [id, type, description, amount, costAmount, discountAmount, paymentMethod, createdAt] CreateTransactionBody: type: object properties: productId: type: integer quantity: type: integer default: 1 isPack: type: boolean paymentMethod: type: string enum: [cash, qris] required: [productId, paymentMethod] CreateTransactionBatchBody: type: object properties: paymentMethod: type: string enum: [cash, qris] discountAmount: type: integer default: 0 items: type: array items: type: object properties: productId: type: integer quantity: type: integer isPack: type: boolean required: [productId, quantity] required: [paymentMethod, items] Expense: type: object properties: id: type: integer description: type: string amount: type: integer paymentMethod: type: string enum: [cash, qris] createdAt: type: string format: date-time required: [id, description, amount, paymentMethod, createdAt] CreateExpenseBody: type: object properties: description: type: string amount: type: integer paymentMethod: type: string enum: [cash, qris] required: [description, amount, paymentMethod] ShopSettings: type: object properties: id: type: integer shopName: type: string tagline: type: string required: [id, shopName, tagline] UpdateSettingsBody: type: object properties: shopName: type: string tagline: type: string TopProduct: type: object properties: productId: type: integer productName: type: string totalQty: type: integer totalRevenue: type: integer required: [productId, productName, totalQty, totalRevenue] TopUnit: type: object properties: unitId: type: integer unitName: type: string totalSessions: type: integer totalRevenue: type: integer required: [unitId, unitName, totalSessions, totalRevenue] DashboardStats: type: object properties: todayIncome: type: integer todayProfit: type: integer cashIncome: type: integer qrisIncome: type: integer todayExpenses: type: integer cashExpenses: type: integer qrisExpenses: type: integer activeRentals: type: integer availableUnits: type: integer totalUnits: type: integer totalProducts: type: integer todayTransactions: type: integer weeklyIncome: type: array items: $ref: "#/components/schemas/DailyIncome" topProducts: type: array items: $ref: "#/components/schemas/TopProduct" topUnits: type: array items: $ref: "#/components/schemas/TopUnit" required: - todayIncome - todayProfit - cashIncome - qrisIncome - todayExpenses - cashExpenses - qrisExpenses - activeRentals - availableUnits - totalUnits - totalProducts - todayTransactions - weeklyIncome - topProducts - topUnits DailyIncome: type: object properties: date: type: string income: type: integer required: [date, income] FinancialReport: type: object properties: summary: $ref: "#/components/schemas/ReportSummary" periods: type: array items: $ref: "#/components/schemas/PeriodData" transactions: type: array items: $ref: "#/components/schemas/Transaction" expenses: type: array items: $ref: "#/components/schemas/Expense" required: [summary, periods, transactions, expenses] ReportSummary: type: object properties: totalIncome: type: integer rentalIncome: type: integer productIncome: type: integer cashIncome: type: integer qrisIncome: type: integer totalExpenses: type: integer cashExpenses: type: integer qrisExpenses: type: integer netProfit: type: integer startDate: type: string endDate: type: string required: [totalIncome, rentalIncome, productIncome, cashIncome, qrisIncome, totalExpenses, cashExpenses, qrisExpenses, netProfit, startDate, endDate] PeriodData: type: object properties: label: type: string income: type: integer rentalIncome: type: integer productIncome: type: integer cashIncome: type: integer qrisIncome: type: integer expenses: type: integer cashExpenses: type: integer qrisExpenses: type: integer profit: type: integer required: [label, income, rentalIncome, productIncome, cashIncome, qrisIncome, expenses, cashExpenses, qrisExpenses, profit] DeleteResult: type: object properties: success: type: boolean message: type: string required: [success, message] Shift: type: object properties: id: type: integer userId: type: integer userName: type: string role: type: string startTime: type: string format: date-time endTime: type: string format: date-time nullable: true openingCash: type: integer closingCash: type: integer nullable: true notes: type: string nullable: true status: type: string enum: [open, closed] createdAt: type: string format: date-time required: [id, userId, userName, role, startTime, openingCash, status, createdAt] StartShiftBody: type: object properties: openingCash: type: integer notes: type: string required: [openingCash] EndShiftBody: type: object properties: closingCash: type: integer notes: type: string required: [closingCash] ShiftSummary: type: object properties: shift: $ref: "#/components/schemas/Shift" cashTransactions: type: integer qrisTransactions: type: integer totalIncome: type: integer expectedCash: type: integer variance: type: integer required: [shift, cashTransactions, qrisTransactions, totalIncome, expectedCash, variance]