-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser_ui.py
More file actions
408 lines (340 loc) · 15.6 KB
/
browser_ui.py
File metadata and controls
408 lines (340 loc) · 15.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
import streamlit as st
import pandas as pd
import random
import os
import json
from datetime import datetime
# Optional imports for Notion integration
try:
from notion_client import Client
NOTION_AVAILABLE = True
except ImportError:
NOTION_AVAILABLE = False
# Configuration
st.set_page_config(
page_title="Chrome Extension Idea Generator",
layout="wide",
initial_sidebar_state="expanded"
)
# Custom styling
st.markdown("""
<style>
.main-header {
font-size: 2.5rem;
color: #4F8BF9;
margin-bottom: 1rem;
}
.idea-card {
background-color: #f8f9fa;
border-radius: 5px;
padding: 20px;
margin-bottom: 10px;
border-left: 5px solid #4F8BF9;
}
.trend-badge {
background-color: #28a745;
color: white;
padding: 2px 8px;
border-radius: 10px;
font-size: 0.8rem;
}
.highlight {
background-color: #ffff99;
padding: 0 4px;
}
</style>
""", unsafe_allow_html=True)
# Function to load data
@st.cache_data
def load_data():
try:
keywords_df = pd.read_csv("keywords.csv")
wordbank_df = pd.read_csv("wordbank.csv")
mashup_df = pd.read_csv("mashup_ideas.csv")
return keywords_df, wordbank_df, mashup_df
except Exception as e:
st.error(f"Error loading data: {e}")
return None, None, None
# Function to connect to Notion (if available)
def connect_to_notion():
if not NOTION_AVAILABLE:
st.sidebar.warning("Notion client not installed. Run: pip install notion-client")
return None
notion_key = st.sidebar.text_input("Notion API Key", type="password")
database_id = st.sidebar.text_input("Notion Database ID")
if notion_key and database_id:
try:
notion = Client(auth=notion_key)
# Test the connection
notion.databases.retrieve(database_id)
st.sidebar.success("✅ Connected to Notion!")
return notion, database_id
except Exception as e:
st.sidebar.error(f"❌ Error connecting to Notion: {str(e)}")
return None, None
# Function to push idea to Notion
def push_idea_to_notion(notion, database_id, idea_data):
if not notion or not database_id:
return False, "Notion connection not established"
try:
# Extract data from idea
idea_name = idea_data.get("hybrid_idea", "")
keyword1 = idea_data.get("keyword1", "")
keyword2 = idea_data.get("keyword2", "")
niche = idea_data.get("niche", "")
trend_score = idea_data.get("trend_score", 5)
features = idea_data.get("features", [])
# Create Notion page
response = notion.pages.create(
parent={"database_id": database_id},
properties={
"Name": {"title": [{"text": {"content": idea_name}}]},
"Keyword Search Potential": {"number": trend_score},
"Tags": {"multi_select": [
{"name": keyword1},
{"name": keyword2}
]},
"Who Needs This?": {"select": {"name": niche}},
"User Pain Point": {"rich_text": [{"text": {"content": f"Solution that combines {keyword1} and {keyword2} for {niche}"}}]},
"Created By AI": {"checkbox": True},
"Date Generated": {"date": {"start": datetime.now().isoformat()}}
}
)
return True, response
except Exception as e:
return False, str(e)
# Function to generate feature ideas using keywords
def generate_features(keyword1, keyword2, niche):
features = [
f"Seamless {keyword1.lower()} integration with popular {keyword2.lower()} tools",
f"One-click {keyword1.lower()} export to {keyword2.lower()} platforms",
f"Custom dashboard for tracking {keyword1.lower()} metrics focused on {niche}",
f"Smart alerts when {keyword2.lower()} opportunities arise",
f"AI-powered suggestions to improve {keyword1.lower()} efficiency"
]
return features
# Function to analyze trends (simulation)
def analyze_trend(keyword1, keyword2, niche):
# This would be replaced with actual API calls in production
seed = hash(f"{keyword1}{keyword2}{niche}") % 100
random.seed(seed)
trend_score = random.randint(1, 10)
growth = random.randint(-20, 50)
return {
"score": trend_score,
"growth": growth,
"insights": [
f"{keyword1} is trending strongly in browser extensions" if trend_score > 7 else f"{keyword1} has moderate interest",
f"{keyword2} shows {growth}% growth in the past 30 days" if growth > 0 else f"{keyword2} is declining by {abs(growth)}%",
f"The {niche} audience is highly engaged with browser tools" if trend_score > 5 else f"The {niche} market needs more targeted solutions"
]
}
# Function to save idea for later
def save_idea(idea_data):
saved_file = "saved_ideas.json"
# Load existing saved ideas
if os.path.exists(saved_file):
with open(saved_file, "r") as f:
try:
saved_ideas = json.load(f)
except:
saved_ideas = []
else:
saved_ideas = []
# Add new idea with timestamp
idea_data["timestamp"] = datetime.now().isoformat()
saved_ideas.append(idea_data)
# Save back to file
with open(saved_file, "w") as f:
json.dump(saved_ideas, f, indent=2)
return len(saved_ideas)
# Main application
def main():
# Load data
keywords_df, wordbank_df, mashup_df = load_data()
if keywords_df is None:
st.error("Failed to load required data files. Please check your CSV files.")
return
# Connect to Notion (optional)
st.sidebar.title("🔌 Integrations")
notion_tab, saved_tab = st.sidebar.tabs(["Notion", "Saved Ideas"])
with notion_tab:
notion, database_id = connect_to_notion()
# App title and description
st.markdown("<h1 class='main-header'>🚀 Chrome Extension Idea Generator</h1>", unsafe_allow_html=True)
st.markdown("""
Generate innovative Chrome extension ideas by combining different keywords and niches.
These hybrid ideas can help you discover untapped opportunities in the browser extension market.
""")
# Main tabs
idea_tab, trend_tab, advanced_tab = st.tabs(["💡 Idea Generator", "📈 Trend Analysis", "🔍 Advanced Tools"])
# Idea Generator Tab
with idea_tab:
col1, col2 = st.columns([3, 2])
with col1:
st.subheader("Quick Idea Generation")
if st.button("🔄 Generate 5 Random Ideas", use_container_width=True):
st.session_state.ideas = mashup_df.sample(5).reset_index(drop=True)
st.session_state.show_ideas = True
if "show_ideas" in st.session_state and st.session_state.show_ideas:
for index, row in st.session_state.ideas.iterrows():
hybrid_idea = row['Hybrid Idea']
keyword1 = row['Keyword 1']
keyword2 = row['Keyword 2']
niche = row['Niche']
# Get trend analysis
trend = analyze_trend(keyword1, keyword2, niche)
features = generate_features(keyword1, keyword2, niche)
# Create idea card
st.markdown(f"""
<div class='idea-card'>
<h3>Idea #{index+1}: {hybrid_idea}</h3>
<p><strong>Trend Score:</strong> <span class='trend-badge'>{trend['score']}/10</span></p>
<p><strong>Keywords:</strong> {keyword1} + {keyword2}</p>
<p><strong>Target Audience:</strong> {niche}</p>
<details>
<summary>Suggested Features</summary>
<ul>
{"".join([f"<li>{feature}</li>" for feature in features])}
</ul>
</details>
</div>
""", unsafe_allow_html=True)
col_a, col_b, col_c = st.columns([1, 1, 1])
idea_data = {
"hybrid_idea": hybrid_idea,
"keyword1": keyword1,
"keyword2": keyword2,
"niche": niche,
"trend_score": trend["score"],
"features": features
}
with col_a:
if notion and database_id and st.button(f"Push to Notion #{index+1}"):
success, response = push_idea_to_notion(notion, database_id, idea_data)
if success:
st.success("✅ Pushed to Notion!")
else:
st.error(f"❌ Error: {response}")
with col_b:
if st.button(f"Save Idea #{index+1}"):
count = save_idea(idea_data)
st.success(f"✅ Saved! You have {count} saved ideas.")
with col_c:
if st.button(f"Expand Idea #{index+1}"):
st.session_state.expanded_idea = idea_data
st.session_state.show_expanded = True
with col2:
st.subheader("Custom Idea Builder")
keyword1 = st.selectbox("Keyword 1", keywords_df["Keyword"])
keyword2 = st.selectbox("Keyword 2", keywords_df["Keyword"], index=1 if len(keywords_df) > 1 else 0)
niche = st.selectbox("Target Niche", wordbank_df["Niche"])
if st.button("🧠 Build Custom Idea", use_container_width=True):
hybrid_idea = f"{keyword1} + {keyword2} for {niche}"
# Get trend analysis
trend = analyze_trend(keyword1, keyword2, niche)
features = generate_features(keyword1, keyword2, niche)
idea_data = {
"hybrid_idea": hybrid_idea,
"keyword1": keyword1,
"keyword2": keyword2,
"niche": niche,
"trend_score": trend["score"],
"features": features
}
st.session_state.custom_idea = idea_data
st.session_state.show_custom = True
if "show_custom" in st.session_state and st.session_state.show_custom:
idea = st.session_state.custom_idea
st.markdown(f"""
<div class='idea-card'>
<h3>{idea['hybrid_idea']}</h3>
<p><strong>Trend Score:</strong> <span class='trend-badge'>{idea['trend_score']}/10</span></p>
</div>
""", unsafe_allow_html=True)
with st.expander("Suggested Features"):
for feature in idea['features']:
st.markdown(f"- {feature}")
col_x, col_y = st.columns(2)
with col_x:
if notion and database_id and st.button("Push to Notion"):
success, response = push_idea_to_notion(notion, database_id, idea)
if success:
st.success("✅ Pushed to Notion!")
else:
st.error(f"❌ Error: {response}")
with col_y:
if st.button("Save This Idea"):
count = save_idea(idea)
st.success(f"✅ Saved! You have {count} saved ideas.")
# Trend Analysis Tab
with trend_tab:
st.subheader("Chrome Extension Market Trends")
col_trend1, col_trend2 = st.columns([2, 3])
with col_trend1:
st.markdown("""
### Top Trending Categories
1. **AI Tools** - Score: 9.2/10
2. **Productivity** - Score: 8.7/10
3. **Privacy & Security** - Score: 8.5/10
4. **Remote Work** - Score: 8.3/10
5. **Shopping** - Score: 7.9/10
### Growth Metrics
* **AI Tools**: +45% (30 days)
* **Productivity**: +22% (30 days)
* **Privacy & Security**: +18% (30 days)
* **Remote Work**: +15% (30 days)
""")
with col_trend2:
st.markdown("""
### Market Insights
* **AI-powered features** are seeing the highest growth rate in browser extensions
* Extensions targeting **remote workers** show consistent user acquisition
* **Privacy-focused** extensions have strong retention rates
* Extensions with **hybrid functionality** (combining two or more core features) are gaining popularity
* **Integration capabilities** with popular tools are a key differentiator
### Monetization Patterns
* Freemium model with premium features remains the dominant strategy
* Subscription-based extensions succeed when providing continuous value
* Enterprise licensing is growing for team-focused productivity tools
""")
# Advanced Tools Tab
with advanced_tab:
st.subheader("Advanced Tools")
st.markdown("""
### API Integration
Connect to external APIs to enhance your Chrome extension ideas:
1. **OpenAI API** - Generate creative extension descriptions and features
2. **Google Trends API** - Get real-time trend data for keywords
3. **Reddit API** - Analyze discussions about browser extensions
4. **Chrome Web Store API** - Study competitors and market gaps
""")
st.markdown("""
### Idea Scoring
Our AI-powered idea scoring system evaluates extension ideas based on:
* **Market Potential** - Size of the target audience
* **Competition Level** - Saturation in the market
* **Implementation Complexity** - Technical difficulty
* **Monetization Potential** - Revenue generation options
* **Trend Alignment** - Matching current market trends
""")
# Saved Ideas Tab (Sidebar)
with saved_tab:
if os.path.exists("saved_ideas.json"):
with open("saved_ideas.json", "r") as f:
try:
saved_ideas = json.load(f)
st.write(f"You have {len(saved_ideas)} saved ideas")
for i, idea in enumerate(saved_ideas):
st.markdown(f"""
<div style='padding: 10px; border-bottom: 1px solid #ddd;'>
<p><strong>{idea.get('hybrid_idea', 'Unnamed Idea')}</strong></p>
<p>Saved on: {idea.get('timestamp', 'Unknown date')[:10]}</p>
</div>
""", unsafe_allow_html=True)
except:
st.write("No saved ideas found")
else:
st.write("No saved ideas yet")
if __name__ == "__main__":
main()