Backend API service for Cafe Management System built using GraphQL API, Apollo and Node.js libraries. MongoDB used and hosted on MongoDB Atlas.
-
allItems
- Fetch all items in the menu.
- Returns:
[Item]
-
userOrders
- Fetch orders for the logged-in user.
- Returns:
[Order]
-
findOrder
- Find an order by its ID.
- Input:
orderId: ID!
- Returns:
Order
-
getEmployees
- Get a list of employees.
- Returns:
[User]
-
getMonthlySales
- Get monthly sales statistics.
- Input:
selectedMonth: Int, selectedYear: Int
- Returns:
MonthlySales
-
signup
- User signup.
- Input:
signupInput: signupInput
- Returns:
User
-
login
- User login.
- Input:
loginInput: loginInput
- Returns:
User
-
registerEmployee
- Register an employee (admin only).
- Input:
signupInput: signupInput
- Returns:
User
-
addItem
- Add a new item to the menu (admin only).
- Input:
itemInput: itemInput
- Returns:
Item
-
placeOrder
- Place a new order.
- Input:
orderInput: orderInput
- Returns:
Order
-
changeOrderStatus
- Change the status of an order (admin/employee only).
- Input:
orderId: ID!, newStatus: String!
- Returns:
Order
-
deleteItem
- Delete an item from the menu (admin only).
- Input:
itemId: ID!
- Returns:
{ message: String }
-
deleteEmployee
- Delete an employee (admin only).
- Input:
userId: ID!
- Returns:
{ message: String }
-
forgotPassword
- Initiate password reset process.
- Input:
email: String!
- Returns:
ForgotPasswordResponse
-
changePassword
- Change user password.
- Input:
currentPassword: String, newPassword: String
- Returns:
ChangePasswordResponse
-
DateTime
- Custom scalar representing a date and time.
-
OrderStatus
- Enum representing order status (Pending, Preparing, Prepared, Served, Completed, Cancelled).
-
User
- User information.
- Fields:
id, username, email, password, token, role
.
-
signupInput
- Input for user signup.
- Fields:
username, email, password
.
-
loginInput
- Input for user login.
- Fields:
email, password
.
-
Item
- Menu item information.
- Fields:
id, itemName, itemDesc, itemImage, itemGrp, itemPrice
.
-
itemInput
- Input for adding a new item.
- Fields:
itemName, itemDesc, itemImage, itemGrp, itemPrice
.
-
Order
- Order information.
- Fields:
id, customerName, items, totalAmount, status, createdAt, orderServedAt, orderCompletedAt
.
-
OrderItem
- Information about an item in an order.
- Fields:
name, quantity, price
.
-
orderInput
- Input for placing a new order.
- Fields:
customerName, items, totalAmount
.
-
orderItemInput
- Input for an item in an order.
- Fields:
name, quantity, price
.
-
MonthlySales
- Monthly sales statistics.
- Fields:
totalSales, avgOrderCompletionTime, numberOfOrdersMonthly, month, year, topSellingItems, avgOrderValue, bestSellingCategory, busyTime
.
-
TopSellingItem
- Information about a top-selling item.
- Fields:
itemName, totalQuantity
.
-
ForgotPasswordResponse
- Response for the forgot password mutation.
- Fields:
success, message
.
-
ChangePasswordResponse
- Response for the change password mutation.
- Fields:
success, message
.
- The API uses JWT tokens for authentication.
- Certain mutations are restricted to specific roles (admin, employee).
- Some mutations require authentication (login/signup) and authorization (admin-only actions).
- The API supports fetching monthly sales data and managing user orders.
- Error responses include custom error codes for better error handling.
- Date and time are represented using the custom
DateTime
scalar.