GraphAcademy Cup Submission
Topic Title Format:
Week 3: KiranaAI โ Text2Cypher + Text2SQL AI Agent for Kirana Stores - India
GraphAcademy Cup Team Profile Link
Team Profile Link: India | GraphAcademy Cup
GraphAcademy Public Profile Username
Public Profile Username: guna
Anonymous GraphAcademy profiles are not eligible for weekly LEGO prizes.
Country
Country: India
GraphAcademy Course Completed
Course Name:
-
Cypher Fundamentals
-
Neo4j Fundamentals
Project Name
KiranaAI โ Conversational AI Agent for Indian Kirana Store Owners using Text2Cypher + Text2SQL
Description
India has over 12 million kirana (neighborhood grocery) stores. Every owner knows their business intuitively โ but depends on a "technical person" to run reports. A relational database gives sales totals and stock counts, but it cannot reveal how customers, products, credit, and suppliers are connected. Those connections are graph problems.
A few days ago I got an email about the Week 2 GraphAcademy Cup results. That same day I gave a guest lecture on Text2SQL at my undergraduate college. Driving back, one question came to mind: does Text2Cypher exist? I found the Neo4j blog, and the idea clicked โ Text2SQL and Text2Cypher are both products of the LLM + ReAct agent pattern era . Both let a non-technical person query a database with plain language. But they solve fundamentally different problems.
KiranaAI is a Tenglish (Telugu + English, Roman script) conversational agent that routes each owner question to the right database automatically:
Graph Value โ why Neo4j is the intelligence layer:
-
"Atta tho paatu em adugutaaru customers?" โ
OFTEN_WITHco-purchase traversal + stock check from SQLite = full recommendation -
"Evaru evaru udhar teeyaali?" โ
Customer โ OWES โ Khatatraversal + credit ranking -
"Basmati Rice ekkadi nundi vastaundi?" โ
Product โ SUPPLIED_BY โ Supplierone-hop traversal
No SQL JOIN chain expresses these naturally. Two-line Cypher does. And Text2Cypher translates the owner's Tenglish question to that Cypher automatically โ no graph knowledge required.
Architecture:
Owner Question (Tenglish โ Telugu + English, Roman script)
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ DeepSeek LLM โ
โ (LangGraph ReAct Agent)โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโ
โ decides which tool(s)
โโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ neo4j_search โ โ sql_query โ
โ (Text2Cypher โ โ (SQLite) โ
โ โ Neo4j Aura) โ โ โ
โ โ โ Inventory, Sales, โ
โ PURCHASED โ โ Billing, Stock alerts โ
โ OWES โ Khata โ โโโโโโโโโโโโโโฌโโโโโโโโโโโโโ
โ OFTEN_WITH โ โ
โ SUPPLIED_BY โ โ
โ REFERRED_BY โ โ
โโโโโโโโโโฌโโโโโโโโโโ โ
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโ
โ create_visualization โ
โ (Plotly charts) โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโ
โ
โผ
Answer in Tenglish
+ Interactive Neo4j Graph (pyvis)
+ Plotly Chart (when numeric)
What Did You Learn?
a) The Graph Data Model
I modelled the kirana store as a knowledge graph where every business relationship is a first-class edge:
(Customer)-\[:PURCHASED {times, last_date}\]->(Product)
(Customer)-\[:OWES\]->(Khata {balance})
(Product)-\[:OFTEN_WITH {strength}\]->(Product)
(Product)-\[:SUPPLIED_BY\]->(Supplier)
(Customer)-\[:REFERRED_BY\]->(Customer)
This is what the Cypher Fundamentals and Neo4j Fundamentals courses made click for me โ designing relationships as edges (not foreign keys) changes what questions you can answer in one query. MATCH (c:Customer)-\[r:OWES\]->(k:Khata) RETURN c, r, k ORDER BY k.balance DESC does what would take a 3-table SQL JOIN plus an ORDER BY.
b) Text2Cypher with GraphCypherQAChain from langchain-neo4j
The neo4j_search tool accepts only plain-language questions โ the agent never writes Cypher. Inside the tool:
-
Neo4jGraph(enhanced_schema=True)fetches the live schema with property examples โ LLM stops guessing node labels -
The question + schema + 14 verified few-shot Cypher examples go into
GraphCypherQAChain
3. LLM generates Cypher grounded in the real schema
4. The same Cypher re-runs via the raw Neo4j driver to capture Node and Relationship objects for the interactive pyvis graph
Without the few-shot examples, the LLM invented complex WITH aggregation blocks the graph couldn't serve. 14 tested patterns made generation reliable.
c) Two auto-generated Cypher queries that show what Text2Cypher enables
Question: "Atta tho paatu em adugutaaru?" (What to suggest alongside Atta?)
MATCH (p1:Product)-\[r:OFTEN_WITH\]->(p2:Product)
WHERE p1.name CONTAINS 'Atta'
RETURN p1, r, p2
ORDER BY r.strength DESC
The agent also called sql_query for stock levels and merged both answers โ without being told to.
Question: "Evaru evaru udhar teeyaali?" (Who owes money?)
MATCH (c:Customer)-\[r:OWES\]->(k:Khata)
RETURN c, r, k
ORDER BY k.balance DESC
Both queries rendered as interactive force-directed graphs โ automatically.
d) Key architectural insight
Graph + Relational together is more powerful than either alone. Neo4j handles relationships and patterns. SQLite handles counts, totals, and filtering. The LangGraph ReAct agent decides which database โ or both โ to query for each question. That decision is the intelligence.
Screenshot
Query 1 โ "Atta tho paatu em adugutaaru customers, aa items stock lo unnaya?"
(What to suggest to Atta buyers โ are those items in stock?)
This question requires both databases: Neo4j for co-purchase relationships, SQLite for stock levels. The agent decides this on its own.
-
Step 1 โ Owner asks in Tenglish. The agent immediately decides to call both the graph tool (Text2Cypher) and the SQL tool to answer this single question.
-
Step 2 โ The thinking panel reveals both auto-generated queries. The Cypher โ produced from the owner's question via Text2Cypher โ traverses the
OFTEN_WITHrelationship to find what is bought alongside Atta.
-
Step 3 โ The agent synthesises graph + SQL results into one Tenglish recommendation: "Suggest Toor Dal (55 packets remaining) and Sugar (80 packets remaining)."
-
Step 4 โ The Atta โ Toor Dal and Atta โ Sugar
OFTEN_WITHedges render as an interactive force-directed graph โ automatically, from the same Text2Cypher result.
Query 2 โ "Evaru evaru udhar teeyaali, enta baaki undi?"
(Who all need to pay their credit โ how much is pending?)
A pure graph traversal question. The OWES relationship between Customer and Khata nodes holds the answer.
-
Step 1 โ Owner asks about pending credit. The agent's first instinct is the graph โ
OWESis a natural graph traversal. SQL runs in parallel for the raw balance numbers.
-
Step 2 โ The thinking panel shows the auto-generated Cypher:
MATCH (c:Customer)-\[r:OWES\]->(k:Khata) RETURN c, r, k ORDER BY k.balance DESCโ produced entirely from the Tenglish question. No manual Cypher writing.
-
Step 3 โ Ranked udhar list in Tenglish: Mohan Lal Rs.450, Ramesh Kumar Rs.250, Vijay Singh Rs.180, Suresh Yadav Rs.120 โ with a tip on who to collect from first.
-
Step 4 โ Customer โ Khata credit graph with rupee amounts on edges. The entire store's credit network at a glance โ this is what Neo4j makes possible that SQL simply cannot.
Repository / Demo Link
GitHub / Demo URL (Optional): GitHub - chakka-guna-sekhar-venkata-chennaiah/kirana-ai-agent ยท GitHub
Additional Notes
The Tenglish persona matters: millions of Telugu kirana owners think and speak in Telugu+English Roman script โ not Hindi, not pure English. "Naadu stock chala takkuvaiga undi!" lands differently than "Stock is low." The agent responds the same way a knowledgeable neighbour would.
The system is schema-aware at runtime โ Neo4jGraph fetches the live graph schema before each query, so the Text2Cypher layer adapts automatically if the graph evolves. No hardcoded schema strings in the prompt.
My background with knowledge graphs came from postgraduate studies and professional work. Revisiting Cypher through GraphAcademy with a real project to build made every concept land differently than studying it in isolation. The moment Text2Cypher turned a Tenglish question into a working MATCH query against live Neo4j Aura was when it all made sense.
Next: local LLM support (Ollama) for full offline operation, and a WhatsApp bot interface โ since most kirana owners already use WhatsApp all day.
Submission Checklist
Before submitting, confirm that:
-
I am participating in the GraphAcademy Cup.
-
I included my Team Profile Link.
-
I included my GraphAcademy Public Profile Username.
-
My profile is public and eligible for prize verification.
-
My project is related to concepts learned in GraphAcademy.
Contest Reminder
One LEGO prize winner will be selected every week during the GraphAcademy Cup.
Terms & Conditions:
FAQ:









