A real-time kitchen order management system built with SvelteKit frontend and NestJS backend, featuring PostgreSQL database and RabbitMQ integration for order processing. Part 2 of a two-part application for an Ordering and Order Management system.
View Part 1 here.
- Real-time Order Management: View and manage kitchen orders with live updates via Server-Sent Events (SSE)
- Order Status Tracking: Track orders through Pending β Received β Completed states
- RabbitMQ Integration: Receive new orders and send status updates via message queues
- Persistent Storage: Orders stored in PostgreSQL database with full data persistence
- Server-Side Rendering: Fast initial page loads with SvelteKit SSR
- Responsive UI: Modern, clean interface with smooth animations
- Server-Sent Events: Real-time updates without polling - instant order notifications
- Order Processing: Process and complete orders with one-click buttons
- Order Visibility: Hide completed orders from view while keeping them in database
- Type Safety: Full TypeScript implementation across frontend and backend
- Docker Support: Complete containerized deployment with Docker Compose
- SvelteKit - Modern web framework with SSR
- TypeScript - Type-safe JavaScript
- Node.js - JavaScript runtime
- NestJS - Enterprise-grade Node.js framework
- TypeORM - TypeScript ORM for database operations
- TypeScript - Type-safe JavaScript
- PostgreSQL - Robust relational database
- Docker - Containerized database deployment
- RabbitMQ - Message broker for order processing
- Docker - Containerized message broker
- Docker - Container platform
- Docker Compose - Multi-container orchestration
- Framework: SvelteKit with Server-Side Rendering (SSR)
- Features: Server-Sent Events (SSE), smooth transitions, responsive layout, real-time updates
- Port: 3001
- API Integration: Direct HTTP calls to NestJS backend with proxy support
- Real-time: EventSource API for instant order updates via SSE
- Framework: NestJS with TypeScript decorators and dependency injection
- Database: PostgreSQL with TypeORM for entity management
- Message Queue: RabbitMQ integration with amqplib
- Features: REST API, Server-Sent Events, order management, real-time updates, data persistence
- Architecture: Modular design with controllers, services, entities, and modules
- Port: 3000
- SSE: RxJS-based event streaming for real-time client updates
- Engine: PostgreSQL 15 with Alpine Linux
- ORM: TypeORM with entity-based models
- Features: JSONB support for complex order data, auto-generated migrations
- Persistence: Docker volume for data persistence
- Port: 5432
- Broker: RabbitMQ with management interface
- Queues:
orders(incoming),orderStatus(outgoing) - Features: Message acknowledgment, error handling, connection resilience
- Ports: 5672 (AMQP), 15672 (Management UI)
# Clone the repository
git clone <repository-url>
cd kitchen-dashboard
# Start all services (PostgreSQL, RabbitMQ, NestJS backend, SvelteKit frontend)
docker-compose up -d --build
# Check service status
docker-compose ps
# View logs
docker-compose logs -f# Prerequisites: PostgreSQL and RabbitMQ running locally
# Clone the repository
git clone <repository-url>
cd kitchen-dashboard
# Start NestJS backend (runs on port 3000)
cd nestjs-backend
npm install
npm run start:dev
# Start SvelteKit frontend (runs on port 3001)
cd ../frontend
npm install
npm run dev# Connect to database
docker exec -it kitchen-postgres psql -U kitchen_user -d kitchen_db
# View all orders
docker exec kitchen-postgres psql -U kitchen_user -d kitchen_db -c "SELECT * FROM orders;"
# Clear all data and reset ID sequence
docker exec kitchen-postgres psql -U kitchen_user -d kitchen_db -c "DELETE FROM orders; ALTER SEQUENCE orders_id_seq RESTART WITH 1;"
# Backup database
docker exec kitchen-postgres pg_dump -U kitchen_user kitchen_db > backup.sqlpgAdmin is included for easy database management through a web interface:
- Access pgAdmin: Navigate to http://localhost:5050
- Login: Use
admin@kitchen.com/admin123 - Add Server: Right-click "Servers" β "Register" β "Server"
- Server Configuration:
- Name: Kitchen Database
- Connection Tab:
- Host:
postgres(Docker service name) - Port:
5432 - Database:
kitchen_db - Username:
kitchen_user - Password:
kitchen_pass
- Host:
-- Orders table structure
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
items JSONB NOT NULL, -- {"name": "Coffee", "quantity": 2}
status orders_status_enum DEFAULT 'Pending', -- Pending/Received/Completed
"isVisible" BOOLEAN DEFAULT true, -- Controls order visibility
"createdAt" TIMESTAMP DEFAULT now(),
"updatedAt" TIMESTAMP DEFAULT now()
);RabbitMQ is automatically started with Docker Compose:
# RabbitMQ is included in docker-compose.yml
docker-compose up -dTo connect to an external RabbitMQ server:
# Set environment variable
export RABBITMQ_URL=amqp://username:password@your-rabbitmq-host:5672
# Or update docker-compose.yml environment section
RABBITMQ_URL: amqp://username:password@your-rabbitmq-host:5672// Incoming orders (to 'orders' queue)
{
"name": "Cappuccino",
"quantity": 2
}
// Or new format
{
"items": {
"name": "Cappuccino",
"quantity": 2
}
}
// Outgoing status updates (to 'orderStatus' queue)
{
"orderId": 123,
"status": "Completed"
}# Application URLs
Frontend: http://localhost:3001
Backend API: http://localhost:3000
Database: localhost:5432 (kitchen_user/kitchen_pass)
RabbitMQ AMQP: localhost:5672
RabbitMQ Web UI: http://localhost:15672 (guest/guest)
pgAdmin: http://localhost:5050 (admin@kitchen.com/admin123)# Get all orders
GET http://localhost:3000/api/orders
# Server-Sent Events stream for real-time updates
GET http://localhost:3000/api/orders/stream
Accept: text/event-stream
# Create new order
POST http://localhost:3000/api/orders
Content-Type: application/json
{
"items": {
"name": "Latte",
"quantity": 1
}
}
# Update order status
PATCH http://localhost:3000/api/orders/123
Content-Type: application/json
{
"status": "Completed"
}
# Hide order from view
PATCH http://localhost:3000/api/orders/123/hideThe application uses Server-Sent Events (SSE) for real-time order updates, replacing traditional polling for better performance and instant notifications.
- Frontend connects:
EventSourceconnects to/api/orders/stream - Backend streams: NestJS
@Ssedecorator with RxJS Observable - Real-time updates: Order changes broadcast instantly to all connected clients
// Connection established
{ "type": "connected" }
// New order created
{ "type": "order_created", "order": { "id": 1, "items": {...}, "status": "Pending" } }
// Order status updated
{ "type": "order_updated", "order": { "id": 1, "items": {...}, "status": "Completed" } }
// Order hidden from view
{ "type": "order_hidden", "order": { "id": 1, ... } }kitchen-dashboard/
βββ docker-compose.yml # Multi-container orchestration
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore rules (excludes .env)
βββ frontend/ # SvelteKit application
β βββ src/
β β βββ lib/
β β β βββ api.ts # API client functions
β β β βββ OrderList.svelte
β β β βββ stores/
β β β βββ orders.ts # Svelte stores for state management
β β βββ routes/
β β β βββ +page.svelte # Main dashboard (pending orders)
β β β βββ +layout.server.ts # SSR data loading
β β β βββ completed/
β β β βββ +page.svelte # Completed orders page
β β βββ hooks.server.ts # SSR API proxy
β βββ Dockerfile
βββ nestjs-backend/ # NestJS application
βββ src/
β βββ entities/
β β βββ order.entity.ts # Database models
β βββ orders/
β β βββ orders.controller.ts # API endpoints + SSE stream
β β βββ order-creation.service.ts # Order creation logic
β β βββ order-retrieval.service.ts # Order fetching logic
β β βββ order-update.service.ts # Order status updates
β β βββ order-stream.service.ts # SSE event streaming
β β βββ order-visibility.service.ts # Order hiding logic
β β βββ orders.module.ts # NestJS module
β βββ rabbitmq/
β β βββ rabbitmq.service.ts # Message queue
β βββ app.module.ts # Root module
β βββ main.ts # Application entry
βββ Dockerfile
# Create .env file from template
cp .env.example .env
# Edit .env with your configuration
# Note: .env is gitignored for security
# Backend environment variables
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=kitchen_user
DB_PASSWORD=kitchen_pass
DB_NAME=kitchen_db
RABBITMQ_URL=amqp://localhost:5672
NODE_ENV=development
BACKEND_PORT=3000
FRONTEND_PORT=3001# Test order creation via API
curl -X POST http://localhost:3000/api/orders \
-H "Content-Type: application/json" \
-d '{"items": {"name": "Test Coffee", "quantity": 1}}'
# Test order status update
curl -X PATCH http://localhost:3000/api/orders/1 \
-H "Content-Type: application/json" \
-d '{"status": "Completed"}'
# Test order hiding
curl -X PATCH http://localhost:3000/api/orders/1/hide
# Test SSE stream (in separate terminal)
curl -N -H "Accept: text/event-stream" http://localhost:3000/api/orders/stream
# Test via RabbitMQ (send message to orders queue)
# Use RabbitMQ Management UI at http://localhost:15672# Check order count
docker exec kitchen-postgres psql -U kitchen_user -d kitchen_db -c "SELECT COUNT(*) FROM orders;"
# View recent orders
docker exec kitchen-postgres psql -U kitchen_user -d kitchen_db -c "SELECT * FROM orders ORDER BY \"createdAt\" DESC LIMIT 5;"
# Check order visibility
docker exec kitchen-postgres psql -U kitchen_user -d kitchen_db -c "SELECT id, items->>'name' as name, status, \"isVisible\" FROM orders;"# Access pgAdmin for visual database management
# 1. Open http://localhost:5050
# 2. Login with admin@kitchen.com / admin123
# 3. Connect to Kitchen Database server
# 4. Navigate to: Servers β Kitchen Database β Databases β kitchen_db β Schemas β public β Tables β orders
# 5. Right-click orders table β "View/Edit Data" β "All Rows"Database Connection Issues:
# Check if PostgreSQL is running
docker ps | grep postgres
# View database logs
docker logs kitchen-postgres
# Check pgAdmin logs
docker logs kitchen-pgadmin
# Reset database (nuclear option)
docker-compose down -v && docker-compose up -dRabbitMQ Connection Issues:
# Check RabbitMQ status
docker logs kitchen-rabbitmq
# Verify queues exist
# Visit http://localhost:15672 and check Queues tabFrontend/Backend Communication:
# Check if backend is responding
curl http://localhost:3000/api/orders
# Check backend logs
docker logs kitchen-nestjs-backend
# Check frontend logs
docker logs kitchen-frontend# Check what's using ports
netstat -tulpn | grep -E "(3000|3001|5432|5672|15672|5050)"
# Stop conflicting services
docker-compose down# Build for production
docker-compose -f docker-compose.prod.yml up -d --build
# Or build individual services
docker build -t kitchen-frontend ./frontend
docker build -t kitchen-backend ./nestjs-backend# docker-compose.prod.yml example
environment:
- NODE_ENV=production
- DB_HOST=your-production-db
- RABBITMQ_URL=amqp://your-production-rabbitmq- Real-time order management with Server-Sent Events (SSE)
- PostgreSQL data persistence
- RabbitMQ message processing
- Server-side rendering (SSR)
- Docker containerization
- TypeScript throughout
- Real-time updates without polling
- Order visibility management (hide/show)
- Separated page views (pending vs completed orders)
- Environment variable configuration with
.env.example - Modular NestJS architecture with service separation
- Svelte stores for state management
- User authentication
- Order history and analytics
- Push notifications
- Multi-restaurant support
- Order filtering and search
- Performance monitoring
- Automated testing suite
This project is licensed under the MIT License.
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
Happy cooking! π¨βπ³π©βπ³