Skip to Content
MySagra 1.4.0 is released 🎉
Database

Database

MySagra uses MySQL as its primary database, managed via Prisma ORM . Migrations are applied automatically on API startup when MIGRATE_ON_START=true is set in the environment (default for the Docker Compose setup).

ER Diagram

Model reference

ModelTableDescription
CategorycategoriesGroups of foods. Each category can be linked to a specific printer for ticket routing.
FoodfoodsIndividual menu items. Belong to a category; can override the category printer.
IngredientingredientsA shared pool of ingredients.
FoodIngredientfood_ingredientsMany-to-many join between Food and Ingredient.

Orders

ModelTableDescription
OrderordersA customer order. Tracks table, customer name, payment method, totals, and status lifecycle.
OrderItemorder_itemsA line item inside an order. Stores the food, quantity, unit price, and optional notes.
DailyTicketCounter—Incremental counter reset daily, used to generate the human-readable ticketNumber printed on receipts.

Order status lifecycle

PENDING → CONFIRMED → COMPLETED → PICKED_UP
StatusMeaning
PENDINGOrder created, not yet confirmed by the cashier
CONFIRMEDPayment taken, ticket printed
COMPLETEDFood is ready for pickup
PICKED_UPCustomer collected the order

Users & authentication

ModelTableDescription
RolerolesNamed roles (e.g. admin, cashier). Controls API permissions.
UserusersOperator accounts. Each user has one role.
RefreshTokenrefresh_tokensJWT refresh tokens with expiry, revocation timestamp, and client metadata.

Hardware

ModelTableDescription
PrinterprintersESC/POS network printers (IP + port). Status tracked as ONLINE, OFFLINE, or ERROR.
CashRegistercash_registersNamed cash register stations. Each can have a default printer; orders are associated to a register.
Last updated on