108 lines
2.1 KiB
Markdown
108 lines
2.1 KiB
Markdown
# Kiến Trúc F&B Engine
|
|
|
|
> Tài liệu kiến trúc cho F&B Engine.
|
|
|
|
## Tổng Quan Kiến Trúc
|
|
|
|
```mermaid
|
|
graph TB
|
|
subgraph "Tầng API"
|
|
TC[TableController]
|
|
SC[SessionController]
|
|
KC[KitchenController]
|
|
end
|
|
|
|
subgraph "Tầng Domain"
|
|
T[Table]
|
|
S[Session]
|
|
KT[KitchenTicket]
|
|
end
|
|
|
|
subgraph "Infrastructure"
|
|
DB[(PostgreSQL)]
|
|
EB[Event Bus]
|
|
end
|
|
|
|
TC --> T
|
|
SC --> S
|
|
KC --> KT
|
|
S --> T
|
|
KT --> S
|
|
T --> DB
|
|
KT --> EB
|
|
|
|
style T fill:#50c878,stroke:#2d8659,color:#fff
|
|
style S fill:#3498db,stroke:#2980b9,color:#fff
|
|
```
|
|
|
|
## Database Schema
|
|
|
|
```mermaid
|
|
erDiagram
|
|
tables {
|
|
uuid id PK
|
|
uuid shop_id FK
|
|
varchar table_number
|
|
int capacity
|
|
varchar zone
|
|
varchar status
|
|
}
|
|
|
|
sessions {
|
|
uuid id PK
|
|
uuid table_id FK
|
|
timestamp started_at
|
|
timestamp closed_at
|
|
int guest_count
|
|
varchar status
|
|
}
|
|
|
|
kitchen_tickets {
|
|
uuid id PK
|
|
uuid session_id FK
|
|
uuid order_item_id FK
|
|
varchar station
|
|
int priority
|
|
varchar status
|
|
timestamp created_at
|
|
}
|
|
|
|
tables ||--o{ sessions : has
|
|
sessions ||--o{ kitchen_tickets : contains
|
|
```
|
|
|
|
## Luồng Hiển Thị Bếp
|
|
|
|
```mermaid
|
|
sequenceDiagram
|
|
participant Order as Order Service
|
|
participant FnB as F&B Engine
|
|
participant KDS as Màn Hình Bếp
|
|
|
|
Order->>FnB: KitchenTicketCreated Event
|
|
FnB->>FnB: Lưu Phiếu
|
|
KDS->>FnB: Lấy Phiếu Chờ
|
|
FnB-->>KDS: Danh Sách Phiếu
|
|
|
|
Note over KDS: Đầu bếp chuẩn bị đơn
|
|
|
|
KDS->>FnB: Cập Nhật Trạng Thái (Xong)
|
|
FnB->>Order: TicketCompleted Event
|
|
```
|
|
|
|
## Table State Machine
|
|
|
|
```mermaid
|
|
stateDiagram-v2
|
|
[*] --> Available
|
|
Available --> Occupied: Mở Phiên
|
|
Occupied --> Available: Đóng Phiên
|
|
Available --> Reserved: Đặt Trước
|
|
Reserved --> Occupied: Khách Đến
|
|
Reserved --> Available: Hủy
|
|
```
|
|
|
|
## Tài Nguyên
|
|
|
|
- [Kiến Trúc Đa Ngành Hàng](../../../../docs/vi/architecture/multi-vertical-architecture.md)
|