Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import numpy as np
|
4 |
+
import plotly.express as px
|
5 |
+
|
6 |
+
# Sample Data for Testing
|
7 |
+
competitor_prices = pd.DataFrame({
|
8 |
+
"Competitor": ["Shop A", "Shop B", "Shop C", "Shop D"],
|
9 |
+
"Product": ["Sneakers", "Hoodies", "Watches", "Backpacks"],
|
10 |
+
"Price (Ksh)": [4500, 3200, 7500, 2800],
|
11 |
+
"Discount (%)": [10, 5, 15, 0]
|
12 |
+
})
|
13 |
+
|
14 |
+
sales_data = pd.DataFrame({
|
15 |
+
"Date": pd.date_range(start="2024-01-01", periods=30, freq="D"),
|
16 |
+
"Sales (Ksh)": np.random.randint(5000, 50000, size=30)
|
17 |
+
})
|
18 |
+
|
19 |
+
# ---- Streamlit App ----
|
20 |
+
st.set_page_config(page_title="AI Business Dashboard", layout="wide")
|
21 |
+
|
22 |
+
# ---- Sidebar Navigation ----
|
23 |
+
st.sidebar.title("π AI Business Intelligence")
|
24 |
+
page = st.sidebar.radio("Navigate", ["Dashboard", "Competitor Analysis", "Marketing Insights", "AI Suggestions"])
|
25 |
+
|
26 |
+
# ---- Dashboard ----
|
27 |
+
if page == "Dashboard":
|
28 |
+
st.title("π Business Performance Dashboard")
|
29 |
+
|
30 |
+
tab1, tab2 = st.tabs(["Sales Trends", "Product Insights"])
|
31 |
+
|
32 |
+
with tab1:
|
33 |
+
st.subheader("π Daily Sales Performance")
|
34 |
+
fig = px.line(sales_data, x="Date", y="Sales (Ksh)", title="Sales Over Time")
|
35 |
+
st.plotly_chart(fig, use_container_width=True)
|
36 |
+
|
37 |
+
with tab2:
|
38 |
+
st.subheader("π¦ Top-Selling Products")
|
39 |
+
top_products = pd.DataFrame({
|
40 |
+
"Product": ["Sneakers", "Hoodies", "Watches", "Backpacks"],
|
41 |
+
"Sales (Ksh)": [25000, 18000, 15000, 12000]
|
42 |
+
})
|
43 |
+
fig2 = px.bar(top_products, x="Product", y="Sales (Ksh)", title="Best-Selling Products", text="Sales (Ksh)")
|
44 |
+
st.plotly_chart(fig2, use_container_width=True)
|
45 |
+
|
46 |
+
# ---- Competitor Analysis ----
|
47 |
+
elif page == "Competitor Analysis":
|
48 |
+
st.title("π Competitor Price Tracking")
|
49 |
+
st.table(competitor_prices)
|
50 |
+
|
51 |
+
# Price Adjustment Recommendation
|
52 |
+
st.subheader("π‘ AI Pricing Suggestion")
|
53 |
+
st.info("Your Sneakers are priced at Ksh 5000. AI suggests a **10% discount (Ksh 4500)** to remain competitive.")
|
54 |
+
|
55 |
+
# ---- Marketing Insights ----
|
56 |
+
elif page == "Marketing Insights":
|
57 |
+
st.title("π£ Social Media Performance")
|
58 |
+
tab1, tab2 = st.tabs(["Instagram Engagement", "Ad Optimization"])
|
59 |
+
|
60 |
+
with tab1:
|
61 |
+
st.subheader("π₯ Best Posting Times")
|
62 |
+
best_times = pd.DataFrame({"Time": ["10 AM", "1 PM", "6 PM", "9 PM"], "Engagement": [300, 450, 700, 550]})
|
63 |
+
fig3 = px.bar(best_times, x="Time", y="Engagement", title="Best Times to Post on Instagram")
|
64 |
+
st.plotly_chart(fig3, use_container_width=True)
|
65 |
+
|
66 |
+
with tab2:
|
67 |
+
st.subheader("π’ Ad Performance Insights")
|
68 |
+
st.write("π‘ AI suggests allocating **60% of the budget** to Instagram Stories instead of Feed Ads for better ROI.")
|
69 |
+
|
70 |
+
# ---- AI Suggestions ----
|
71 |
+
elif page == "AI Suggestions":
|
72 |
+
st.title("π€ AI-Powered Business Recommendations")
|
73 |
+
st.info("π AI predicts that **Hoodies will trend next month**. Consider increasing stock and running a promo.")
|
74 |
+
st.info("π° AI suggests increasing ad spend on **Instagram Reels for better conversions**.")
|
75 |
+
|
76 |
+
# ---- Footer ----
|
77 |
+
st.sidebar.markdown("---")
|
78 |
+
st.sidebar.caption("π Powered by Waziri Collective Labs | 2025")
|