bmid / app.py
Iammcqwory's picture
Create app.py
5ecce7d verified
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")