ductai05 avatar
Smart Restaurant

Smart Restaurant

A comprehensive multi-tenant restaurant management SaaS with real-time state synchronization, KDS, and secure online payments.

December 1, 2025 → January 31, 2026

Introduction

Smart Restaurant is a modern, comprehensive restaurant management system designed to meet the digitization and automation needs of the contemporary food service industry. Built with a robust Client-Server architecture and a microservices-ready approach, it provides a seamless experience for customers, staff, and management alike.

Summary (Project Highlights)
  • Multi-tenant Architecture: Isolated data management for multiple restaurants on a single SaaS platform.
  • Real-time Synchronization: Instant updates via WebSockets for the Kitchen Display System (KDS) and order tracking.
  • VNPAY Integration: Secure online payment processing using Instant Payment Notification (IPN).
  • Responsive UI/UX: Mobile-first design utilizing TailwindCSS, Radix UI, and Zustand for state management.

Technical Architecture

The system is designed with a clear separation of concerns, ensuring high maintainability and scalability.

Note (Technology Stack)
  • Frontend: Next.js 14 (App Router), React 18, TailwindCSS, Zustand, Radix UI.
  • Backend: NestJS 10, TypeScript, Passport + JWT for Authentication.
  • Database: PostgreSQL hosted on Supabase with Row-Level Security (RLS).
  • Deployment: Vercel (Serverless Functions) with automated CI/CD pipelines.

Core Modules

The backend is modularized to handle complex business logic efficiently:

  1. Identity & Auth: Manages JWT-based authentication and Role-Based Access Control (RBAC) for Super Admins, Admins, Kitchen staff, and Waiters.
  2. Catalog & Operations: Handles menus, dynamic modifier groups (sizes, toppings), table management (QR code generation), and the smart cart.
  3. Finance & Analytics: Processes bills, integrates with the VNPAY gateway, and generates real-time reports and revenue dashboards.
  4. Realtime Gateway: Uses Socket.io to emit events instantly to the Kitchen Display System when orders are placed or updated.

Database Design (EER Schema)

The database strictly adheres to the Third Normal Form (3NF) to ensure data integrity and performance.

Example: RLS Policy for Multi-tenancy
-- Ensuring users can only access data within their tenant
CREATE POLICY "tenant_isolation_policy" ON orders
FOR ALL
USING (tenant_id = current_setting('app.current_tenant_id')::uuid);

Payment Integration (VNPAY)

Integrating a payment gateway requires a highly secure and reliable flow. We implemented the standard IPN (Instant Payment Notification) process.

Warning (Security Measure)

The payment flow relies on server-to-server communication (IPN) rather than the client-side redirect URL to confirm payment success. This prevents vulnerabilities where a user might close the browser before the redirect completes. The backend verifies the HMAC-SHA512 signature before updating the bill status.


User Interfaces

We prioritized a Mobile-first approach, acknowledging that most customers will browse the menu and order via their smartphones using QR codes.

Tip (Optimization)

We used Anti-aliased Blur Pooling and Attention Pooling concepts from modern CV to ensure our image uploads (menu items) remain crisp and clear across all device resolutions without causing layout shifts (using skeleton screens).