|
import os |
|
|
|
import streamlit as st |
|
from landing import show_landing_content |
|
from agent_manager import AgentManager |
|
from dashboard.logs import show_logs |
|
from stripe_checkout import create_stripe_session |
|
from shopify_client import create_shopify_product |
|
|
|
|
|
|
|
|
|
st.set_page_config( |
|
page_title="AutoExec AI", |
|
page_icon="π", |
|
layout="wide", |
|
initial_sidebar_state="expanded", |
|
) |
|
|
|
|
|
|
|
|
|
PAGES = { |
|
"Home": "π Home", |
|
"Launch": "π Launch", |
|
"Logs": "π Logs", |
|
"Settings": "βοΈ Settings" |
|
} |
|
|
|
if "current_page" not in st.session_state: |
|
st.session_state.current_page = "Home" |
|
|
|
def render_sidebar() -> str: |
|
st.sidebar.title("AutoExec AI") |
|
choice = st.sidebar.radio( |
|
"Navigate to:", |
|
options=list(PAGES.values()), |
|
index=list(PAGES.values()).index(PAGES[st.session_state.current_page]), |
|
key="nav_radio" |
|
) |
|
|
|
return next(k for k, v in PAGES.items() if v == choice) |
|
|
|
st.session_state.current_page = render_sidebar() |
|
|
|
|
|
|
|
|
|
def main(): |
|
page = st.session_state.current_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!") |
|
|
|
|
|
|
|
|
|
def render_home(): |
|
st.markdown( |
|
""" |
|
<div style="text-align:center; margin:2rem 0;"> |
|
<h1 style="font-size:3rem;">π AutoExec AI</h1> |
|
<p style="font-size:1.25rem; color:#555;"> |
|
Launch, manage, and optimize AIβpowered businesses with a single click. |
|
</p> |
|
</div> |
|
""", |
|
unsafe_allow_html=True, |
|
) |
|
show_landing_content() |
|
|
|
def render_launch(): |
|
st.markdown("## π Launch a New AI Business") |
|
with st.form("launch_form"): |
|
niche = st.text_input( |
|
"π― Niche", |
|
placeholder="e.g., fitness wear", |
|
help="Define the market or audience for your business.", |
|
) |
|
business_type = st.selectbox( |
|
"π¦ Business Type", |
|
options=["Dropshipping", "Print-on-Demand", "Newsletter", "Course"], |
|
help="Select the type of business model to generate.", |
|
) |
|
submit = st.form_submit_button("Generate & Deploy") |
|
|
|
if submit: |
|
if not niche.strip(): |
|
st.warning("Please enter a valid niche.") |
|
return |
|
|
|
|
|
with st.spinner("π€ Running AI agents..."): |
|
manager = AgentManager(niche.strip(), business_type) |
|
results = manager.run_all() |
|
st.success("β
Business Launched Successfully!") |
|
st.json(results) |
|
|
|
|
|
st.markdown("### ποΈ Publishing Product to Shopify") |
|
product_title = f"{business_type} in {niche}" |
|
product_desc = results.get("copy", "") |
|
price_str = "49.00" |
|
image_url = None |
|
|
|
try: |
|
shopify_url = create_shopify_product( |
|
title=product_title, |
|
description=product_desc, |
|
price=price_str, |
|
image_url=image_url |
|
) |
|
st.success("π Product published to Shopify!") |
|
st.markdown(f"[View your live product β]({shopify_url})") |
|
except Exception as e: |
|
st.error(f"β Shopify publish failed: {e}") |
|
|
|
def render_logs(): |
|
st.markdown("## π Agent Memory Log Dashboard") |
|
show_logs() |
|
|
|
def render_settings(): |
|
st.markdown("## βοΈ Settings & Billing") |
|
st.markdown( |
|
""" |
|
**Ensure the following secrets are set** under |
|
Settings β Secrets: |
|
- `API_KEY` |
|
- `OPENAI_API_KEY` |
|
- `GEMINI_API_KEY` |
|
- `STRIPE_API_KEY` |
|
""" |
|
) |
|
if st.button("π³ Create Stripe Checkout Session"): |
|
session_url = create_stripe_session() |
|
st.markdown(f"[Proceed to Payment]({session_url})", unsafe_allow_html=True) |
|
|
|
|
|
|
|
|
|
def render_footer(): |
|
st.markdown("---") |
|
st.markdown( |
|
""" |
|
<div style="text-align:center; color:#888; font-size:0.9rem;"> |
|
Powered by Streamlit β’ FastAPI β’ Celery β’ Redis β’ Hugging Face Spaces |
|
</div> |
|
""", |
|
unsafe_allow_html=True, |
|
) |
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
main() |
|
render_footer() |
|
|