# F&B Engine

> Table management, sessions, and kitchen display for Food & Beverage operations.

## Overview

F&B Engine handles the unique requirements of restaurants and cafes: table layouts, dining sessions, and kitchen display system (KDS) for order preparation.

### Key Features

- **Table Management** - Floor plan, table status, capacity
- **Session Tracking** - Guest sessions per table
- **Kitchen Display System** - Order tickets to kitchen stations
- **Table Operations** - Merge, split, transfer tables

## Architecture Context

```mermaid
graph LR
    ORDER["📝 Order Service"] --> FNB["🍳 F&B Engine"]
    FNB --> INVENTORY["🏭 Inventory Service"]
    POS["POS"] --> FNB
    KDS["Kitchen Display"] --> FNB
    
    style FNB fill:#f39c12,stroke:#d68910,color:#fff
```

## Quick Start

```bash
cd services/fnb-engine-net
cp .env.example .env
dotnet run --project src/FnbEngine.API
```

## API Endpoints

### Table Management

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/v1/tables` | List tables by shop |
| `POST` | `/api/v1/tables` | Create table |
| `PUT` | `/api/v1/tables/{id}` | Update table |
| `PATCH` | `/api/v1/tables/{id}/status` | Change status |
| `POST` | `/api/v1/tables/merge` | Merge tables |
| `POST` | `/api/v1/tables/split` | Split merged tables |

### Sessions

| Method | Endpoint | Description |
|--------|----------|-------------|
| `POST` | `/api/v1/sessions` | Open session |
| `GET` | `/api/v1/sessions/{id}` | Get session details |
| `POST` | `/api/v1/sessions/{id}/close` | Close session |
| `POST` | `/api/v1/sessions/{id}/transfer` | Transfer to another table |

### Kitchen Display

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/v1/kitchen/tickets` | List pending tickets |
| `PATCH` | `/api/v1/kitchen/tickets/{id}/status` | Update ticket status |
| `GET` | `/api/v1/kitchen/stations` | List kitchen stations |

## Domain Model

### Table

```csharp
public class Table : Entity, IAggregateRoot
{
    public Guid ShopId { get; private set; }
    public string TableNumber { get; private set; }
    public int Capacity { get; private set; }
    public string Zone { get; private set; }
    public TableStatus Status { get; private set; } // Available, Occupied, Reserved
}
```

### Session

```csharp
public class Session : Entity, IAggregateRoot
{
    public Guid TableId { get; private set; }
    public DateTime StartedAt { get; private set; }
    public DateTime? ClosedAt { get; private set; }
    public int GuestCount { get; private set; }
    public SessionStatus Status { get; private set; }
}
```

### KitchenTicket

```csharp
public class KitchenTicket : Entity
{
    public Guid SessionId { get; private set; }
    public Guid OrderItemId { get; private set; }
    public string Station { get; private set; } // Bar, Kitchen, Grill
    public int Priority { get; private set; }
    public TicketStatus Status { get; private set; } // Pending, InProgress, Done
}
```

## Related Services

- [Order Service](../../order-service-net/docs/en/README.md) - Uses FnbStrategy
- [Inventory Service](../../inventory-service-net/docs/en/README.md) - Ingredient deduction
- [Catalog Service](../../catalog-service-net/docs/en/README.md) - Menu items

## License

Proprietary - GoodGo Platform
