File size: 7,680 Bytes
9140d68
80901e6
c5676bf
b7b397e
c5676bf
26ca950
b7b397e
e19b30e
cda83bf
f761f01
cda83bf
85ebef7
c5676bf
85ebef7
 
 
 
 
9140d68
f761f01
9140d68
85ebef7
 
 
 
 
 
7c66e2d
c5676bf
 
cda83bf
c5676bf
 
 
 
 
 
 
f761f01
 
e19b30e
cda83bf
 
 
 
c5676bf
 
cda83bf
 
 
 
 
 
 
 
 
c5676bf
cda83bf
 
 
 
f761f01
cda83bf
f761f01
85ebef7
 
c5676bf
 
 
f761f01
c5676bf
85ebef7
f761f01
 
85ebef7
f761f01
c5676bf
 
f761f01
 
 
c5676bf
 
 
 
 
 
f761f01
c5676bf
f761f01
b7b397e
cda83bf
f761f01
cda83bf
f761f01
9140d68
c5676bf
85ebef7
9140d68
c5676bf
85ebef7
cda83bf
f761f01
cda83bf
85ebef7
c5676bf
cda83bf
9140d68
f761f01
c5676bf
9140d68
 
 
 
 
f761f01
9140d68
f761f01
c5676bf
f761f01
c5676bf
 
 
 
f761f01
 
 
 
 
 
9140d68
 
f761f01
b7b397e
cda83bf
f761f01
cda83bf
e19b30e
b7b397e
cda83bf
f761f01
cda83bf
85ebef7
 
f761f01
 
 
 
 
85ebef7
 
c5676bf
f761f01
 
85ebef7
cda83bf
9140d68
cda83bf
 
 
 
f761f01
 
 
 
 
 
cda83bf
 
 
c5676bf
cda83bf
 
 
 
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
import os
import streamlit as st
from datetime import datetime
from agent_manager import AgentManager
from shopify_client import create_shopify_product
from dashboard.logs import show_logs
from stripe_checkout import create_stripe_session

# ────────────────────────────────────────────────────────────────────────────────
# 1. GLOBAL PAGE CONFIGURATION
# ────────────────────────────────────────────────────────────────────────────────
st.set_page_config(
    page_title="AutoExecΒ AI",
    page_icon="πŸš€",
    layout="wide",
    initial_sidebar_state="expanded",
)

# ────────────────────────────────────────────────────────────────────────────────
# 2. SIDEBAR NAVIGATION SETUP
# ────────────────────────────────────────────────────────────────────────────────
PAGES = {
    "Home": "🏠 Home",
    "Launch": "πŸš€ Launch",
    "Logs": "πŸ“Š Logs",
    "Settings": "βš™οΈ Settings"
}

if "page" not in st.session_state:
    st.session_state.page = "Home"

st.sidebar.title("AutoExecΒ AI")
selection = st.sidebar.radio(
    "Navigate:",
    list(PAGES.values()),
    index=list(PAGES.values()).index(PAGES[st.session_state.page]),
    key="nav_radio"
)
# Map the selection back to its key
st.session_state.page = next(key for key, label in PAGES.items() if label == selection)

# ────────────────────────────────────────────────────────────────────────────────
# 3. PAGE DISPATCHER
# ────────────────────────────────────────────────────────────────────────────────
def main():
    page = st.session_state.page

    if page == "Home":
        render_home()
    elif page == "Launch":
        render_launch()
    elif page == "Logs":
        render_logs()
    elif page == "Settings":
        render_settings()
    else:
        st.error("Page not found")

# ────────────────────────────────────────────────────────────────────────────────
# 4. PAGE RENDERERS
# ────────────────────────────────────────────────────────────────────────────────

def render_home():
    """Render the Home page with hero and feature highlights."""
    st.markdown(
        """
        <div style="text-align:center; padding:2rem 0;">
          <h1 style="font-size:3rem; margin:0;">πŸš€ AutoExecΒ AI</h1>
          <p style="font-size:1.25rem; color:#555;">
            Generate, deploy, and optimize AI‑powered businesses in one click.
          </p>
        </div>
        """,
        unsafe_allow_html=True
    )

    cols = st.columns(3)
    features = [
        ("πŸ€– LLM‑Powered", "Gemini Pro + GPT‑4 fallback"),
        ("πŸ”„ LoopAgent",   "Daily autonomous optimizations"),
        ("πŸ“Š Dashboard",   "Real‑time logs & analytics")
    ]
    for col, (title, desc) in zip(cols, features):
        col.subheader(title)
        col.write(desc)

    st.markdown("---")
    def go_to_launch():
        st.session_state.page = "Launch"
    st.button("πŸ‘‰ Try the Demo", on_click=go_to_launch)

def render_launch():
    """Render the Launch page with a form to run the AI agents & publish product."""
    st.markdown("## πŸš€ Launch a New AI Business")

    with st.form("launch_form"):
        niche = st.text_input("🎯 Niche", placeholder="e.g., fitness wear")
        business_type = st.selectbox(
            "πŸ“¦ Business Type",
            ["Dropshipping", "Print‑on‑Demand", "Newsletter", "Course"]
        )
        submit = st.form_submit_button("Generate & Deploy")

    if submit:
        if not niche.strip():
            st.warning("Please enter a niche to continue.")
            return

        # 1) Run AI Agents
        with st.spinner("πŸ€– Running AI agents…"):
            manager = AgentManager(niche.strip(), business_type)
            results = manager.run_all()
        st.success("βœ… Business Launched Successfully!")
        st.json(results)

        # 2) Publish to Shopify
        try:
            title       = f"{business_type} in {niche}"
            description = results["copy"]
            price       = "49.00"
            storefront_url = create_shopify_product(
                title=title,
                description=description,
                price=price,
                image_url=None
            )
            st.markdown(
                f"**πŸ›οΈ Product Live on Shopify:** "
                f"[View Product]({storefront_url})",
                unsafe_allow_html=True
            )
        except Exception as e:
            st.error(f"❌ Shopify publishing failed: {e}")

def render_logs():
    """Render the Logs dashboard page."""
    st.markdown("## πŸ“Š Agent Memory Log Dashboard")
    show_logs()

def render_settings():
    """Render the Settings & Billing page."""
    st.markdown("## βš™οΈ Settings & Billing")
    st.markdown(
        """
        **Configure these secrets:**  
        - `API_KEY`  
        - `OPENAI_API_KEY`  
        - `GEMINI_API_KEY`  
        - `STRIPE_API_KEY`
        """
    )
    if st.button("πŸ’³ Subscribe via Stripe"):
        url = create_stripe_session()
        st.markdown(f"[Proceed to Payment β†’]({url})", unsafe_allow_html=True)

# ────────────────────────────────────────────────────────────────────────────────
# 5. FOOTER
# ────────────────────────────────────────────────────────────────────────────────
def render_footer():
    st.markdown("---")
    st.markdown(
        """
        <div style="text-align:center; color:#888; font-size:0.85rem;">
            Powered by Streamlit β€’ FastAPI β€’ Celery β€’ Redis β€’ Hugging Face Spaces
        </div>
        """,
        unsafe_allow_html=True
    )

# ────────────────────────────────────────────────────────────────────────────────
# 6. ENTRY POINT
# ────────────────────────────────────────────────────────────────────────────────
if __name__ == "__main__":
    main()
    render_footer()