mgbam commited on
Commit
c5676bf
Β·
verified Β·
1 Parent(s): 9140d68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +69 -69
app.py CHANGED
@@ -1,24 +1,24 @@
1
  import os
2
-
3
  import streamlit as st
4
- from landing import show_landing_content
5
  from agent_manager import AgentManager
 
6
  from dashboard.logs import show_logs
7
  from stripe_checkout import create_stripe_session
8
- from shopify_client import create_shopify_product
9
 
10
  # ────────────────────────────────────────────────────────────────────────────────
11
- # 1. GLOBAL CONFIGURATION
12
  # ────────────────────────────────────────────────────────────────────────────────
13
  st.set_page_config(
14
- page_title="AutoExec AI",
15
  page_icon="πŸš€",
16
  layout="wide",
17
  initial_sidebar_state="expanded",
18
  )
19
 
20
  # ────────────────────────────────────────────────────────────────────────────────
21
- # 2. NAVIGATION SETUP
22
  # ────────────────────────────────────────────────────────────────────────────────
23
  PAGES = {
24
  "Home": "🏠 Home",
@@ -27,27 +27,25 @@ PAGES = {
27
  "Settings": "βš™οΈ Settings"
28
  }
29
 
30
- if "current_page" not in st.session_state:
31
- st.session_state.current_page = "Home"
32
-
33
- def render_sidebar() -> str:
34
- st.sidebar.title("AutoExec AI")
35
- choice = st.sidebar.radio(
36
- "Navigate to:",
37
- options=list(PAGES.values()),
38
- index=list(PAGES.values()).index(PAGES[st.session_state.current_page]),
39
- key="nav_radio"
40
- )
41
- # reverse‐lookup internal key
42
- return next(k for k, v in PAGES.items() if v == choice)
43
 
44
- st.session_state.current_page = render_sidebar()
 
 
 
 
 
 
 
 
45
 
46
  # ────────────────────────────────────────────────────────────────────────────────
47
  # 3. PAGE DISPATCHER
48
  # ────────────────────────────────────────────────────────────────────────────────
49
  def main():
50
- page = st.session_state.current_page
 
51
  if page == "Home":
52
  render_home()
53
  elif page == "Launch":
@@ -57,7 +55,7 @@ def main():
57
  elif page == "Settings":
58
  render_settings()
59
  else:
60
- st.error("Page not found!")
61
 
62
  # ────────────────────────────────────────────────────────────────────────────────
63
  # 4. PAGE RENDERERS
@@ -65,60 +63,65 @@ def main():
65
  def render_home():
66
  st.markdown(
67
  """
68
- <div style="text-align:center; margin:2rem 0;">
69
- <h1 style="font-size:3rem;">πŸš€ AutoExec AI</h1>
70
- <p style="font-size:1.25rem; color:#555;">
71
- Launch, manage, and optimize AI‑powered businesses with a single click.
72
- </p>
 
73
  </div>
74
- """,
75
- unsafe_allow_html=True,
76
  )
77
- show_landing_content()
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
  def render_launch():
80
  st.markdown("## πŸš€ Launch a New AI Business")
81
  with st.form("launch_form"):
82
- niche = st.text_input(
83
- "🎯 Niche",
84
- placeholder="e.g., fitness wear",
85
- help="Define the market or audience for your business.",
86
- )
87
  business_type = st.selectbox(
88
  "πŸ“¦ Business Type",
89
- options=["Dropshipping", "Print-on-Demand", "Newsletter", "Course"],
90
- help="Select the type of business model to generate.",
91
  )
92
  submit = st.form_submit_button("Generate & Deploy")
93
-
94
  if submit:
95
  if not niche.strip():
96
- st.warning("Please enter a valid niche.")
97
  return
98
 
99
- # 1) Run the AI agents
100
- with st.spinner("πŸ€– Running AI agents..."):
101
  manager = AgentManager(niche.strip(), business_type)
102
  results = manager.run_all()
 
103
  st.success("βœ… Business Launched Successfully!")
104
  st.json(results)
105
 
106
- # 2) Publish to Shopify
107
- st.markdown("### πŸ›οΈ Publishing Product to Shopify")
108
- product_title = f"{business_type} in {niche}"
109
- product_desc = results.get("copy", "")
110
- price_str = "49.00" # default price
111
- image_url = None
112
-
113
  try:
114
- shopify_url = create_shopify_product(
115
- title=product_title,
116
- description=product_desc,
117
- price=price_str,
 
 
 
 
118
  image_url=image_url
119
  )
120
- st.success("πŸŽ‰ Product published to Shopify!")
121
- st.markdown(f"[View your live product β†’]({shopify_url})")
122
  except Exception as e:
123
  st.error(f"❌ Shopify publish failed: {e}")
124
 
@@ -130,17 +133,16 @@ def render_settings():
130
  st.markdown("## βš™οΈ Settings & Billing")
131
  st.markdown(
132
  """
133
- **Ensure the following secrets are set** under
134
- Settings β†’ Secrets:
135
- - `API_KEY`
136
- - `OPENAI_API_KEY`
137
- - `GEMINI_API_KEY`
138
- - `STRIPE_API_KEY`
139
  """
140
  )
141
- if st.button("πŸ’³ Create Stripe Checkout Session"):
142
- session_url = create_stripe_session()
143
- st.markdown(f"[Proceed to Payment]({session_url})", unsafe_allow_html=True)
144
 
145
  # ────────────────────────────────────────────────────────────────────────────────
146
  # 5. FOOTER
@@ -148,16 +150,14 @@ def render_settings():
148
  def render_footer():
149
  st.markdown("---")
150
  st.markdown(
151
- """
152
- <div style="text-align:center; color:#888; font-size:0.9rem;">
153
- Powered by Streamlit β€’ FastAPI β€’ Celery β€’ Redis β€’ Hugging Face Spaces
154
- </div>
155
- """,
156
  unsafe_allow_html=True,
157
  )
158
 
159
  # ────────────────────────────────────────────────────────────────────────────────
160
- # ENTRY POINT
161
  # ────────────────────────────────────────────────────────────────────────────────
162
  if __name__ == "__main__":
163
  main()
 
1
  import os
 
2
  import streamlit as st
3
+ from datetime import datetime
4
  from agent_manager import AgentManager
5
+ from shopify_client import create_shopify_product
6
  from dashboard.logs import show_logs
7
  from stripe_checkout import create_stripe_session
8
+ import requests # if you’re also firing webhooks/Zapier
9
 
10
  # ────────────────────────────────────────────────────────────────────────────────
11
+ # 1. GLOBAL PAGE CONFIG
12
  # ────────────────────────────────────────────────────────────────────────────────
13
  st.set_page_config(
14
+ page_title="AutoExecΒ AI",
15
  page_icon="πŸš€",
16
  layout="wide",
17
  initial_sidebar_state="expanded",
18
  )
19
 
20
  # ────────────────────────────────────────────────────────────────────────────────
21
+ # 2. NAVIGATION
22
  # ────────────────────────────────────────────────────────────────────────────────
23
  PAGES = {
24
  "Home": "🏠 Home",
 
27
  "Settings": "βš™οΈ Settings"
28
  }
29
 
30
+ if "page" not in st.session_state:
31
+ st.session_state.page = "Home"
 
 
 
 
 
 
 
 
 
 
 
32
 
33
+ st.sidebar.title("AutoExecΒ AI")
34
+ selection = st.sidebar.radio(
35
+ "Navigate:",
36
+ list(PAGES.values()),
37
+ index=list(PAGES.values()).index(PAGES[st.session_state.page]),
38
+ key="nav_radio"
39
+ )
40
+ # map back to key
41
+ st.session_state.page = next(k for k, v in PAGES.items() if v == selection)
42
 
43
  # ────────────────────────────────────────────────────────────────────────────────
44
  # 3. PAGE DISPATCHER
45
  # ────────────────────────────────────────────────────────────────────────────────
46
  def main():
47
+ page = st.session_state.page
48
+
49
  if page == "Home":
50
  render_home()
51
  elif page == "Launch":
 
55
  elif page == "Settings":
56
  render_settings()
57
  else:
58
+ st.error("Page not found")
59
 
60
  # ────────────────────────────────────────────────────────────────────────────────
61
  # 4. PAGE RENDERERS
 
63
  def render_home():
64
  st.markdown(
65
  """
66
+ <div style="text-align:center; padding:2rem 0;">
67
+ <h1 style="font-size:3rem; margin:0;">πŸš€ AutoExecΒ AI</h1>
68
+ <p style="font-size:1.25rem; color:#555;">
69
+ Your Autonomous AI Business Builder<br>
70
+ Generate, deploy, and optimize startups in one click.
71
+ </p>
72
  </div>
73
+ """, unsafe_allow_html=True
 
74
  )
75
+ cols = st.columns(3)
76
+ features = [
77
+ ("πŸ€– LLM-Powered", "Gemini Pro + GPT‑4 fallback"),
78
+ ("πŸ”„ LoopAgent", "Daily autonomous optimizations"),
79
+ ("πŸ“Š Dashboard", "Real-time logs & analytics")
80
+ ]
81
+ for col, (title, desc) in zip(cols, features):
82
+ col.subheader(title)
83
+ col.write(desc)
84
+
85
+ st.markdown("---")
86
+ if st.button("πŸ‘‰ Try the Demo"):
87
+ st.session_state.page = "Launch"
88
+ st.experimental_rerun()
89
 
90
  def render_launch():
91
  st.markdown("## πŸš€ Launch a New AI Business")
92
  with st.form("launch_form"):
93
+ niche = st.text_input("🎯 Niche", placeholder="e.g., fitness wear")
 
 
 
 
94
  business_type = st.selectbox(
95
  "πŸ“¦ Business Type",
96
+ ["Dropshipping", "Print‑on‑Demand", "Newsletter", "Course"]
 
97
  )
98
  submit = st.form_submit_button("Generate & Deploy")
 
99
  if submit:
100
  if not niche.strip():
101
+ st.warning("Please enter a niche to continue.")
102
  return
103
 
104
+ # Run agents
105
+ with st.spinner("πŸ€– Running AI agents…"):
106
  manager = AgentManager(niche.strip(), business_type)
107
  results = manager.run_all()
108
+
109
  st.success("βœ… Business Launched Successfully!")
110
  st.json(results)
111
 
112
+ # Publish product to Shopify
 
 
 
 
 
 
113
  try:
114
+ title = f"{business_type} in {niche}"
115
+ description = results["copy"]
116
+ price = "49.00"
117
+ image_url = None # or provide a default URL
118
+ storefront_url = create_shopify_product(
119
+ title=title,
120
+ description=description,
121
+ price=price,
122
  image_url=image_url
123
  )
124
+ st.markdown(f"**πŸ›οΈ Product live on Shopify:** [View Product]({storefront_url})")
 
125
  except Exception as e:
126
  st.error(f"❌ Shopify publish failed: {e}")
127
 
 
133
  st.markdown("## βš™οΈ Settings & Billing")
134
  st.markdown(
135
  """
136
+ **Configure these secrets in Settings β†’ Secrets**
137
+ β€’ `API_KEY`
138
+ β€’ `OPENAI_API_KEY`
139
+ β€’ `GEMINI_API_KEY`
140
+ β€’ `STRIPE_API_KEY`
 
141
  """
142
  )
143
+ if st.button("πŸ’³ Subscribe via Stripe"):
144
+ checkout_url = create_stripe_session()
145
+ st.markdown(f"[Proceed to Payment β†’]({checkout_url})", unsafe_allow_html=True)
146
 
147
  # ────────────────────────────────────────────────────────────────────────────────
148
  # 5. FOOTER
 
150
  def render_footer():
151
  st.markdown("---")
152
  st.markdown(
153
+ "<div style='text-align:center; color:#888; font-size:0.85rem;'>"
154
+ "Powered by Streamlit β€’ FastAPI β€’ Celery β€’ Redis β€’ Hugging Face Spaces"
155
+ "</div>",
 
 
156
  unsafe_allow_html=True,
157
  )
158
 
159
  # ────────────────────────────────────────────────────────────────────────────────
160
+ # 6. ENTRY POINT
161
  # ────────────────────────────────────────────────────────────────────────────────
162
  if __name__ == "__main__":
163
  main()