# KDSAI - Restaurant Monitoring & Anomaly Detection

An LLM-driven monitoring system that helps restaurants detect ad-hoc operational and financial anomalies (POS, KDS, inventory, etc.) from manager-written natural language prompts.

## Project Structure

- **[backend/](backend/)** - .NET Aspire application with API service, worker, and CLI
- **[Front/](Front/)** - Laravel web application with Tailwind CSS frontend
- **[docs/](docs/)** - System architecture documentation and flow diagrams

## Key Concepts

- **Non-technical authoring**: Managers describe monitors in natural language
- **Ad-hoc detection**: System detects issues not explicitly pre-modeled
- **Per-store baselines**: Anomalies judged relative to store's own history
- **Two processes**: Authoring (create MonitorSpec) and Runtime (execute + alert)

## Core Artifacts

- **MonitorSpec**: Versioned, executable monitor definitions
- **Capabilities Manifest**: Per-restaurant data catalog (entities/tables/joins/units)
- **KPI Catalog**: KPI definitions and targets from restaurant manuals
- **Doc Index (RAG)**: Searchable documentation for context

## Agent Architecture

- **Orchestrator**: Coordinates agents, persists MonitorSpec
- **Spec Builder**: Manager-facing, converts prompts to MonitorSpec
- **KB/Semantic Agent**: Answers data availability queries
- **Data Access Agent**: Executes read-only queries via MCP
- **Runtime Detector**: Executes MonitorSpec as adaptive runbook
- **Critic/Verifier**: Validates conclusions before alerting
- **Alert Emitter**: Dedupes and sends alerts

See [docs/README.md](docs/README.md) for detailed architecture diagrams.

## Testing

- Run live tests when changing the logic they cover or at the end of the task.
