RESTAURANT MODULES ANALYSIS
Documentation for Sessions
Restaurant Management Modules - Analysis & Enhancement Recommendations
Session: 16.1
Date: December 28, 2025
Focus: Analyze generated restaurant modules and propose database integration enhancements
📦 Current Module Structure
Generated Modules (8 total)
Located in modules/business/:
- restaurant-management-customer-management
- restaurant-management-inventory-item-management
- restaurant-management-kitchen-ticket-management
- restaurant-management-loyalty-transaction-management
- restaurant-management-menu-item-management
- restaurant-management-order-management
- restaurant-management-reservation-management
- restaurant-management-table-management
✅ What's Already Excellent
1. Proper Module Structure
Each module follows best practices:
- ✅
BrowserModuleContractimplementation - ✅ Separate
.module.tsand.manifest.ts - ✅ CRUD actions (create, list, get, update, delete)
- ✅ Embeddable components (list, card, form, detail)
- ✅ Proper models with TypeScript interfaces
- ✅ Event bus integration
- ✅ Logger integration
- ✅ Permission-based actions
2. Component Architecture
- ✅ Standalone components
- ✅ Separate .ts/.html/.scss files
- ✅ OnPush change detection (assumed)
- ✅ Proper inputs/outputs
3. Action System
- ✅ Observable-based actions
- ✅ Execution context tracking
- ✅ Cross-module callable
- ✅ Permission checks
🔍 What's Missing: Database Integration
Current State: No Database Sync
The modules have:
- ✅ Models defined
- ✅ Actions defined
- ❌ No storage integration
- ❌ No MongoDB sync
- ❌ No flash-persistence
- ❌ No backend API calls
Example: CustomerManagementModule
// Current: Actions defined but no implementation
createCustomerAction.execute(params, context)
// → Returns Observable<void>
// → No actual database operation
// What's needed:
createCustomerAction.execute(params, context)
// → Should call backend API
// → Should update flash-persistence
// → Should sync to MongoDB
// → Should emit events for real-time updates
🚀 Recommended Enhancements
Enhancement 1: Flash-Persistence Integration
Add to each module's actions:
// In create-customer.action.ts
import { autoFlashState } from '@storage-system';
export class CreateCustomerAction {
// Add flash state for immediate local persistence
private readonly customers = autoFlashState<Customer[]>(
'restaurant:customers',
[],
{
collection: 'restaurant-management',
priority: 'high'
}
);
execute(params: any, context: ExecutionContext): Observable<Customer> {
const newCustomer: Customer = {
id: `customer-${Date.now()}`,
...params,
createdAt: new Date(),
updatedAt: new Date()
};
// 1. Update local flash state (immediate)
this.customers.update(list => [...list, newCustomer]);
// 2. Call backend API (async)
return this.http.post<Customer>('/api/customers', newCustomer).pipe(
tap(savedCustomer => {
// 3. Update with server response
this.customers.update(list =>
list.map(c => c.id === newCustomer.id ? savedCustomer : c)
);
}),
// 4. Emit event for real-time sync
tap(savedCustomer => {
this.eventBus.emit({
type: 'customer:created',
payload: savedCustomer
});
})
);
}
}
Enhancement 2: Backend API Integration
Add to backend-api:
// apis/backend-api/src/app/restaurant/
├── controllers/
│ ├── customers.controller.ts
│ ├── orders.controller.ts
│ ├── menu-items.controller.ts
│ └── reservations.controller.ts
├── services/
│ ├── customers.service.ts
│ └── ...
└── schemas/
├── customer.schema.ts
└── ...
Example Controller:
@Controller('api/customers')
export class CustomersController {
constructor(private readonly customersService: CustomersService) {}
@Post()
async create(@Body() dto: CreateCustomerDto) {
return this.customersService.create(dto);
}
@Get()
async list(@Query() query: ListQueryDto) {
return this.customersService.list(query);
}
@Get(':id')
async get(@Param('id') id: string) {
return this.customersService.get(id);
}
@Put(':id')
async update(@Param('id') id: string, @Body() dto: UpdateCustomerDto) {
return this.customersService.update(id, dto);
}
@Delete(':id')
async delete(@Param('id') id: string) {
return this.customersService.delete(id);
}
}
Enhancement 3: Real-Time Sync
Use existing RealtimeSyncService:
// In each module
export class CustomerManagementModule {
private readonly realtimeSync = inject(RealtimeSyncService);
initialize(): Observable<void> {
// Subscribe to real-time updates
this.realtimeSync.onDocumentChange((event) => {
if (event.collection === 'customers') {
// Update local flash state
this.customers.set(event.data);
}
});
return of(undefined);
}
}
Enhancement 4: Offline-First with Repository Pattern
Use existing OfflineFirstRepository:
import { OfflineFirstRepository } from '@storage-system';
export class CustomerRepository extends OfflineFirstRepository<Customer> {
constructor() {
super({
collectionName: 'customers',
syncEndpoint: '/api/customers',
conflictResolution: 'server-wins'
});
}
}
// In actions
execute(params: any): Observable<Customer> {
return this.customerRepo.create(params);
// → Saves locally immediately
// → Syncs to backend when online
// → Handles conflicts automatically
}
🎯 Proposed Implementation Plan
Phase 1: Add Flash-Persistence to Actions
For each module (8 modules × 5 actions = 40 actions):
- Add
autoFlashStatefor entity collection - Update action execute methods to use flash state
- Emit events after operations
Estimated: 2-3 hours
Phase 2: Generate Backend APIs
Use existing BackendAPIGeneratorService:
- Already created in Session 15
- Located:
apis/backend-ai-api/src/app/workflow/generators/backend-api-generator.service.ts - Can generate controllers, services, DTOs, schemas
Action: Call backendGenerator.generateBackendForModule(moduleSpec) for each restaurant module
Estimated: 1 hour (automated)
Phase 3: Integrate Repository Pattern
For each module:
- Create repository extending
OfflineFirstRepository - Update actions to use repository
- Configure sync endpoints
Estimated: 3-4 hours
Phase 4: Real-Time Collaboration
For each module:
- Subscribe to
RealtimeSyncServiceevents - Handle document changes
- Update local state
- Emit UI updates
Estimated: 2 hours
💡 Smart Recommendations
1. Auto-Generate Database Integration
Enhance ModuleCodeGeneratorService to automatically include:
// When generating module, also generate:
├── repositories/
│ └── {entity}.repository.ts // OfflineFirstRepository
├── services/
│ └── {entity}.service.ts // Business logic
└── actions/
└── {action}.action.ts // With flash-persistence
2. Universal Storage Configuration
Add to module manifest:
{
"storage": {
"enabled": true,
"collections": [
{
"name": "customers",
"syncEndpoint": "/api/customers",
"offlineFirst": true,
"conflictResolution": "server-wins"
}
]
}
}
3. Platform-Agnostic Data Layer
Use existing patterns from storage-system:
// Module actions should be platform-agnostic
execute(params: any): Observable<Customer> {
// Works in:
// - Angular (browser)
// - Flutter (mobile)
// - Node.js (server)
return this.repository.create(params);
}
🔧 Immediate Action Items
Must Do Now:
Add universeSlug to Navigation
- ✅ DONE: Routes now use
/space/{spaceSlug}/universe/{universeSlug}/vibe - ✅ DONE: Removed query params for universeId
- ✅ DONE: Routes now use
Export IntelligentInput Properly
- ✅ DONE: Exports added to universe-map
Fix Compilation Errors
- ✅ DONE: All TypeScript errors resolved
Should Do Next (Session 16.2):
Add Flash-Persistence to Restaurant Modules
- Enhance action implementations
- Add autoFlashState to each module
- Immediate local persistence
Generate Backend APIs
- Use existing BackendAPIGeneratorService
- Generate for all 8 restaurant modules
- Deploy to backend-api
Test Complete Flow
- Vibe → Universe → Workbench
- With clean slug-based routes
- With database persistence
📊 Restaurant Modules Quality Assessment
| Module | Structure | Actions | Components | DB Integration |
|---|---|---|---|---|
| Customer Management | ✅ Excellent | ✅ Complete | ✅ 4 components | ❌ Missing |
| Order Management | ✅ Excellent | ✅ Complete | ✅ 4 components | ❌ Missing |
| Menu Item Management | ✅ Excellent | ✅ Complete | ✅ 4 components | ❌ Missing |
| Reservation Management | ✅ Excellent | ✅ Complete | ✅ 4 components | ❌ Missing |
| Table Management | ✅ Excellent | ✅ Complete | ✅ 4 components | ❌ Missing |
| Kitchen Ticket Management | ✅ Excellent | ✅ Complete | ✅ 4 components | ❌ Missing |
| Inventory Item Management | ✅ Excellent | ✅ Complete | ✅ 4 components | ❌ Missing |
| Loyalty Transaction Management | ✅ Excellent | ✅ Complete | ✅ 4 components | ❌ Missing |
Overall: Structure is excellent, database integration is the missing piece.
🎯 Next Session Goals
- Add flash-persistence to all restaurant module actions
- Generate backend APIs using existing generator
- Test complete CRUD flow with database
- Verify real-time sync works
- Test offline-first capabilities
Estimated Time: 6-8 hours for complete database integration across all 8 modules