Natural-Language Analytics for Restaurant Operations
Ask a Question, Get the Right Chart
My Role
- Model reads the question; code does calculations
- Validate parameters; clarify instead of guessing
- Chart type chosen by query intent
Approach at a Glance
Details- 1Query Understanding
- 2Validation and Edge Cases
- 3Metric Calculation Engine
- 4External Context: Weather and Events
- 5Visualization Generation
- 6API Service
Executive Summary
The backend for an AI analytics dashboard used by restaurant operations teams. Instead of building reports, a manager asks in plain English, for example "How did bar revenue compare with last month across our sites?" or "Which sessions are under budget this week?". They get back the numbers and a chart chosen for the question.
The API I designed takes a question through four stages:
- Understanding: the query is classified by intent, mapped onto structured parameters and checked for completeness.
- Calculation: a metric engine computes revenue, covers and other metrics with filters, aggregations and comparisons across periods, locations and budget.
- Context: weather and local events are brought into the analysis, because both move restaurant demand.
- Visualization: the system picks a chart type and generates the spec, with titles, labels and annotations, for the frontend to render.
The system understood about 0.85 of questions correctly and covered more than 50 restaurants across 2 countries. I was the architect and tech lead, with one or two engineers, from May to July 2025. The backend API was delivered to the client.
Client Profile
The client runs analytics for restaurant operations across more than 50 restaurants in two countries. Operations managers need answers about revenue, covers, revenue centres, categories and sessions, compared against last week, last year, another site or the budget. Each new question used to mean a new report or a request to an analyst.
Answering questions in natural language over this data is harder than it looks:
- Domain language is ambiguous. "Covers", "sessions" and "revenue centres" have specific meanings, and the same question can be phrased in many ways.
- Questions are often incomplete. "How did we do last week?" doesn't say which metric, which site or what to compare with.
- The numbers have to be right. A chart from an LLM's guess at a calculation is worse than no chart.
- Context explains performance. A rainy Saturday or a local event can explain a dip or a spike better than any internal metric.
- The chart has to fit the question. A comparison, a trend and a breakdown each need a different visual.
Technical Approach
-
Query Understanding – Each question goes through intent classification, which decides what kind of analysis it is: a trend, a comparison, a breakdown and so on. It is then translated into structured parameters: metric, dimensions, filters, time periods and locations. The model turns language into parameters, and the calculations are done by code. Questions were understood correctly about 85% of the time.
-
Validation and Edge Cases – Validation logic checks that every required parameter is present before running anything. Ambiguous or incomplete questions are handled explicitly, with defaults or a request to clarify, instead of a confident wrong answer.
-
Metric Calculation Engine – Connectors pull data from the restaurants' management systems. A calculation engine computes the metrics, such as revenue and covers, with filtering and aggregation by revenue centre, category and session. A comparative analysis engine compares time periods, locations and actuals against budget.
-
External Context: Weather and Events – Weather and local events data is integrated into the analysis, so performance can be read in context, for example why one site's Saturday was weaker than another's.
-
Visualization Generation – Chart-type selection logic picks the right visual for the query type. A spec generator produces a rendering specification for the frontend, with titles, labels and annotations, and the data is transformed into a visualization-ready, compact payload.
-
API Service – REST endpoints receive questions and deliver visualization data to the client's dashboard, with authentication and caching for frequently asked queries. The frontend stayed with the client's team, and the API was documented for integration.
Business Outcome
Operations managers across more than 50 restaurants in 2 countries can ask questions in plain English and get a calculated answer with a fitting chart, instead of waiting for a report. The backend understood about 0.85 of questions correctly and was delivered to power the client's dashboard.
The design split the work cleanly: the model reads the question, and code does the calculations. That kept the numbers trustworthy while making the data reachable for people who'd never write a query.
Technologies
Planning something similar?
Tell me about it on a short call. New projects can start within 2 weeks