Da-123 commited on
Commit
7c68554
·
verified ·
1 Parent(s): 0ef406d

Upload 7 files

Browse files
mcp/client/host.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ CLI host for the FastAPI-powered Swiggy server.
4
+
5
+ Flow
6
+ 1. Send natural-language query → /parse_query
7
+ 2. If is_swiggy_query == True and dates are present → /get_orders
8
+ 3. Pretty-print the result
9
+ """
10
+
11
+ import requests, sys
12
+ from dateutil import parser as dtparse
13
+
14
+ API_BASE = "http://127.0.0.1:8000"
15
+
16
+ # ----------------------------------------------------------------------
17
+ # Helpers
18
+ # ----------------------------------------------------------------------
19
+ def nice_date(dt_str: str | None) -> str:
20
+ if not dt_str:
21
+ return "??"
22
+ return dtparse.parse(dt_str).strftime("%d %b %Y")
23
+
24
+ def pretty_order(order: dict) -> str:
25
+ if "error" in order:
26
+ return f" - Email #{order['email_number']}: ❌ {order['error']}"
27
+ head = (
28
+ f"Restaurant : {order['restaurant_name']}\n"
29
+ f"Date : {nice_date(order['order_date'])} {order['order_time']}\n"
30
+ f"Total : ₹{order['total_price']:.0f}\n"
31
+ "Items:"
32
+ )
33
+ items = "\n".join(
34
+ f" • {it['quantity']} × {it['name']} – ₹{it['price']:.0f}"
35
+ for it in order["items"]
36
+ )
37
+ return head + "\n" + items
38
+
39
+ # ----------------------------------------------------------------------
40
+ # Main REPL
41
+ # ----------------------------------------------------------------------
42
+ def main() -> None:
43
+ # Quick health-check
44
+ try:
45
+ requests.get(f"{API_BASE}/docs").raise_for_status()
46
+ except Exception as e:
47
+ print("❌ Cannot reach FastAPI server:", e)
48
+ sys.exit(1)
49
+ print("✅ Connected. Type a Swiggy question (or Ctrl-C to quit).")
50
+
51
+ while True:
52
+ try:
53
+ query = input("\n🗨️ You: ").strip()
54
+ except (EOFError, KeyboardInterrupt):
55
+ break
56
+ if not query:
57
+ continue
58
+
59
+ # ── Stage 1: parse_query ────────────────────────────────────
60
+ try:
61
+ r = requests.post(f"{API_BASE}/parse_query", json={"query": query})
62
+ r.raise_for_status()
63
+ meta = r.json() # {is_swiggy_query, start_date, end_date, intent}
64
+ except Exception as e:
65
+ print("⚠️ Parse error:", e)
66
+ print("🔎 Server:", r.text if 'r' in locals() else "no response")
67
+ continue
68
+
69
+ # Handle non-Swiggy or missing dates
70
+ if not meta.get("is_swiggy_query"):
71
+ print("🤷 That doesn’t look like a Swiggy order query.")
72
+ continue
73
+ if not meta.get("start_date") or not meta.get("end_date"):
74
+ print("⚠️ Couldn’t find a full date range in your question.")
75
+ continue
76
+
77
+ print(f" ↳ Date range: {meta['start_date']} → {meta['end_date']}")
78
+ print(f" ↳ Intent : {meta['intent']}")
79
+
80
+ # ── Stage 2: get_orders ────────────────────────────────────
81
+ try:
82
+ r2 = requests.post(
83
+ f"{API_BASE}/get_orders",
84
+ json={
85
+ "start_date": meta["start_date"],
86
+ "end_date": meta["end_date"],
87
+ },
88
+ )
89
+ r2.raise_for_status()
90
+ orders = r2.json()
91
+ except Exception as e:
92
+ print("⚠️ Failed to fetch orders:", e)
93
+ print("🔎 Server:", r2.text if 'r2' in locals() else "no response")
94
+ continue
95
+
96
+ # ── Output ────────────────────────────────────────────────
97
+ if not orders:
98
+ print("😕 No orders found for that range.")
99
+ continue
100
+
101
+ print("\n📦 Orders:")
102
+ for o in orders:
103
+ print(pretty_order(o))
104
+ print("-" * 40)
105
+
106
+ print("\n👋 Bye!")
107
+
108
+ # ----------------------------------------------------------------------
109
+ if __name__ == "__main__":
110
+ main()
mcp/server/db_schema.py ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # File: db_schema.py
2
+ import sqlite3
3
+
4
+ DB_NAME = "swiggy_orders.db"
5
+
6
+
7
+ def init_db(db_path: str = DB_NAME) -> None:
8
+ """
9
+ Initialize the SQLite database with the necessary tables.
10
+ """
11
+ conn = sqlite3.connect(db_path)
12
+ c = conn.cursor()
13
+ # Orders metadata
14
+ c.execute(
15
+ """
16
+ CREATE TABLE IF NOT EXISTS orders (
17
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
18
+ email_number INTEGER,
19
+ order_date TEXT,
20
+ order_time TEXT,
21
+ restaurant_name TEXT,
22
+ delivery_address TEXT,
23
+ total_price REAL
24
+ )
25
+ """
26
+ )
27
+ # Individual items per order
28
+ c.execute(
29
+ """
30
+ CREATE TABLE IF NOT EXISTS order_items (
31
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
32
+ order_id INTEGER,
33
+ item_name TEXT,
34
+ quantity INTEGER,
35
+ price REAL,
36
+ FOREIGN KEY(order_id) REFERENCES orders(id)
37
+ )
38
+ """
39
+ )
40
+ conn.commit()
41
+ conn.close()
42
+
43
+
44
+ def get_db_connection(db_path: str = DB_NAME) -> sqlite3.Connection:
45
+ """Return a new connection to the database."""
46
+ return sqlite3.connect(db_path)
47
+
48
+
49
+ def get_orders_by_date_from_db(date_str: str) -> list[dict]:
50
+ """
51
+ Fetch all orders and their items for a given date from the database.
52
+ """
53
+ conn = get_db_connection()
54
+ c = conn.cursor()
55
+ c.execute(
56
+ "SELECT id, email_number, order_time, restaurant_name, delivery_address, total_price"
57
+ " FROM orders WHERE order_date = ?",
58
+ (date_str,)
59
+ )
60
+ orders = []
61
+ for order_id, email_number, order_time, restaurant_name, delivery_address, total_price in c.fetchall():
62
+ # fetch items for this order
63
+ c.execute(
64
+ "SELECT item_name, quantity, price FROM order_items WHERE order_id = ?",
65
+ (order_id,)
66
+ )
67
+ items = [
68
+ {"name": name, "quantity": qty, "price": price}
69
+ for name, qty, price in c.fetchall()
70
+ ]
71
+ orders.append({
72
+ "email_number": email_number,
73
+ "order_date": date_str,
74
+ "order_time": order_time,
75
+ "restaurant_name": restaurant_name,
76
+ "delivery_address": delivery_address,
77
+ "items": items,
78
+ "total_price": total_price
79
+ })
80
+ conn.close()
81
+ return orders
82
+
83
+
84
+ def save_orders_to_db(date_str: str, orders: list[dict]) -> None:
85
+ """
86
+ Insert scraped orders and their items for a given date into the database.
87
+ """
88
+ conn = get_db_connection()
89
+ c = conn.cursor()
90
+ for order in orders:
91
+ c.execute(
92
+ """
93
+ INSERT INTO orders
94
+ (email_number, order_date, order_time, restaurant_name, delivery_address, total_price)
95
+ VALUES (?, ?, ?, ?, ?, ?)
96
+ """,
97
+ (
98
+ order["email_number"],
99
+ date_str,
100
+ order["order_time"],
101
+ order["restaurant_name"],
102
+ order["delivery_address"],
103
+ order["total_price"]
104
+ )
105
+ )
106
+ order_id = c.lastrowid
107
+ for item in order.get("items", []):
108
+ c.execute(
109
+ """
110
+ INSERT INTO order_items
111
+ (order_id, item_name, quantity, price)
112
+ VALUES (?, ?, ?, ?)
113
+ """,
114
+ (
115
+ order_id,
116
+ item["name"],
117
+ item["quantity"],
118
+ item["price"]
119
+ )
120
+ )
121
+ conn.commit()
122
+ conn.close()
123
+
124
+
mcp/server/eval.txt ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ EVALUATIONS
2
+
3
+ able to differentiate between swiggy based queries or not
4
+ able to break prompts into 2 instruction. First instruction will be extracting dates.
5
+ second instructions will be analysing the data scrapped.
6
+ able to extract dates
7
+ able to extract the analysis:
8
+
9
+ -How much non-veg did I order last week / between date X and date Y?
10
+
11
+ -Counts and/or total rupees spent on non-veg dishes.
12
+
13
+ -What was my total expense between date X and date Y?
14
+
15
+ -What is my average daily spend on Swiggy (overall or for a given period)?
16
+
17
+ -Which restaurant got the most orders (or the most money) in that period?
18
+
19
+ -What single order cost me the most during that window?
20
+
21
+ -Show a day-by-day spend chart between date X and date Y.
22
+
23
+ -List every item I’ve ordered only once—my “one-hit wonders.”
24
+
25
+ -How many unique cuisines did I try in the last month?
26
+
27
+ -Compare veg vs. non-veg spend for the current calendar year.
28
+
29
+ -When was my longest streak of days without ordering anything?
30
+
31
+ -Identify any “late-night” orders placed after 11 p.m. this week.
32
+
33
+ -Tell me my top three most-ordered dishes in the past six months.
34
+
35
+ -Which new restaurant did I try most recently, and what did I order?
36
+
37
+ -Forecast next month’s spend based on my last three-month trend.
mcp/server/main.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # File: main.py
2
+ from fastapi import FastAPI
3
+ from contextlib import asynccontextmanager
4
+ from routes import router
5
+ from db_schema import init_db
6
+
7
+ @asynccontextmanager
8
+ async def lifespan(app: FastAPI):
9
+ print("🚀 Server is starting up...")
10
+ # Ensure SQLite tables exist before handling requests
11
+ init_db()
12
+ yield
13
+ print("🧹 Server is shutting down... Cleaned up!")
14
+
15
+ app = FastAPI(
16
+ title="Swiggy Email API",
17
+ description="Extract Swiggy orders from Gmail",
18
+ version="1.0.0",
19
+ lifespan=lifespan
20
+ )
21
+
22
+ app.include_router(router)
23
+
24
+ # Run with: uvicorn main:app --reload
mcp/server/routes.py ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter, HTTPException
2
+ from pydantic import BaseModel
3
+ from swiggy_scraper import fetch_swiggy_orders
4
+ from datetime import datetime
5
+ from openai import OpenAI
6
+ import os, json
7
+
8
+ router = APIRouter()
9
+ client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
10
+
11
+ class QueryInput(BaseModel):
12
+ query: str
13
+
14
+ class DateRange(BaseModel):
15
+ start_date: str
16
+ end_date: str
17
+
18
+ # @router.post("/parse_query")
19
+ # def parse_query_llm(input: QueryInput):
20
+
21
+ # print("\ninput query:")
22
+ # print(input)
23
+
24
+ # today_str = datetime.today().strftime("%d-%b-%Y")
25
+ # system = (
26
+ # f"You are a date range extractor.\n"
27
+ # f"Today is {today_str}.\n"
28
+ # "Extract start_date and end_date in 'DD-MMM-YYYY' format.\n"
29
+ # "Respond with:\n"
30
+ # "Output ONLY a valid JSON object like:\n"
31
+ # '{ "start_date": "17-May-2025", "end_date": "18-May-2025" }\n'
32
+ # 'no extra commentry needed.'
33
+ # )
34
+ # try:
35
+ # rsp = client.chat.completions.create(
36
+ # model="gpt-4o-mini",
37
+ # temperature=0,
38
+ # messages=[
39
+ # {"role": "system", "content": system},
40
+ # {"role": "user", "content": input.query},
41
+ # ]
42
+ # )
43
+ # result = json.loads(rsp.choices[0].message.content.strip())
44
+ # if "start_date" not in result or "end_date" not in result:
45
+ # raise ValueError("Invalid response format")
46
+ # print("results:", result)
47
+ # return result
48
+ # except Exception as e:
49
+ # raise HTTPException(status_code=400, detail=str(e))
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+ def _llm(messages, model="gpt-4o-mini", temperature=0):
58
+ rsp = client.chat.completions.create(
59
+ model=model,
60
+ temperature=temperature,
61
+ messages=messages,
62
+ )
63
+ return rsp.choices[0].message.content.strip()
64
+
65
+ # ---------- Stage 1: classify + extract dates --------------------------
66
+
67
+ def _extract_scope(user_query: str):
68
+ today_str = datetime.today().strftime("%d-%b-%Y")
69
+
70
+ sys_prompt = f"""
71
+ Today is {today_str}.
72
+ You are a SCOPING assistant: decide if the user's text is about Swiggy food orders,
73
+ extract ONE date range, and keep the leftover words.
74
+
75
+ Return ONLY valid JSON like:
76
+ {{
77
+ "is_swiggy_query": true,
78
+ "start_date": "15-May-2025",
79
+ "end_date": "20-May-2025",
80
+ "remainder": "non veg expense"
81
+ }}
82
+
83
+ Rules:
84
+ • Accept natural phrases (“last week”, “since 1 May”).
85
+ • If no dates → start_date & end_date = null.
86
+ • If not Swiggy related → is_swiggy_query=false and remainder is full original text.
87
+ • Do NOT invent a remainder; it is literally whatever words follow the date phrase(s).
88
+ """
89
+ raw = _llm(
90
+ [
91
+ {"role": "system", "content": sys_prompt},
92
+ {"role": "user", "content": user_query}
93
+ ]
94
+ )
95
+ return json.loads(raw)
96
+
97
+ # ---------- Stage 2: shrink “remainder” into an intent -----------------
98
+
99
+ def _extract_intent(remainder: str):
100
+ sys_prompt = """
101
+ You are an INTENT classifier for Swiggy-order analytics.
102
+ Map the sentence into one concise snake_case intent.
103
+ Allowed intents (extendable):
104
+
105
+ • calculate_expense
106
+ • list_orders
107
+ • list_items
108
+ • list_nonveg_items
109
+ • list_veg_items
110
+ • count_orders
111
+ • unknown
112
+
113
+ Return JSON: { "intent": "calculate_expense" }
114
+ If unsure choose "unknown".
115
+ """
116
+ raw = _llm(
117
+ [
118
+ {"role": "system", "content": sys_prompt},
119
+ {"role": "user", "content": remainder.strip()}
120
+ ]
121
+ )
122
+ return json.loads(raw)["intent"]
123
+
124
+ # ---------- FastAPI route ----------------------------------------------
125
+
126
+ @router.post("/parse_query")
127
+ def parse_query_llm(input: QueryInput):
128
+ try:
129
+ scope = _extract_scope(input.query)
130
+ print("scope")
131
+ print(scope)
132
+ # If it is a Swiggy query, classify intent; else, intent = "unrelated"
133
+ if scope.get("is_swiggy_query", False):
134
+ intent = _extract_intent(scope.get("remainder", ""))
135
+ else:
136
+ intent = "unrelated"
137
+
138
+ result = {
139
+ "is_swiggy_query": scope["is_swiggy_query"],
140
+ "start_date": scope["start_date"],
141
+ "end_date": scope["end_date"],
142
+ "intent": intent
143
+ }
144
+
145
+
146
+ print("result")
147
+ print(result)
148
+
149
+ return result
150
+
151
+ except Exception as e:
152
+ raise HTTPException(status_code=400, detail=str(e))
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+ @router.post("/get_orders")
162
+ def get_orders(range: DateRange):
163
+ try:
164
+ orders = fetch_swiggy_orders(range.start_date, range.end_date)
165
+ return orders
166
+ except Exception as e:
167
+ raise HTTPException(status_code=500, detail=str(e))
mcp/server/swiggy_cache.json ADDED
@@ -0,0 +1,1379 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "2025-05-17": [
3
+ {
4
+ "email_number": 1,
5
+ "order_date": "17-May-2025",
6
+ "order_time": "11:00:08",
7
+ "restaurant_name": "IDC Kitchen",
8
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
9
+ "items": [
10
+ {
11
+ "name": "Thatte Idli",
12
+ "quantity": 1,
13
+ "price": 59
14
+ },
15
+ {
16
+ "name": "Idly 2 Pc",
17
+ "quantity": 1,
18
+ "price": 59
19
+ },
20
+ {
21
+ "name": "Vada (1 Pc)",
22
+ "quantity": 3,
23
+ "price": 174
24
+ }
25
+ ],
26
+ "total_price": 330
27
+ },
28
+ {
29
+ "email_number": 2,
30
+ "order_date": "17-May-2025",
31
+ "order_time": "17:02:59",
32
+ "restaurant_name": "Suryawanshi",
33
+ "delivery_address": "Shobhit\n2C, Orchard Green Apartment\n2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
34
+ "items": [
35
+ {
36
+ "name": "Vada Pav (twin)",
37
+ "quantity": 1,
38
+ "price": 95
39
+ },
40
+ {
41
+ "name": "Kande Bhaji",
42
+ "quantity": 1,
43
+ "price": 160
44
+ }
45
+ ],
46
+ "total_price": 300
47
+ },
48
+ {
49
+ "email_number": 3,
50
+ "order_date": "17-May-2025",
51
+ "order_time": "20:25:39",
52
+ "restaurant_name": "Meghana Foods",
53
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
54
+ "items": [
55
+ {
56
+ "name": "Extra Aloo 4 Pcs",
57
+ "quantity": 1,
58
+ "price": 45
59
+ },
60
+ {
61
+ "name": "Chicken Boneless Biryani",
62
+ "quantity": 1,
63
+ "price": 360
64
+ },
65
+ {
66
+ "name": "Lemon Chicken",
67
+ "quantity": 1,
68
+ "price": 360
69
+ },
70
+ {
71
+ "name": "Veg Manchurian Biryani",
72
+ "quantity": 1,
73
+ "price": 360
74
+ }
75
+ ],
76
+ "total_price": 1240
77
+ }
78
+ ],
79
+ "2025-05-19": [
80
+ {
81
+ "email_number": 1,
82
+ "order_date": "19-May-2025",
83
+ "order_time": "22:28:08",
84
+ "restaurant_name": "Swiggy Instamart",
85
+ "delivery_address": "2C, Orchard Green Apartment 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
86
+ "items": [
87
+ {
88
+ "name": "Safal Frozen Green Peas (Matar)",
89
+ "quantity": 1,
90
+ "price": 110
91
+ },
92
+ {
93
+ "name": "NOTO Strawberry Raspberry Sugar Free Popsicle Ice Cream",
94
+ "quantity": 4,
95
+ "price": 500
96
+ },
97
+ {
98
+ "name": "Baby Lady's Finger (Bendekaayi)",
99
+ "quantity": 2,
100
+ "price": 32
101
+ },
102
+ {
103
+ "name": "Whisper Ultra Skin Love Soft 30 Xl+ Sanitary Pads, Cottony Soft",
104
+ "quantity": 1,
105
+ "price": 323
106
+ },
107
+ {
108
+ "name": "Akshayakalpa Artisanal Organic Set Curd",
109
+ "quantity": 1,
110
+ "price": 145
111
+ },
112
+ {
113
+ "name": "Akshayakalpa Organic Malai Paneer",
114
+ "quantity": 1,
115
+ "price": 119
116
+ },
117
+ {
118
+ "name": "Aashirvaad Superior MP Atta",
119
+ "quantity": 2,
120
+ "price": 146
121
+ },
122
+ {
123
+ "name": "NOTO Kala Jamun Sugar Free Popsicle Ice Cream",
124
+ "quantity": 2,
125
+ "price": 250
126
+ },
127
+ {
128
+ "name": "Royal Gala Apple (Sebu)",
129
+ "quantity": 2,
130
+ "price": 356
131
+ }
132
+ ],
133
+ "total_price": 1564
134
+ }
135
+ ],
136
+ "2025-05-01": [
137
+ {
138
+ "email_number": 1,
139
+ "order_date": "01-May-2025",
140
+ "order_time": "11:36:15",
141
+ "restaurant_name": "Starbucks Coffee",
142
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
143
+ "items": [
144
+ {
145
+ "name": "Caffe Americano",
146
+ "quantity": 2,
147
+ "price": 710
148
+ }
149
+ ],
150
+ "total_price": 647
151
+ },
152
+ {
153
+ "email_number": 2,
154
+ "order_date": "01-May-2025",
155
+ "order_time": "18:34:08",
156
+ "restaurant_name": "Chaayos Chai+Snacks=Relax",
157
+ "delivery_address": "Shobhit\n2C, Orchard Green Apartment\n2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
158
+ "items": [
159
+ {
160
+ "name": "Vada Pav",
161
+ "quantity": 2,
162
+ "price": 238
163
+ },
164
+ {
165
+ "name": "Desi Chai",
166
+ "quantity": 1,
167
+ "price": 219
168
+ },
169
+ {
170
+ "name": "Samosa(2 pc)",
171
+ "quantity": 1,
172
+ "price": 90
173
+ }
174
+ ],
175
+ "total_price": 528
176
+ },
177
+ {
178
+ "email_number": 3,
179
+ "order_date": "01-May-2025",
180
+ "order_time": "21:28:12",
181
+ "restaurant_name": "Lavonne Cafe",
182
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
183
+ "items": [
184
+ {
185
+ "name": "Baguette",
186
+ "quantity": 1,
187
+ "price": 190.48
188
+ }
189
+ ],
190
+ "total_price": 278
191
+ }
192
+ ],
193
+ "2025-05-02": [
194
+ {
195
+ "email_number": 1,
196
+ "order_date": "02-May-2025",
197
+ "order_time": "11:13:38",
198
+ "restaurant_name": "Starbucks Coffee",
199
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
200
+ "items": [
201
+ {
202
+ "name": "Caffe Americano",
203
+ "quantity": 1,
204
+ "price": 315
205
+ },
206
+ {
207
+ "name": "Caffe Americano",
208
+ "quantity": 1,
209
+ "price": 355
210
+ }
211
+ ],
212
+ "total_price": 605
213
+ },
214
+ {
215
+ "email_number": 2,
216
+ "order_date": "02-May-2025",
217
+ "order_time": "14:43:19",
218
+ "restaurant_name": "Harvest Salad Co",
219
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
220
+ "items": [
221
+ {
222
+ "name": "Hummus And Chipotle Chicken Wrap",
223
+ "quantity": 2,
224
+ "price": 498
225
+ },
226
+ {
227
+ "name": "Mediterranean Bowl (Veg)",
228
+ "quantity": 1,
229
+ "price": 299
230
+ }
231
+ ],
232
+ "total_price": 899
233
+ },
234
+ {
235
+ "email_number": 3,
236
+ "order_date": "02-May-2025",
237
+ "order_time": "21:10:20",
238
+ "restaurant_name": "Swiggy Instamart",
239
+ "delivery_address": "2C, Orchard Green Apartment 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
240
+ "items": [
241
+ {
242
+ "name": "Classic Ice Burst",
243
+ "quantity": 1,
244
+ "price": 170
245
+ }
246
+ ],
247
+ "total_price": 222
248
+ },
249
+ {
250
+ "email_number": 4,
251
+ "order_date": "02-May-2025",
252
+ "order_time": "22:01:35",
253
+ "restaurant_name": "Dhaba Estd 1986 Delhi",
254
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
255
+ "items": [
256
+ {
257
+ "name": "Non Vegetarian Platter ( 12 Pcs)",
258
+ "quantity": 1,
259
+ "price": 1249
260
+ },
261
+ {
262
+ "name": "Butter Naan",
263
+ "quantity": 2,
264
+ "price": 198
265
+ },
266
+ {
267
+ "name": "Dhabe Di Roti",
268
+ "quantity": 2,
269
+ "price": 238
270
+ },
271
+ {
272
+ "name": "Laal Mirchi Parantha",
273
+ "quantity": 1,
274
+ "price": 109
275
+ },
276
+ {
277
+ "name": "Handi Murgh",
278
+ "quantity": 1,
279
+ "price": 629
280
+ }
281
+ ],
282
+ "total_price": 2006
283
+ }
284
+ ],
285
+ "2025-05-03": [
286
+ {
287
+ "email_number": 1,
288
+ "order_date": "03-May-2025",
289
+ "order_time": "09:50:51",
290
+ "restaurant_name": "Starbucks Coffee",
291
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
292
+ "items": [
293
+ {
294
+ "name": "Cold Brew Black",
295
+ "quantity": 1,
296
+ "price": 410
297
+ },
298
+ {
299
+ "name": "Caffe Americano.",
300
+ "quantity": 1,
301
+ "price": 315
302
+ }
303
+ ],
304
+ "total_price": 691
305
+ },
306
+ {
307
+ "email_number": 2,
308
+ "order_date": "03-May-2025",
309
+ "order_time": "15:06:18",
310
+ "restaurant_name": "Copper + Cloves",
311
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
312
+ "items": [
313
+ {
314
+ "name": "Asian Peanut Salad",
315
+ "quantity": 1,
316
+ "price": 500
317
+ },
318
+ {
319
+ "name": "Tofu",
320
+ "quantity": 1,
321
+ "price": 100
322
+ }
323
+ ],
324
+ "total_price": 432
325
+ },
326
+ {
327
+ "email_number": 3,
328
+ "order_date": "03-May-2025",
329
+ "order_time": "21:32:47",
330
+ "restaurant_name": "Shiro",
331
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
332
+ "items": [
333
+ {
334
+ "name": "Super Crunch (8 pcs)",
335
+ "quantity": 1,
336
+ "price": 695
337
+ },
338
+ {
339
+ "name": "Bulgogi Chicken Spring Rolls (6 pcs)",
340
+ "quantity": 1,
341
+ "price": 595
342
+ },
343
+ {
344
+ "name": "Cantonese Chicken Wonton (6 pcs)",
345
+ "quantity": 1,
346
+ "price": 410
347
+ },
348
+ {
349
+ "name": "Smoky Pork Gyoza (4 pcs)",
350
+ "quantity": 1,
351
+ "price": 495
352
+ },
353
+ {
354
+ "name": "Spicy Salmon Negi (8 pcs)",
355
+ "quantity": 1,
356
+ "price": 670
357
+ }
358
+ ],
359
+ "total_price": 2600
360
+ }
361
+ ],
362
+ "2025-05-04": [
363
+ {
364
+ "email_number": 1,
365
+ "order_date": "04-May-2025",
366
+ "order_time": "09:54:22",
367
+ "restaurant_name": "IDC Kitchen",
368
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
369
+ "items": [
370
+ {
371
+ "name": "Masala Dosa",
372
+ "quantity": 1,
373
+ "price": 140
374
+ },
375
+ {
376
+ "name": "Idly 2 Pc",
377
+ "quantity": 1,
378
+ "price": 59
379
+ },
380
+ {
381
+ "name": "Thatte Idli",
382
+ "quantity": 1,
383
+ "price": 59
384
+ },
385
+ {
386
+ "name": "Vada (1 Pc)",
387
+ "quantity": 1,
388
+ "price": 58
389
+ }
390
+ ],
391
+ "total_price": 356
392
+ },
393
+ {
394
+ "email_number": 2,
395
+ "order_date": "04-May-2025",
396
+ "order_time": "10:21:33",
397
+ "restaurant_name": "Starbucks Coffee",
398
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
399
+ "items": [
400
+ {
401
+ "name": "Caffe Americano",
402
+ "quantity": 1,
403
+ "price": 315
404
+ },
405
+ {
406
+ "name": "Caffe Americano",
407
+ "quantity": 1,
408
+ "price": 355
409
+ }
410
+ ],
411
+ "total_price": 694
412
+ }
413
+ ],
414
+ "2025-05-05": [
415
+ {
416
+ "email_number": 1,
417
+ "order_date": "05-May-2025",
418
+ "order_time": "09:23:24",
419
+ "restaurant_name": "Starbucks Coffee",
420
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
421
+ "items": [
422
+ {
423
+ "name": "Caffe Americano",
424
+ "quantity": 1,
425
+ "price": 315
426
+ },
427
+ {
428
+ "name": "Caffe Americano",
429
+ "quantity": 1,
430
+ "price": 355
431
+ }
432
+ ],
433
+ "total_price": 694
434
+ },
435
+ {
436
+ "email_number": 2,
437
+ "order_date": "05-May-2025",
438
+ "order_time": "13:58:29",
439
+ "restaurant_name": "Maverick & Farmer Coffee",
440
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
441
+ "items": [
442
+ {
443
+ "name": "Cold Brew Latte",
444
+ "quantity": 1,
445
+ "price": 300
446
+ },
447
+ {
448
+ "name": "Smoked Tandoori Chicken",
449
+ "quantity": 1,
450
+ "price": 450
451
+ }
452
+ ],
453
+ "total_price": 730
454
+ },
455
+ {
456
+ "email_number": 3,
457
+ "order_date": "05-May-2025",
458
+ "order_time": "14:42:09",
459
+ "restaurant_name": "Magnolia Bakery",
460
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
461
+ "items": [
462
+ {
463
+ "name": "CLASSIC TRES LECHES",
464
+ "quantity": 1,
465
+ "price": 410
466
+ }
467
+ ],
468
+ "total_price": 538
469
+ },
470
+ {
471
+ "email_number": 4,
472
+ "order_date": "05-May-2025",
473
+ "order_time": "21:09:39",
474
+ "restaurant_name": "Hyderabad Biryaani House",
475
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
476
+ "items": [
477
+ {
478
+ "name": "Mutton Biryani Family Pack",
479
+ "quantity": 1,
480
+ "price": 749
481
+ }
482
+ ],
483
+ "total_price": 806
484
+ }
485
+ ],
486
+ "2025-05-06": [
487
+ {
488
+ "email_number": 1,
489
+ "order_date": "06-May-2025",
490
+ "order_time": "09:58:07",
491
+ "restaurant_name": "Swiggy Instamart",
492
+ "delivery_address": "2C, Orchard Green Apartment 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
493
+ "items": [
494
+ {
495
+ "name": "Yellaki Banana (Baalehannu)",
496
+ "quantity": 1,
497
+ "price": 59
498
+ },
499
+ {
500
+ "name": "Robusta Banana (Pachha Baalehannu)",
501
+ "quantity": 1,
502
+ "price": 30
503
+ },
504
+ {
505
+ "name": "Eggoz Farm Fresh High Protein White Eggs Box",
506
+ "quantity": 1,
507
+ "price": 325
508
+ },
509
+ {
510
+ "name": "Amul Processed Cheese Slices",
511
+ "quantity": 1,
512
+ "price": 145
513
+ },
514
+ {
515
+ "name": "NOTO Orange Sugar Free Popsicle Ice Cream",
516
+ "quantity": 2,
517
+ "price": 157.5
518
+ },
519
+ {
520
+ "name": "Rocket Leaves (Arugula)",
521
+ "quantity": 1,
522
+ "price": 54
523
+ },
524
+ {
525
+ "name": "Royal Gala Apple (Sebu)",
526
+ "quantity": 2,
527
+ "price": 254.6
528
+ },
529
+ {
530
+ "name": "NOTO Kala Jamun Sugar Free Popsicle Ice Cream",
531
+ "quantity": 2,
532
+ "price": 132.5
533
+ },
534
+ {
535
+ "name": "Imported Avocado - Tanzania",
536
+ "quantity": 1,
537
+ "price": 75
538
+ },
539
+ {
540
+ "name": "Ratnagiri Alphonso Mango (Hapus)",
541
+ "quantity": 1,
542
+ "price": 415
543
+ },
544
+ {
545
+ "name": "Indian Blueberries",
546
+ "quantity": 1,
547
+ "price": 199
548
+ },
549
+ {
550
+ "name": "Flyer Dil Foods",
551
+ "quantity": 1,
552
+ "price": 0
553
+ },
554
+ {
555
+ "name": "Premium Guava (Thai)",
556
+ "quantity": 1,
557
+ "price": 71
558
+ },
559
+ {
560
+ "name": "Lettuce Mix Salad",
561
+ "quantity": 2,
562
+ "price": 120
563
+ }
564
+ ],
565
+ "total_price": 2049
566
+ },
567
+ {
568
+ "email_number": 2,
569
+ "order_date": "06-May-2025",
570
+ "order_time": "10:51:28",
571
+ "restaurant_name": "Starbucks Coffee",
572
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
573
+ "items": [
574
+ {
575
+ "name": "Caffe Americano",
576
+ "quantity": 1,
577
+ "price": 355
578
+ },
579
+ {
580
+ "name": "Caffe Americano",
581
+ "quantity": 1,
582
+ "price": 315
583
+ }
584
+ ],
585
+ "total_price": 694
586
+ },
587
+ {
588
+ "email_number": 3,
589
+ "order_date": "06-May-2025",
590
+ "order_time": "11:06:59",
591
+ "restaurant_name": "Yogisthaan",
592
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
593
+ "items": [
594
+ {
595
+ "name": "Tapioca (sabu Dana) Khichadi",
596
+ "quantity": 1,
597
+ "price": 252
598
+ },
599
+ {
600
+ "name": "Sattu Paratha",
601
+ "quantity": 1,
602
+ "price": 288
603
+ }
604
+ ],
605
+ "total_price": 537
606
+ },
607
+ {
608
+ "email_number": 4,
609
+ "order_date": "06-May-2025",
610
+ "order_time": "15:05:22",
611
+ "restaurant_name": "Sweet Karam Coffee",
612
+ "delivery_address": "2C, Orchard Green Apartment 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
613
+ "items": [
614
+ {
615
+ "name": "Sweet Karam Coffee Tapioca Chips (Kappa) - No Palm Oil",
616
+ "quantity": 1,
617
+ "price": 65
618
+ },
619
+ {
620
+ "name": "Sweet Karam Coffee Special Madras Mixture (No Palm Oil)",
621
+ "quantity": 1,
622
+ "price": 90
623
+ },
624
+ {
625
+ "name": "Sweet Karam Coffee Peanut Chikki Bites (No White Sugar, No Liquid Glucose)",
626
+ "quantity": 1,
627
+ "price": 87
628
+ },
629
+ {
630
+ "name": "Mother's Recipe Potato Masala Papad",
631
+ "quantity": 4,
632
+ "price": 126.64
633
+ },
634
+ {
635
+ "name": "Sweet Karam Coffee Kerala Nendran Banana Chips",
636
+ "quantity": 1,
637
+ "price": 87.12
638
+ },
639
+ {
640
+ "name": "Iyer's Rice Papad Buy 1 Get 1 (inside one pack)",
641
+ "quantity": 1,
642
+ "price": 64
643
+ },
644
+ {
645
+ "name": "Ginger kombucha (Low cal, Low sugar)",
646
+ "quantity": 4,
647
+ "price": 368.28
648
+ }
649
+ ],
650
+ "total_price": 899
651
+ },
652
+ {
653
+ "email_number": 5,
654
+ "order_date": "06-May-2025",
655
+ "order_time": "22:36:46",
656
+ "restaurant_name": "Misu",
657
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India.",
658
+ "items": [
659
+ {
660
+ "name": "Spicy Chilli Basil Noodles Non-veg",
661
+ "quantity": 1,
662
+ "price": 465
663
+ },
664
+ {
665
+ "name": "Vietnamese Pho Chicken",
666
+ "quantity": 1,
667
+ "price": 305
668
+ },
669
+ {
670
+ "name": "Sour & Spicy Dumplings Chicken (6 Pcs)",
671
+ "quantity": 1,
672
+ "price": 405
673
+ }
674
+ ],
675
+ "total_price": 1117
676
+ }
677
+ ],
678
+ "2025-05-07": [
679
+ {
680
+ "email_number": 1,
681
+ "order_date": "07-May-2025",
682
+ "order_time": "13:26:32",
683
+ "restaurant_name": "Kale - A Salad Symphony",
684
+ "delivery_address": "Shobhit\n2nd Floor\nKariyammana Agrahara Road, Marathahalli, Bengaluru, Karnataka 560037, India. (Divyasree Technopolis)",
685
+ "items": [
686
+ {
687
+ "name": "Thai Chicken Bowl (nutrients & Vitamin B12)",
688
+ "quantity": 1,
689
+ "price": 425
690
+ },
691
+ {
692
+ "name": "Green Protein Smoothie",
693
+ "quantity": 1,
694
+ "price": 250
695
+ }
696
+ ],
697
+ "total_price": 693
698
+ },
699
+ {
700
+ "email_number": 2,
701
+ "order_date": "07-May-2025",
702
+ "order_time": "13:53:43",
703
+ "restaurant_name": "Chakum Chukum",
704
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
705
+ "items": [
706
+ {
707
+ "name": "Chicken Tikka Roll",
708
+ "quantity": 1,
709
+ "price": 237.15
710
+ },
711
+ {
712
+ "name": "Kasundi Paneer Roll",
713
+ "quantity": 1,
714
+ "price": 275.24
715
+ }
716
+ ],
717
+ "total_price": 518
718
+ },
719
+ {
720
+ "email_number": 3,
721
+ "order_date": "07-May-2025",
722
+ "order_time": "20:50:27",
723
+ "restaurant_name": "Lavonne Cafe",
724
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
725
+ "items": [
726
+ {
727
+ "name": "Sourdough Bread Plain",
728
+ "quantity": 1,
729
+ "price": 219.05
730
+ }
731
+ ],
732
+ "total_price": 41
733
+ },
734
+ {
735
+ "email_number": 4,
736
+ "order_date": "07-May-2025",
737
+ "order_time": "21:51:42",
738
+ "restaurant_name": "Basco And Fry",
739
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
740
+ "items": [
741
+ {
742
+ "name": "Truffle Shroom Burger",
743
+ "quantity": 1,
744
+ "price": 365
745
+ },
746
+ {
747
+ "name": "Peri Peri Wings",
748
+ "quantity": 1,
749
+ "price": 425
750
+ },
751
+ {
752
+ "name": "Chicken Katsu Burger",
753
+ "quantity": 1,
754
+ "price": 365
755
+ }
756
+ ],
757
+ "total_price": 1100
758
+ }
759
+ ],
760
+ "2025-05-08": [
761
+ {
762
+ "email_number": 1,
763
+ "order_date": "08-May-2025",
764
+ "order_time": "13:04:12",
765
+ "restaurant_name": "NATRAJ Chole bhature",
766
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
767
+ "items": [
768
+ {
769
+ "name": "Chole Bhature(full Plate)",
770
+ "quantity": 1,
771
+ "price": 225
772
+ },
773
+ {
774
+ "name": "Samosa(1pc)",
775
+ "quantity": 1,
776
+ "price": 45
777
+ }
778
+ ],
779
+ "total_price": 310
780
+ },
781
+ {
782
+ "email_number": 2,
783
+ "order_date": "08-May-2025",
784
+ "order_time": "14:27:04",
785
+ "restaurant_name": "Salad Days",
786
+ "delivery_address": "2nd Floor, Kariyammana Agrahara Road, Marathahalli, Bengaluru, Karnataka 560037, India. (Divyasree Technopolis)",
787
+ "items": [
788
+ {
789
+ "name": "Asian Chicken, Egg & Soba Noodle Salad",
790
+ "quantity": 1,
791
+ "price": 379
792
+ },
793
+ {
794
+ "name": "Green Pressed Juice",
795
+ "quantity": 1,
796
+ "price": 199
797
+ }
798
+ ],
799
+ "total_price": 655
800
+ },
801
+ {
802
+ "email_number": 3,
803
+ "order_date": "08-May-2025",
804
+ "order_time": "22:47:20",
805
+ "restaurant_name": "Mahesh Lunch Home",
806
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
807
+ "items": [
808
+ {
809
+ "name": "Appam",
810
+ "quantity": 2,
811
+ "price": 60
812
+ },
813
+ {
814
+ "name": "Chicken Ghee Roast",
815
+ "quantity": 1,
816
+ "price": 460
817
+ },
818
+ {
819
+ "name": "Butter Roti",
820
+ "quantity": 2,
821
+ "price": 80
822
+ },
823
+ {
824
+ "name": "Chicken Manglorean",
825
+ "quantity": 1,
826
+ "price": 405
827
+ },
828
+ {
829
+ "name": "Neer Dosa (4 Pcs)",
830
+ "quantity": 1,
831
+ "price": 80
832
+ },
833
+ {
834
+ "name": "Dal Fry",
835
+ "quantity": 1,
836
+ "price": 210
837
+ }
838
+ ],
839
+ "total_price": 1267
840
+ },
841
+ {
842
+ "email_number": 4,
843
+ "order_date": "08-May-2025",
844
+ "order_time": "23:41:54",
845
+ "restaurant_name": "Swiggy Instamart",
846
+ "delivery_address": "2C, Orchard Green Apartment 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
847
+ "items": [
848
+ {
849
+ "name": "NOTO Strawberry Raspberry Sugar Free Popsicle Ice Cream",
850
+ "quantity": 4,
851
+ "price": 325
852
+ },
853
+ {
854
+ "name": "NOTO Orange Sugar Free Popsicle Ice Cream",
855
+ "quantity": 2,
856
+ "price": 162.5
857
+ }
858
+ ],
859
+ "total_price": 498
860
+ }
861
+ ],
862
+ "2025-05-09": [
863
+ {
864
+ "email_number": 1,
865
+ "order_date": "09-May-2025",
866
+ "order_time": "15:22:57",
867
+ "restaurant_name": "Kale - A Salad Symphony",
868
+ "delivery_address": "Shobhit\n2nd Floor\nKariyammana Agrahara Road, Marathahalli, Bengaluru, Karnataka 560037, India. (Divyasree Technopolis)",
869
+ "items": [
870
+ {
871
+ "name": "Thai Chicken Bowl (nutrients & Vitamin B12)",
872
+ "quantity": 1,
873
+ "price": 425
874
+ },
875
+ {
876
+ "name": "Green Protein Smoothie",
877
+ "quantity": 1,
878
+ "price": 250
879
+ }
880
+ ],
881
+ "total_price": 693
882
+ },
883
+ {
884
+ "email_number": 2,
885
+ "order_date": "09-May-2025",
886
+ "order_time": "16:25:50",
887
+ "restaurant_name": "Swiggy Instamart",
888
+ "delivery_address": "2C, Orchard Green Apartment 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
889
+ "items": [
890
+ {
891
+ "name": "Kodai Parmesan Cheese",
892
+ "quantity": 1,
893
+ "price": 475
894
+ }
895
+ ],
896
+ "total_price": 487
897
+ }
898
+ ],
899
+ "2025-05-10": [
900
+ {
901
+ "email_number": 1,
902
+ "order_date": "10-May-2025",
903
+ "order_time": "13:34:39",
904
+ "restaurant_name": "Swiggy Instamart",
905
+ "delivery_address": "2C, Orchard Green Apartment 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
906
+ "items": [
907
+ {
908
+ "name": "Gooseberry (Nellikaayi)",
909
+ "quantity": 1,
910
+ "price": 39
911
+ },
912
+ {
913
+ "name": "Fresh Turmeric",
914
+ "quantity": 2,
915
+ "price": 42
916
+ },
917
+ {
918
+ "name": "Licious Chicken Curry Cut (Large Pieces) - Skinless",
919
+ "quantity": 1,
920
+ "price": 165
921
+ },
922
+ {
923
+ "name": "White Radish (Moolangi)",
924
+ "quantity": 2,
925
+ "price": 30.6
926
+ },
927
+ {
928
+ "name": "English Cucumber (Sowthekaayi)",
929
+ "quantity": 2,
930
+ "price": 65.8
931
+ },
932
+ {
933
+ "name": "Robusta Banana (Pachha Baalehannu)",
934
+ "quantity": 1,
935
+ "price": 44
936
+ },
937
+ {
938
+ "name": "Curry Leaves (Karibevu)",
939
+ "quantity": 1,
940
+ "price": 11
941
+ },
942
+ {
943
+ "name": "Green Chilli (Hasiru Menasinakaayi)",
944
+ "quantity": 1,
945
+ "price": 12
946
+ },
947
+ {
948
+ "name": "Coriander - Without Roots (Kotthambari)",
949
+ "quantity": 1,
950
+ "price": 18
951
+ },
952
+ {
953
+ "name": "Ginger (Shunti)",
954
+ "quantity": 1,
955
+ "price": 16
956
+ },
957
+ {
958
+ "name": "Premium Guava (Thai)",
959
+ "quantity": 2,
960
+ "price": 131.4
961
+ },
962
+ {
963
+ "name": "Royal Gala Apple (Sebu)",
964
+ "quantity": 2,
965
+ "price": 275
966
+ }
967
+ ],
968
+ "total_price": 862
969
+ },
970
+ {
971
+ "email_number": 2,
972
+ "order_date": "10-May-2025",
973
+ "order_time": "17:23:45",
974
+ "restaurant_name": "Irani Std. Tea",
975
+ "delivery_address": "Swiggy,Tower D, 9th Floor, IBC Knowledge Park, Bannerghatta Road, Bangalore - 560029",
976
+ "items": [],
977
+ "total_price": 291
978
+ },
979
+ {
980
+ "email_number": 3,
981
+ "order_date": "10-May-2025",
982
+ "order_time": "18:05:00",
983
+ "restaurant_name": "Irani Std. Tea",
984
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India",
985
+ "items": [
986
+ {
987
+ "name": "Irani Ginger Chai",
988
+ "quantity": 1,
989
+ "price": 219
990
+ },
991
+ {
992
+ "name": "Osmania Biscuits 100 Grams",
993
+ "quantity": 1,
994
+ "price": 100
995
+ },
996
+ {
997
+ "name": "Bun Maska",
998
+ "quantity": 2,
999
+ "price": 158
1000
+ }
1001
+ ],
1002
+ "total_price": 399
1003
+ }
1004
+ ],
1005
+ "2025-05-11": [
1006
+ {
1007
+ "email_number": 1,
1008
+ "order_date": "11-May-2025",
1009
+ "order_time": "12:36:17",
1010
+ "restaurant_name": "Anand Sweets & Savouries",
1011
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India.",
1012
+ "items": [
1013
+ {
1014
+ "name": "Shahi Tohfa Dry Fruits 750 Gms",
1015
+ "quantity": 1,
1016
+ "price": 1022.32
1017
+ }
1018
+ ],
1019
+ "total_price": 1167
1020
+ },
1021
+ {
1022
+ "email_number": 2,
1023
+ "order_date": "11-May-2025",
1024
+ "order_time": "21:17:18",
1025
+ "restaurant_name": "Hotel Empire",
1026
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
1027
+ "items": [
1028
+ {
1029
+ "name": "Paneer Butter Masala",
1030
+ "quantity": 1,
1031
+ "price": 252
1032
+ },
1033
+ {
1034
+ "name": "Kerala Parotta",
1035
+ "quantity": 1,
1036
+ "price": 39
1037
+ },
1038
+ {
1039
+ "name": "Coin Parotta",
1040
+ "quantity": 2,
1041
+ "price": 64
1042
+ },
1043
+ {
1044
+ "name": "Dal Fry",
1045
+ "quantity": 1,
1046
+ "price": 137
1047
+ },
1048
+ {
1049
+ "name": "Ghee Rice",
1050
+ "quantity": 1,
1051
+ "price": 110
1052
+ },
1053
+ {
1054
+ "name": "Malabar Parotta",
1055
+ "quantity": 2,
1056
+ "price": 70
1057
+ }
1058
+ ],
1059
+ "total_price": 749
1060
+ }
1061
+ ],
1062
+ "2025-05-12": [
1063
+ {
1064
+ "email_number": 1,
1065
+ "order_date": "12-May-2025",
1066
+ "order_time": "22:12:42",
1067
+ "restaurant_name": "Swiggy Instamart",
1068
+ "delivery_address": "2C, Orchard Green Apartment 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
1069
+ "items": [
1070
+ {
1071
+ "name": "NOTO Strawberry Raspberry Sugar Free Popsicle Ice Cream",
1072
+ "quantity": 4,
1073
+ "price": 275
1074
+ },
1075
+ {
1076
+ "name": "NOTO Orange Sugar Free Popsicle Ice Cream",
1077
+ "quantity": 2,
1078
+ "price": 137.5
1079
+ }
1080
+ ],
1081
+ "total_price": 423
1082
+ }
1083
+ ],
1084
+ "2025-05-13": [],
1085
+ "2025-05-14": [
1086
+ {
1087
+ "email_number": 1,
1088
+ "order_date": "14-May-2025",
1089
+ "order_time": "14:14:14",
1090
+ "restaurant_name": "Swiggy Instamart",
1091
+ "delivery_address": "2C, Orchard Green Apartment 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
1092
+ "items": [
1093
+ {
1094
+ "name": "Robusta Banana (Pachha Baalehannu)",
1095
+ "quantity": 1,
1096
+ "price": 42
1097
+ },
1098
+ {
1099
+ "name": "Coriander - Without Roots (Kotthambari)",
1100
+ "quantity": 1,
1101
+ "price": 18
1102
+ },
1103
+ {
1104
+ "name": "Tata Sampann Turmeric Powder Masala",
1105
+ "quantity": 2,
1106
+ "price": 85.04
1107
+ },
1108
+ {
1109
+ "name": "Organic Certified Onion (Eerulli)",
1110
+ "quantity": 1,
1111
+ "price": 66
1112
+ },
1113
+ {
1114
+ "name": "NOTO Strawberry Raspberry Sugar Free Popsicle Ice Cream",
1115
+ "quantity": 4,
1116
+ "price": 275
1117
+ },
1118
+ {
1119
+ "name": "Premium Guava (Thai)",
1120
+ "quantity": 2,
1121
+ "price": 154
1122
+ },
1123
+ {
1124
+ "name": "Garlic (Bellulli)",
1125
+ "quantity": 1,
1126
+ "price": 47
1127
+ },
1128
+ {
1129
+ "name": "Royal Gala Apple (Sebu)",
1130
+ "quantity": 1,
1131
+ "price": 142
1132
+ }
1133
+ ],
1134
+ "total_price": 841
1135
+ }
1136
+ ],
1137
+ "2025-05-15": [],
1138
+ "2025-05-16": [
1139
+ {
1140
+ "email_number": 1,
1141
+ "order_date": "16-May-2025",
1142
+ "order_time": "15:43:43",
1143
+ "restaurant_name": "Glen's Bakehouse",
1144
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
1145
+ "items": [
1146
+ {
1147
+ "name": "Mushroom Puff",
1148
+ "quantity": 1,
1149
+ "price": 62.86
1150
+ },
1151
+ {
1152
+ "name": "Chicken Puff",
1153
+ "quantity": 1,
1154
+ "price": 84.23
1155
+ }
1156
+ ],
1157
+ "total_price": 235
1158
+ },
1159
+ {
1160
+ "email_number": 2,
1161
+ "order_date": "16-May-2025",
1162
+ "order_time": "15:48:57",
1163
+ "restaurant_name": "The Himalayan Momo Company",
1164
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
1165
+ "items": [
1166
+ {
1167
+ "name": "Woked Maggi",
1168
+ "quantity": 1,
1169
+ "price": 209
1170
+ },
1171
+ {
1172
+ "name": "Himalayan Steamed Chicken Momos",
1173
+ "quantity": 2,
1174
+ "price": 318
1175
+ }
1176
+ ],
1177
+ "total_price": 547
1178
+ }
1179
+ ],
1180
+ "2025-05-18": [
1181
+ {
1182
+ "email_number": 1,
1183
+ "order_date": "18-May-2025",
1184
+ "order_time": "12:57:21",
1185
+ "restaurant_name": "Starbucks Coffee",
1186
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
1187
+ "items": [
1188
+ {
1189
+ "name": "Caffe Americano",
1190
+ "quantity": 1,
1191
+ "price": 315
1192
+ }
1193
+ ],
1194
+ "total_price": 363
1195
+ },
1196
+ {
1197
+ "email_number": 2,
1198
+ "order_date": "18-May-2025",
1199
+ "order_time": "13:02:51",
1200
+ "restaurant_name": "Maiz Mexican Kitchen",
1201
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
1202
+ "items": [
1203
+ {
1204
+ "name": "Chips With Guacamole",
1205
+ "quantity": 1,
1206
+ "price": 249
1207
+ },
1208
+ {
1209
+ "name": "Fresh Tomato Salsa (50ml)",
1210
+ "quantity": 1,
1211
+ "price": 69
1212
+ },
1213
+ {
1214
+ "name": "Chipotle Chicken Burrito",
1215
+ "quantity": 1,
1216
+ "price": 299
1217
+ }
1218
+ ],
1219
+ "total_price": 491
1220
+ }
1221
+ ],
1222
+ "2025-05-20": [
1223
+ {
1224
+ "email_number": 1,
1225
+ "order_date": "20-May-2025",
1226
+ "order_time": "11:24:05",
1227
+ "restaurant_name": "IDC Kitchen",
1228
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
1229
+ "items": [
1230
+ {
1231
+ "name": "Vada (1 Pc)",
1232
+ "quantity": 1,
1233
+ "price": 58
1234
+ },
1235
+ {
1236
+ "name": "Masala Dosa",
1237
+ "quantity": 1,
1238
+ "price": 140
1239
+ }
1240
+ ],
1241
+ "total_price": 167
1242
+ },
1243
+ {
1244
+ "email_number": 2,
1245
+ "order_date": "20-May-2025",
1246
+ "order_time": "16:15:50",
1247
+ "restaurant_name": "Irani Std. Tea",
1248
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
1249
+ "items": [
1250
+ {
1251
+ "name": "Bun Omelette",
1252
+ "quantity": 1,
1253
+ "price": 139
1254
+ },
1255
+ {
1256
+ "name": "Osmania Biscuits 100 Grams",
1257
+ "quantity": 1,
1258
+ "price": 100
1259
+ },
1260
+ {
1261
+ "name": "Plain Maggie",
1262
+ "quantity": 1,
1263
+ "price": 119
1264
+ },
1265
+ {
1266
+ "name": "Bun Maska",
1267
+ "quantity": 1,
1268
+ "price": 79
1269
+ },
1270
+ {
1271
+ "name": "Irani Ginger Chai",
1272
+ "quantity": 1,
1273
+ "price": 219
1274
+ },
1275
+ {
1276
+ "name": "Aloo Samosa",
1277
+ "quantity": 1,
1278
+ "price": 49
1279
+ }
1280
+ ],
1281
+ "total_price": 627
1282
+ },
1283
+ {
1284
+ "email_number": 3,
1285
+ "order_date": "20-May-2025",
1286
+ "order_time": "20:13:33",
1287
+ "restaurant_name": "Gayatri Sandwich(Mithibai College)",
1288
+ "delivery_address": "Shobhit, ground floor, Vile Parle East, Vile Parle, Mumbai, Maharashtra, India. (T1)",
1289
+ "items": [
1290
+ {
1291
+ "name": "Sada Sandwich",
1292
+ "quantity": 1,
1293
+ "price": 50
1294
+ },
1295
+ {
1296
+ "name": "Vada Pav",
1297
+ "quantity": 1,
1298
+ "price": 25
1299
+ }
1300
+ ],
1301
+ "total_price": 178
1302
+ }
1303
+ ],
1304
+ "2025-05-21": [
1305
+ {
1306
+ "email_number": 1,
1307
+ "order_date": "21-May-2025",
1308
+ "order_time": "12:56:56",
1309
+ "restaurant_name": "Starbucks Coffee",
1310
+ "delivery_address": "Shobhit\n2C, Orchard Green Apartment\n2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
1311
+ "items": [
1312
+ {
1313
+ "name": "Cold Brew Black (Cold Brew)",
1314
+ "quantity": 1,
1315
+ "price": 390
1316
+ }
1317
+ ],
1318
+ "total_price": 401
1319
+ },
1320
+ {
1321
+ "email_number": 2,
1322
+ "order_date": "21-May-2025",
1323
+ "order_time": "12:58:49",
1324
+ "restaurant_name": "Starbucks Coffee",
1325
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
1326
+ "items": [
1327
+ {
1328
+ "name": "Caffe Americano",
1329
+ "quantity": 1,
1330
+ "price": 315
1331
+ }
1332
+ ],
1333
+ "total_price": 363
1334
+ },
1335
+ {
1336
+ "email_number": 3,
1337
+ "order_date": "21-May-2025",
1338
+ "order_time": "22:07:56",
1339
+ "restaurant_name": "Magnolia Bakery",
1340
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
1341
+ "items": [
1342
+ {
1343
+ "name": "Chocolate Cake with Chocolate Buttercream Cake Slice",
1344
+ "quantity": 1,
1345
+ "price": 260
1346
+ },
1347
+ {
1348
+ "name": "CLASSIC TRES LECHES",
1349
+ "quantity": 1,
1350
+ "price": 410
1351
+ }
1352
+ ],
1353
+ "total_price": 850
1354
+ }
1355
+ ],
1356
+ "2025-05-22": [
1357
+ {
1358
+ "email_number": 1,
1359
+ "order_date": "22-May-2025",
1360
+ "order_time": "12:00:34",
1361
+ "restaurant_name": "Yogisthaan",
1362
+ "delivery_address": "2C, Orchard Green Apartment, 2nd Main Rd, Domlur, Bangalore, Karnataka 560071, India. (Orchard Green)",
1363
+ "items": [
1364
+ {
1365
+ "name": "Poha (quick Of Breakfast)",
1366
+ "quantity": 1,
1367
+ "price": 288
1368
+ },
1369
+ {
1370
+ "name": "Tapioca (sabu Dana) Khichadi",
1371
+ "quantity": 1,
1372
+ "price": 252
1373
+ }
1374
+ ],
1375
+ "total_price": 547
1376
+ }
1377
+ ],
1378
+ "2025-05-23": []
1379
+ }
mcp/server/swiggy_scraper.py ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Reusable helper to fetch Swiggy order e-mails and return a list[dict].
3
+
4
+ Usage:
5
+ from swiggy_scraper import fetch_swiggy_orders
6
+ orders = fetch_swiggy_orders("17-May-2025", "20-May-2025")
7
+ """
8
+
9
+ import os, imaplib, json
10
+ from email import message_from_bytes
11
+ from bs4 import BeautifulSoup
12
+ from openai import OpenAI
13
+ from dotenv import load_dotenv
14
+ from datetime import datetime, timedelta
15
+ from email.utils import parsedate_to_datetime
16
+ from zoneinfo import ZoneInfo
17
+
18
+ from db_schema import init_db, get_orders_by_date_from_db, save_orders_to_db
19
+
20
+
21
+ load_dotenv()
22
+
23
+ APP_PASSWORD = os.getenv("APP_PASSWORD")
24
+ EMAIL_ID = os.getenv("EMAIL_ID")
25
+ OPENAI_KEY = os.getenv("OPENAI_API_KEY")
26
+
27
+ client = OpenAI(api_key=OPENAI_KEY)
28
+
29
+ def _imap_connect():
30
+ m = imaplib.IMAP4_SSL("imap.gmail.com")
31
+ m.login(EMAIL_ID, APP_PASSWORD)
32
+ m.select('"[Gmail]/All Mail"')
33
+ return m
34
+
35
+ def _email_to_clean_text(msg):
36
+ html = next(
37
+ (part.get_payload(decode=True).decode(errors="ignore")
38
+ for part in msg.walk()
39
+ if part.get_content_type() == "text/html"),
40
+ None,
41
+ )
42
+ if not html:
43
+ return ""
44
+ soup = BeautifulSoup(html, "html.parser")
45
+ for t in soup(["script", "style", "head", "meta", "link"]):
46
+ t.decompose()
47
+ return "\n".join(
48
+ line.strip() for line in soup.get_text("\n").splitlines() if line.strip()
49
+ )
50
+
51
+ def _get_all_dates(start_date: str, end_date: str):
52
+ start = datetime.strptime(start_date, "%d-%b-%Y")
53
+ end = datetime.strptime(end_date, "%d-%b-%Y")
54
+ delta = (end - start).days + 1
55
+ return [(start + timedelta(days=i)).strftime("%Y-%m-%d") for i in range(delta)]
56
+
57
+
58
+
59
+
60
+ def _extract_with_llm(email_number, subject, body, email_date, email_time):
61
+ current_email = {
62
+ "subject": subject,
63
+ "body": body
64
+ }
65
+
66
+ prompt = f"""
67
+ You are given a Swiggy order confirmation email with a subject and body.
68
+
69
+ Extract and return only the following:
70
+ - "restaurant_name": name of the restaurant
71
+ - "delivery_address": the delivery address
72
+ - "items": a list of ordered items, each with "name", "quantity", and "price" (number)
73
+ - "total_price": the total bill paid including taxes, charges, etc.
74
+
75
+ Example output format:
76
+ {{
77
+ "restaurant_name": "Dominos Pizza",
78
+ "delivery_address": "123 Main St, City",
79
+ "total_price": 567,
80
+ "items": [
81
+ {{ "name": "Veg Pizza", "quantity": 2, "price": 199 }},
82
+ {{ "name": "Coke", "quantity": 1, "price": 45 }}
83
+ ]
84
+ }}
85
+
86
+ Return only valid JSON. No extra text or comments.
87
+
88
+ {json.dumps(current_email, indent=2)}
89
+ """
90
+
91
+
92
+ try:
93
+ rsp = client.chat.completions.create(
94
+ model="gpt-4o-mini",
95
+ temperature=0,
96
+ messages=[
97
+ {"role": "system", "content": "You are a precise JSON extractor."},
98
+ {"role": "user", "content": prompt},
99
+ ],
100
+ )
101
+
102
+ # Attempt to parse the returned content
103
+ parsed_data = json.loads(rsp.choices[0].message.content)
104
+
105
+ # Wrap into final structure
106
+ final_output = {
107
+ "email_number": email_number,
108
+ "order_date": email_date,
109
+ "order_time": email_time,
110
+ "restaurant_name": parsed_data.get("restaurant_name", ""),
111
+ "delivery_address": parsed_data.get("delivery_address", ""),
112
+ "items": parsed_data.get("items", []),
113
+ "total_price": parsed_data.get("total_price", 0)
114
+ }
115
+
116
+
117
+ return final_output
118
+
119
+ except json.JSONDecodeError as json_err:
120
+ return {
121
+ "email_number": email_number,
122
+ "error": f"JSON decoding failed: {str(json_err)}",
123
+ "raw_response": rsp.choices[0].message.content if 'rsp' in locals() else None
124
+ }
125
+
126
+ except Exception as e:
127
+ return {
128
+ "email_number": email_number,
129
+ "error": f"Unexpected error: {str(e)}"
130
+ }
131
+
132
+
133
+
134
+ def fetch_swiggy_orders(start_date: str, end_date: str) -> list[dict]:
135
+ mail = _imap_connect()
136
+ all_dates = _get_all_dates(start_date, end_date)
137
+ orders = []
138
+
139
+ for date_str in all_dates:
140
+ # 1) Try loading from DB
141
+ day_orders = get_orders_by_date_from_db(date_str)
142
+ if day_orders:
143
+ print(f"{date_str} loaded from DB")
144
+ orders.extend(day_orders)
145
+ continue
146
+
147
+ # 2) Otherwise scrape emails for that date
148
+ print(f"Fetching Swiggy emails for {date_str}")
149
+ dt_obj = datetime.strptime(date_str, "%Y-%m-%d")
150
+ next_day = (dt_obj + timedelta(days=1)).strftime("%d-%b-%Y")
151
+ this_day = dt_obj.strftime("%d-%b-%Y")
152
+
153
+ crit = f'(FROM "[email protected]") SINCE "{this_day}" BEFORE "{next_day}"'
154
+ _, data = mail.search(None, crit)
155
+ ids = data[0].split()
156
+
157
+ scraped_orders = []
158
+ for idx, eid in enumerate(ids, 1):
159
+ _, msg_data = mail.fetch(eid, "(RFC822)")
160
+ msg = message_from_bytes(msg_data[0][1])
161
+ subject = msg.get("Subject", "")
162
+ body_text = _email_to_clean_text(msg)
163
+
164
+ try:
165
+ dt_obj = parsedate_to_datetime(msg["Date"]).astimezone(ZoneInfo("Asia/Kolkata"))
166
+ email_date = dt_obj.strftime("%d-%b-%Y")
167
+ email_time = dt_obj.strftime("%H:%M:%S")
168
+
169
+ order = _extract_with_llm(idx, subject, body_text, email_date, email_time)
170
+ scraped_orders.append(order)
171
+ except Exception as exc:
172
+ scraped_orders.append({"email_number": idx, "error": str(exc)})
173
+
174
+ # 3) Save newly scraped data to DB
175
+ save_orders_to_db(date_str, scraped_orders)
176
+ orders.extend(scraped_orders)
177
+
178
+ mail.logout()
179
+ return orders