Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import numpy as np | |
| import plotly.express as px | |
| # Sample Data for Testing | |
| competitor_prices = pd.DataFrame({ | |
| "Competitor": ["Shop A", "Shop B", "Shop C", "Shop D"], | |
| "Product": ["Sneakers", "Hoodies", "Watches", "Backpacks"], | |
| "Price (Ksh)": [4500, 3200, 7500, 2800], | |
| "Discount (%)": [10, 5, 15, 0] | |
| }) | |
| sales_data = pd.DataFrame({ | |
| "Date": pd.date_range(start="2024-01-01", periods=30, freq="D"), | |
| "Sales (Ksh)": np.random.randint(5000, 50000, size=30) | |
| }) | |
| # ---- Streamlit App ---- | |
| st.set_page_config(page_title="AI Business Dashboard", layout="wide") | |
| # ---- Sidebar Navigation ---- | |
| st.sidebar.title("π AI Business Intelligence") | |
| page = st.sidebar.radio("Navigate", ["Dashboard", "Competitor Analysis", "Marketing Insights", "AI Suggestions"]) | |
| # ---- Dashboard ---- | |
| if page == "Dashboard": | |
| st.title("π Business Performance Dashboard") | |
| tab1, tab2 = st.tabs(["Sales Trends", "Product Insights"]) | |
| with tab1: | |
| st.subheader("π Daily Sales Performance") | |
| fig = px.line(sales_data, x="Date", y="Sales (Ksh)", title="Sales Over Time") | |
| st.plotly_chart(fig, use_container_width=True) | |
| with tab2: | |
| st.subheader("π¦ Top-Selling Products") | |
| top_products = pd.DataFrame({ | |
| "Product": ["Sneakers", "Hoodies", "Watches", "Backpacks"], | |
| "Sales (Ksh)": [25000, 18000, 15000, 12000] | |
| }) | |
| fig2 = px.bar(top_products, x="Product", y="Sales (Ksh)", title="Best-Selling Products", text="Sales (Ksh)") | |
| st.plotly_chart(fig2, use_container_width=True) | |
| # ---- Competitor Analysis ---- | |
| elif page == "Competitor Analysis": | |
| st.title("π Competitor Price Tracking") | |
| st.table(competitor_prices) | |
| # Price Adjustment Recommendation | |
| st.subheader("π‘ AI Pricing Suggestion") | |
| st.info("Your Sneakers are priced at Ksh 5000. AI suggests a **10% discount (Ksh 4500)** to remain competitive.") | |
| # ---- Marketing Insights ---- | |
| elif page == "Marketing Insights": | |
| st.title("π£ Social Media Performance") | |
| tab1, tab2 = st.tabs(["Instagram Engagement", "Ad Optimization"]) | |
| with tab1: | |
| st.subheader("π₯ Best Posting Times") | |
| best_times = pd.DataFrame({"Time": ["10 AM", "1 PM", "6 PM", "9 PM"], "Engagement": [300, 450, 700, 550]}) | |
| fig3 = px.bar(best_times, x="Time", y="Engagement", title="Best Times to Post on Instagram") | |
| st.plotly_chart(fig3, use_container_width=True) | |
| with tab2: | |
| st.subheader("π’ Ad Performance Insights") | |
| st.write("π‘ AI suggests allocating **60% of the budget** to Instagram Stories instead of Feed Ads for better ROI.") | |
| # ---- AI Suggestions ---- | |
| elif page == "AI Suggestions": | |
| st.title("π€ AI-Powered Business Recommendations") | |
| st.info("π AI predicts that **Hoodies will trend next month**. Consider increasing stock and running a promo.") | |
| st.info("π° AI suggests increasing ad spend on **Instagram Reels for better conversions**.") | |
| # ---- Footer ---- | |
| st.sidebar.markdown("---") | |
| st.sidebar.caption("π Powered by Waziri Collective Labs | 2025") | |