Demeter: The AI Harvest Desk for Tiffin Kitchens

Customers message in chaos. Demeter turns it into a packing sheet. AI proposes. The owner approves. Code calculates.


Inspiration

In Greek myth, Demeter is the goddess of grain and harvest. When she grieved, the harvest failed and people went hungry. Her whole story is about one promise: nobody should go without a meal.

That promise is what a tiffin kitchen keeps every single day. Across India, thousands of home cooks feed 15 to 100 regular subscribers with fresh, home-style meals delivered in stacked steel boxes. The food is made with care. The operations are held together by a paper diary, a good memory, and a WhatsApp inbox that never stops buzzing.

The messages look like this:

  • "Bhaiyya don't send food today"
  • "Send 2 lunches tomorrow"
  • "Out of station till Monday"

Every one of those messages is an order change written in casual Hindi-English, and each one is easy to lose. The cost of a mistake is concrete:

Missed message What happens
A cancellation Food is cooked, packed, and wasted
An extra meal A paying customer goes hungry
Month-end counting Hours of scrolling chat history, then a payment dispute

We asked a simple question: what if the kitchen owner could keep cooking, and the paperwork could keep itself in order?

But we did not want a chatbot that quietly edits someone's meal plan. A tiffin owner's income depends on trust. So the real design question became: how do we use AI where it is strong (understanding messy language) without letting it be wrong where it is dangerous (money and food quantities)?


What it does

Demeter is a full-stack kitchen-management platform for independent tiffin and home-food businesses.

  1. Ingests informal customer messages from WhatsApp or manual paste, and suppresses duplicates within 24 hours.
  2. Understands each message with a two-stage NVIDIA Nemotron pipeline running on Nebius Token Factory, and extracts the intent, dates, quantities, and the exact words that justify them.
  3. Shows the owner a side-by-side before-and-after calendar diff for every proposed change.
  4. Commits only after one-click human approval, verified against a cryptographic hash of exactly what the owner saw.
  5. Produces immutable, versioned packing sheets, building-clustered delivery routes with CSV export, and itemized monthly invoices with a pre-filled WhatsApp billing link.

The guiding rule is Propose, Review, Calculate:

AI → Human → Deterministic code
proposes approves calculates

The whole project at a glance

Demeter: End-to-End Flowchart

AI proposes → Human approves → Deterministic code calculates

Customer message (WhatsApp / SMS)
            |
            v
Intake Engine (fingerprint + duplicate check)
            |
            v
Stage 1: Extraction (NVIDIA Nemotron)
            |
            v
Stage 2: Verification (NVIDIA Nemotron)
            |
            v
   Clarity score >= 0.8 and spans valid?
     |              |               |
 Not an order    Ambiguous         Clear
     |              |               |
     v              v               v
Auto-dismissed   Draft flagged   Draft needs review
                    |               |
                    +-------+-------+
                            |
                            v
        Review Workbench (calendar diff + previewHash)
                            |
                            v
                    Owner approves?
                     |           |
                    No          Yes
                     |           |
                     v           v
         Rejected / deferred   Idempotency + revision check
                                 |         |         |
                             Duplicate   Stale     Valid
                                 |         |         |
                                 v         v         v
                         Cached receipt  HTTP 409  MongoDB ACID transaction
                                                       |
                                                       v
                                          Deterministic engine (TypeScript)
                                                       |
                                                       v
                                            Immutable packing sheet
                                                  |          |
                                                  v          v
                                          Dispatch route   Monthly invoice
                                                  |          |
                                                  v          v
                                          Meals delivered   Customer pays

🛠️ How we built it

The AI layer: two stages, not one

A single model call that both reads and judges its own output is hard to trust. So we split the work:

  1. Stage 1: Fact and span extraction. A Nemotron model reads the raw message and returns candidate operations: intent kind, target dates, quantities, and evidence character spans pointing at the exact words it relied on.
  2. Stage 2: Verification and classification. A second Nemotron pass checks the Stage 1 output against a strict schema. It scores how clear the intent is, checks that the evidence spans really exist in the message, and checks that any plan replacement is explicit.

A proposal is marked clean only when the clarity score $s$ clears a threshold:

$$ \text{status}(p) = \begin{cases} \text{ready for review} & \text{if } s \ge 0.8 \text{ and spans valid} \ \text{flagged with warnings} & \text{if } s < 0.8 \ \text{auto-dismissed} & \text{if message is not an order} \end{cases} $$

Every model call is logged in an aiRuns audit collection with model ID, token counts, latency, and provenance. Inference runs through the Nebius Token Factory OpenAI-compatible endpoint.

The business engine: plain math, no guessing

The LLM never touches a number that ends up on a bill. For customer $c$ on date $d$, the quantity is decided by a simple rule. A date-specific override wins, otherwise the weekly baseline applies:

$$ q_c(d) = \begin{cases} o_c(d) & \text{if an approved override exists for } d \ b_c\big(\text{weekday}(d)\big) & \text{otherwise} \end{cases} $$

The kitchen's total for the day, which is what goes on the packing sheet, is:

$$ T(d) = \sum_{c \in C} q_c(d) $$

A monthly invoice for customer $c$ at rate $r_c$, with credits $K$ and adjustments $A$, is:

$$ I_c = r_c \sum_{d \in \text{month}} q_c(d) \;-\; K \;+\; A $$

All of this is deterministic TypeScript, so the same inputs always produce the same totals.

Baseline invariance

A one-day skip must never destroy a customer's permanent weekly plan. Temporary changes are stored as date-specific overrides in dailyOverrides and never rewrite the plans collection. Remove the override and the original schedule is exactly as it was.

"What you see is what you approve"

When the owner previews a proposal, we compute a hash over the canonical form of the calendar diff:

$$ h = \operatorname{SHA\text{-}256}\big(\operatorname{canonical}(\Delta_{\text{calendar}})\big) $$

The approval request must carry $h$. If the underlying state has drifted since the preview, the hash no longer matches and the approval is rejected. The owner can never approve a change that is different from the one they looked at.

Correctness under concurrency

Every mutating request carries an Idempotency-Key and an expectedStateRevision.

  • If the key was already seen, we return the cached receipt and execute nothing twice.
  • If $\text{expectedStateRevision} \neq \text{seller.stateRevision}$, the request fails with HTTP 409 STALE_REVISION.
  • Otherwise the change runs inside a MongoDB ACID transaction, the revision moves from $N$ to $N+1$, and an immutable audit receipt is written.

Two browser tabs, a double-click, or a flaky mobile connection cannot corrupt the data.

Immutable packing sheets

A daily sheet can only be finalized when zero unresolved messages remain for that date. Once finalized it is versioned (REV-1, REV-2, ...) and never edited in place. The kitchen cooks from a sheet it can trust.

Stack

Layer Technology
Frontend Next.js 16 (App Router), React 19, Tailwind CSS 4, Radix / shadcn UI
Backend Next.js Route Handlers and Server Actions, TypeScript
Database MongoDB Atlas with multi-document ACID transactions, 12 collections
Auth Better-Auth with HMAC-SHA256 signed cookies and CSRF protection
AI NVIDIA Nemotron on Nebius Token Factory
Messaging Baileys (WhatsApp multi-device protocol)
Validation Zod 4 on every input, output, and document
Time @js-temporal/polyfill for timezone-correct calendar math (Asia/Kolkata)

The API has 53 business operations documented in an OpenAPI 3.1 spec, plus an end-to-end test that walks the full path from customer message to finalized packing sheet.


Challenges we faced

1. Trusting AI with real money and real food. The hardest decision was not technical, it was about trust. A wrong guess on a cancellation wastes food. A wrong guess on an invoice damages a customer relationship. We solved it by limiting what the AI is allowed to do: it can only write drafts, and every number is computed by deterministic code.

2. Messy, code-mixed language. Customers write in Hindi, English, and a blend of both, with no consistent format. We needed the model to return strict, validated JSON, not free-form guesses. Requiring evidence spans and a second verification pass made bad extractions visible instead of silent.

3. Keeping temporary changes from destroying permanent plans. It is easy to build a system where "skip tomorrow" accidentally overwrites the weekly schedule. Designing overrides as a separate layer on top of an untouched baseline took careful modelling of the data.

4. Race conditions and double submissions. A kitchen owner on a phone, on patchy mobile data, will tap twice. We designed idempotency keys, state revisions, and transactions so that retries are safe and stale tabs are rejected rather than merged.

5. Making approval honest. A preview that can change before approval is not really a preview. The previewHash check ensures the thing approved is exactly the thing shown.

6. Cost and reliability of AI calls. We added daily request limits, input-token caps, and per-stage timeouts so a burst of messages cannot cause runaway spend or hang the workbench.


Accomplishments we're proud of

  • An AI system where the model is structurally unable to change production data without a human decision.
  • Cryptographically verified approvals, idempotent writes, and optimistic concurrency, which is rare in hackathon projects.
  • A complete loop from a raw WhatsApp message to a printable kitchen sheet, a delivery route, and an invoice.
  • Built-in privacy tools: data export, message erasure, and cascading account deletion, all audited.

What we learned

  • Use AI for understanding, not for arithmetic. Models are excellent at interpreting a sentence like "Monday 2 tiffin bhej dena" and unreliable as calculators. Splitting those jobs made the system both smarter and safer.
  • A second model pass is cheap insurance. Separating extraction from verification catches mistakes that a single call hides.
  • Evidence makes AI reviewable. Pointing at the exact words behind a suggestion lets a busy owner check it in seconds instead of re-reading the whole chat.
  • Trust is a feature. For small-business tools, audit trails, idempotency, and "undo-safe" design matter as much as model quality.
  • Good defaults beat clever prompts. Strict schemas with Zod, typed contracts, and rate limits did more for reliability than prompt tweaking alone.

What's next for Demeter

  • Voice-note intake with speech-to-text, so customers can simply speak their orders.
  • Hindi, Hinglish, and regional-language evaluation sets to measure extraction accuracy across dialects.
  • UPI payment links on invoices to close the billing loop.
  • Multi-kitchen dashboards for cloud-kitchen and franchise operators.
  • Demand forecasting from historical override patterns, so kitchens cook closer to what is needed and waste less:

$$ \min \; W = \sum_{d} \big( \text{cooked}(d) - T(d) \big)^{+} $$

where $(x)^{+} = \max(x, 0)$ is the food cooked beyond what was actually needed.


🔗 Built with

nebius-token-factory · nvidia-nemotron · next.js · react · typescript · tailwind-css · mongodb · better-auth · zod · baileys · whatsapp · shadcn-ui · radix-ui · openapi

Named for Demeter, who made sure no one went hungry.

Built With

  • baileys
  • better-auth
  • mongodb
  • mongodb-atlas
  • nebius-token-factory
  • next.js
  • node.js
  • nvidia-nemotron
  • openapi
  • pnpm
  • radix-ui
  • react
  • shadcn-ui
  • tailwind-css
  • temporal-api
  • typescript
  • whatsapp
  • zod
Share this project:

Updates

Submission history