How alfredlim16/restaurant-management-system works
1. This is a Java desktop application for restaurant operations, not a web service. The main runtime is a Swing UI, with role-based entry points for login, cashier work, and manager/admin work.
2. The top-level launch path appears to be restaurantmanagementsystem/RestaurantManagementSystem.java, which likely boots the app and opens the login screen. From there, access is routed by role into user/LoginFrame, cashier/CashierFrame, or manager/ManagerFrame.
3. The architecture is split into three major functional areas:
- user: authentication, authorization, database connection, and shared exception types
- cashier: order taking, payment processing, and receipt generation
- manager: inventory, menu ingredients, food waste, reports, and user management
4. The user package is the shared infrastructure layer. It contains DatabaseConnection, AuthenticationService, PermissionService, AbstractAppService, user/domain objects, and interfaces such as IAuthentication, IPermission, and IUser. This layer enforces access control and provides the database access foundation used by the other modules.
5. The cashier subsystem centers on customer transaction flow. OrdersPanel and PaymentsPanel are the UI surfaces, while OrderService and PaymentService handle the business logic. Domain objects like Order, OrderItem, MenuItem, and Payment are paired with persistence mappers prefixed with Db* such as DbOrder, DbPayment, and DbMenuItem.
6. Cashier data flow is likely: select menu items -> build an Order -> validate status and inventory rules -> create a Payment using a PaymentMethod -> update OrderStatus and PaymentStatus -> display or print a receipt via ReceiptDialog. Failures are surfaced through business exceptions such as PaymentFailedException and InsufficientInventoryException.
7. The manager subsystem supports operational control and reporting. InventoryPanel, MenuItemPanel, FoodWastePanel, ReportsPanel, and UserManagementPanel are the primary screens. Services such as InventoryService, MenuItemService, FoodWasteService, ReportService, and UserManagementService implement the domain workflows behind those screens.
8. Manager data is structured around inventory and menu composition. InventoryItem, MenuItemIngredient, and FoodWaste represent the core entities, with corresponding DB-backed classes like DbInventoryItem, DbMenuItemIngredient, and DbFoodWaste. The presence of IngredientDialog and DatePickerDialog suggests interactive data-entry and filtering for operational updates and reporting.
9. Reports are likely derived from persisted transactional and operational data, not computed entirely in memory. ReportService probably aggregates orders/payments, inventory changes, and food waste into manager-facing summaries shown in ReportsPanel and DashboardPanel.
10. The Db* classes form the persistence boundary. They appear to be row-mapped representations of the domain objects used by the services, separating UI/business models from database-facing structures. The actual schema is defined in src/main/resources/sql file/database.sql.
11. Interfaces such as IMenuItem, IOrder, IPayment, IInventoryItem, IFoodWaste, and IMenuItemIngredient indicate the code uses explicit contracts for core entities. This suggests the system is organized around service-driven business logic with domain abstractions, rather than direct UI-to-database access.
12. Cross-cutting validation and error handling are first-class parts of the design. ValidationException, BusinessException, PaymentFailedException, and InsufficientInventoryException indicate that domain rules are enforced in the service layer and propagated back to the Swing UI for user feedback.
13. Resource folders for icons and images show the UI is polished and likely heavily desktop-oriented. The architecture is therefore best drawn as a client-side desktop application with local UI, service, and persistence layers, rather than a distributed microservice system.
14. For an architecture diagram, the clearest boundaries are:
- Presentation: Swing frames, panels, dialogs
- Application/domain services: auth, cashier, manager services
- Persistence: DB-mapped entities and database connection
- Shared infrastructure: user/auth/permission, exceptions, and role model
- External dependency: relational database defined by the bundled SQL schema
Main entry points: DatabaseConnection.java Database · ManagerFrame.java Manager · PaymentService.java Payment service · LoginFrame.java Login
Components 34
Presentation
Swing launchers, role frames, screens, and dialogs
- App launch · Main entry point that starts the desktop application
src/main/java/restaurantmanagementsystem/RestaurantManagementSystem.java - Login · Shared login screen that routes users by role
src/main/java/user/LoginFrame.java - Cashier · Cashier workspace shell
src/main/java/cashier/CashierFrame.java - Manager · Manager/admin workspace shell
src/main/java/manager/ManagerFrame.java - Orders · Order entry and item selection screen
src/main/java/cashier/OrdersPanel.java - Payments · Payment capture and completion screen
src/main/java/cashier/PaymentsPanel.java - Receipt · Receipt display or print dialog
src/main/java/cashier/ReceiptDialog.java - Dashboard · Manager landing and summary screen
src/main/java/manager/DashboardPanel.java - Inventory · Inventory maintenance screen
src/main/java/manager/InventoryPanel.java - Menu items · Menu composition and item management screen
src/main/java/manager/MenuItemPanel.java - Food waste · Waste tracking screen
src/main/java/manager/FoodWastePanel.java - Reports · Operational reporting screen
src/main/java/manager/ReportsPanel.java - Users · User administration screen
src/main/java/manager/UserManagementPanel.java - Ingredient dialog · Dialog for editing menu ingredients
src/main/java/manager/IngredientDialog.java - Date picker · Dialog for date selection and filtering
src/main/java/manager/DatePickerDialog.java
Application
Authentication, cashier, and manager services plus core domain objects
- Auth service · Validates credentials and establishes role-based access
src/main/java/user/AuthenticationService.java - Permission service · Resolves and enforces permissions by role
src/main/java/user/PermissionService.java - Order service · Builds and validates orders
src/main/java/cashier/OrderService.java - Payment service · Processes payments and finalizes sales
src/main/java/cashier/PaymentService.java - Inventory service · Maintains inventory state and rules
src/main/java/manager/InventoryService.java - Menu service · Manages menu items and ingredient links
src/main/java/manager/MenuItemService.java - Waste service · Records food waste transactions
src/main/java/manager/FoodWasteService.java - Report service · Aggregates operational and financial data
src/main/java/manager/ReportService.java - User service · Manages user administration workflows
src/main/java/manager/UserManagementService.java - Order · Customer order aggregate
src/main/java/cashier/Order.java - Payment · Payment record and method details
src/main/java/cashier/Payment.java - Inventory item · Stock item and quantity state
src/main/java/manager/InventoryItem.java - Menu ingredient · Links menu items to ingredients
src/main/java/manager/MenuItemIngredient.java - Food waste · Waste entry and quantity tracking
src/main/java/manager/FoodWaste.java
Persistence
Shared database access and DB-mapped records
- Database · Shared database connection utility
src/main/java/user/DatabaseConnection.java - Db user · Database-facing user record
src/main/java/user/DbUser.java - Db order · Database-facing order record
src/main/java/cashier/DbOrder.java - Db payment · Database-facing payment record
src/main/java/cashier/DbPayment.java - Db menu item · Database-facing menu item record
src/main/java/cashier/DbMenuItem.java
Connections 43
- App launch → Login: opens · Application startup shows the login screen
- Login → Auth service: authenticates · Login delegates credential checks to the authentication service
- Auth service → Permission service: resolves role · Authentication and authorization work together to route users
- Login → Cashier: cashier access · Cashier users enter the cashier workspace
- Login → Manager: manager access · Manager or admin users enter the management workspace
- Cashier → Orders: contains · Cashier workspace hosts order entry
- Cashier → Payments: contains · Cashier workspace hosts payment processing
- Cashier → Receipt: shows · Receipts are presented from the cashier flow
- Orders → Order service: uses · Order screen calls order business logic
- Payments → Payment service: uses · Payment screen calls payment business logic
- Order service → Order: builds · Order service creates and validates order aggregates
- Order service → Db order: persists · Orders are stored through DB-mapped records
- Payment service → Payment: creates · Payment service creates payment records
- Payment service → Db payment: persists · Payments are stored through DB-mapped records
- Payment service → Receipt: prints receipt · Completed payments can produce a receipt
- Manager → Dashboard: contains · Management workspace starts with the dashboard
- Manager → Inventory: contains · Management workspace hosts inventory control
- Manager → Menu items: contains · Management workspace hosts menu maintenance
- Manager → Food waste: contains · Management workspace hosts waste tracking
- Manager → Reports: contains · Management workspace hosts reporting
- Manager → Users: contains · Management workspace hosts user administration
- Inventory → Inventory service: uses · Inventory screen delegates to inventory workflows
- Menu items → Menu service: uses · Menu screen delegates to menu workflows
- Food waste → Waste service: uses · Waste screen delegates to waste workflows
- Reports → Report service: uses · Reports screen requests aggregated summaries
- Users → User service: uses · User administration delegates to user management service
- Menu items → Ingredient dialog: edits · Ingredient dialog supports menu composition editing
- Reports → Date picker: filters · Date picker supports report range selection
- Inventory service → Inventory item: manages · Inventory service operates on inventory items
- Menu service → Menu ingredient: manages · Menu service operates on ingredient links
- Waste service → Food waste: records · Waste service operates on waste entries
- Auth service → Database: queries · Authentication depends on the shared database connection
- Order service → Database: queries · Order workflow reads and writes through the database connection
- Payment service → Database: queries · Payment workflow reads and writes through the database connection
- Inventory service → Database: queries · Inventory workflow reads and writes through the database connection
- Menu service → Database: queries · Menu workflow reads and writes through the database connection
- Waste service → Database: queries · Waste workflow reads and writes through the database connection
- Report service → Database: aggregates · Reports are derived from persisted operational data
- User service → Database: queries · User management reads and writes through the database connection
- Database → Db user: maps · Connection supports user row access
- Database → Db menu item: maps · Connection supports menu item row access
- Database → Db order: maps · Connection supports order row access
- Database → Db payment: maps · Connection supports payment row access