Insightflow — Building Materials Inventory Tracker
Conversational inventory tracking for building materials stores. Parses single and multi-entry sales in natural language with Gemini plus regex fallback, saves transactions in Supabase, and exposes Power BI-ready SQL views for reporting.
Next.js
TypeScript
Google Gemini
Supabase
PostgreSQL
Power BI
Conversational UI
Inventory Management
Image of Insightflow — Building Materials Inventory Tracker

#Insightflow — Building Materials Inventory Tracker

Insightflow is a conversational inventory tracker for building materials stores. Instead of filling out forms, users can describe transactions naturally and the app parses them into structured records.

#What It Solves

Building materials businesses often track inventory and sales manually. That slows people down, creates inconsistent records, and makes reporting harder than it needs to be. Insightflow was built to reduce that friction by turning plain-language input into usable transaction data.

#What It Does

  • Accepts single or multiple entries in one message
  • Parses transactions with Google Gemini and a regex fallback
  • Confirms structured output before saving data
  • Stores data in Supabase PostgreSQL
  • Exposes SQL views for Power BI reporting
  • Supports a clean, chat-style interface for mobile and desktop

#Technical Notes

The app follows a simple flow: user input goes through parsing, validation, confirmation, and persistence. It is designed to be resilient, so if the AI parser fails, the fallback parser still handles common formats.

The system also includes a dashboard-friendly data model so the stored records can be analyzed later in Power BI without extra transformation work.

#Solution Architecture

Request flow, per message:

User message ("10 cement at 5000, 50 iron rods for 75000")
  → Conversational detection (greeting/question? respond directly, skip parsing)
  → /api/parse
      → Gemini 2.5 Flash (structured JSON extraction, handles natural-language variation)
      → on failure/quota limit: regex fallback (3 patterns: "qty item at price",
        "item for total", "qty item price") — handles ~90% of common formats
  → Canonical item mapping ("loaf" → "bread", dictionary-based, for clean analytics)
  → /api/validate → ConfirmationCard shown to user (multi-item, with grand total)
  → User confirms → /api/transactions → Supabase (Postgres) insert
  → Pre-aggregated SQL views (daily_summary, category_performance, top_items)
      → read directly by Power BI, no live query-time joins

Key engineering decisions (from the project's own design notes):

  • Regex fallback exists because Gemini has quota limits and can fail — parsing isn't allowed to be a single point of failure. The fallback won't handle everything Gemini can, but it keeps the app usable when the API is down or rate-limited, rather than blocking data entry entirely.
  • Conversational input is detected and short-circuited before parsing — early versions threw parse errors when a user typed "hi" or "help." Detecting greetings/questions and responding directly, instead of forcing every input through the transaction parser, was a direct fix for a real observed failure mode.
  • Canonical item names, not raw string matching — "bread", "Bread", and "loaf" all get mapped to one canonical name via a dictionary lookup before storage, so analytics aren't fragmented across spelling/naming variants of the same item.
  • Power BI reads pre-computed views, not raw tablesdaily_summary, category_performance, and similar views are computed once in Postgres rather than joined at dashboard-refresh time, keeping reporting fast regardless of how the underlying schema evolves.
  • Confirmation step before persistence — parsed output (single or multi-item) is shown back to the user as a structured card before anything is saved, so an AI misparse gets caught before it becomes a bad record rather than after.

#Key Features

  • Multiple transaction support in one message
  • Natural-language parsing for real store input
  • Validation and confirmation before save
  • Light/dark theme support
  • Mobile-first responsive layout
  • Power BI-ready analytics views

#Why It Matters

Insightflow is a practical example of applied AI: a small product that solves a real workflow problem. It combines conversational UX, parsing logic, and database design into one focused tool.