import streamlit as st import pandas as pd import plotly.express as px import plotly.graph_objects as go from datetime import datetime, timedelta # Page config st.set_page_config( page_title="Supply Chain Intelligence", page_icon="🔗", layout="wide", initial_sidebar_state="expanded" ) # Clean, professional CSS styling st.markdown(""" """, unsafe_allow_html=True) # Sample data functions (same as before) @st.cache_data def get_material_data(): return pd.DataFrame({ 'Material Group': ['Engine Components', 'Hydraulic Systems', 'Interior & Seating', 'Battery Systems', 'Suspension Parts', 'Safety Components', 'Semiconductors', 'Smart Sensors', 'Brake Systems', 'Shock Absorbers'], 'Current Rate': [72, 68, 65, 73, 75, 72, 78, 77, 80, 82], 'Target Rate': [75, 70, 70, 75, 78, 75, 80, 80, 82, 85], 'Trend': ['+2.1%', '+1.8%', '+0.9%', '+2.4%', '+1.2%', '+1.8%', '+2.1%', '+1.9%', '+1.1%', '+1.2%'], 'Risk Level': ['Medium', 'High', 'High', 'Low', 'Low', 'Medium', 'Low', 'Low', 'Low', 'Low'], 'Last Updated': ['2 hrs ago', '1 hr ago', '3 hrs ago', '1 hr ago', '2 hrs ago', '1 hr ago', '30 min ago', '45 min ago', '1 hr ago', '2 hrs ago'] }) @st.cache_data def get_enhanced_metrics(): return { 'fulfillment': 86, 'mom_change': 2.3, 'material_groups': 147, 'skus': 12847, 'material_groups_at_risk': 18, 'risk_mom_change': -1.8, 'skus_at_risk': 23, 'sku_risk_mom_change': -2.1, 'active_suppliers': 342, 'on_time_delivery': 94.2 } # Clean, professional header st.markdown("""
Supply Chain Intelligence Hub
Real-time Supply Chain Resilience Dashboard • Control Tower Analytics
""", unsafe_allow_html=True) # Professional sidebar with st.sidebar: st.markdown(""" """, unsafe_allow_html=True) nav_options = [ "Dashboard Home", "Supply Chain Resilience", "Control Tower", "Material Groups", "Supplier Analytics", "Demand Planning", "Insights & Trends", "Real-time Alerts", "Reports Center" ] selected_nav = st.selectbox("", nav_options, index=1) # Clean alerts section st.markdown("---") st.markdown("**System Status**") st.error("⚠️ 3 suppliers need attention") st.warning("📋 12 SKUs below safety stock") st.success("✅ 94% on-time delivery") # Clean filters section st.markdown("""
Filters & Controls
""", unsafe_allow_html=True) col1, col2, col3, col4 = st.columns(4) col5, col6, col7, col8 = st.columns(4) with col1: plant_location = st.selectbox("Plant Location", ["Chennai Hub", "Mumbai Center", "Delhi North", "Bangalore Tech"], index=0) with col2: material_group = st.selectbox("Material Category", ["All Categories", "Critical Components", "Standard Parts"], index=0) with col3: time_period = st.selectbox("Time Period", ["Current Quarter", "FY2025", "Last 6 Months"], index=0) with col4: supplier_tier = st.selectbox("Supplier Tier", ["All Tiers", "Tier 1 Strategic", "Tier 2 Operational"], index=0) with col5: risk_level = st.selectbox("Risk Level", ["All Levels", "High Risk Only", "Medium Risk", "Low Risk"], index=0) with col6: performance = st.selectbox("Performance", ["All Performance", "Above Target", "Below Target"], index=0) with col7: geography = st.selectbox("Geography", ["Global View", "Asia Pacific", "Americas", "Europe"], index=0) with col8: update_freq = st.selectbox("Update Frequency", ["Real-time", "Hourly", "Daily"], index=0) # Get data material_df = get_material_data() metrics = get_enhanced_metrics() # Clean metrics section st.markdown('
Key Performance Indicators
', unsafe_allow_html=True) col1, col2, col3, col4 = st.columns(4) with col1: st.markdown(f"""
{metrics['fulfillment']}%
Overall Fulfillment
↗ +{metrics['mom_change']}% MoM
""", unsafe_allow_html=True) with col2: st.markdown(f"""
{metrics['on_time_delivery']}%
On-Time Delivery
↗ +1.2% WoW
""", unsafe_allow_html=True) with col3: st.markdown(f"""
{metrics['material_groups_at_risk']}%
At-Risk Categories
↘ {metrics['risk_mom_change']}% MoM
""", unsafe_allow_html=True) with col4: st.markdown(f"""
{metrics['active_suppliers']:,}
Active Suppliers
+15 new
""", unsafe_allow_html=True) # Clean data table st.markdown('
Material Group Performance
', unsafe_allow_html=True) # Display clean table st.dataframe(material_df, use_container_width=True, hide_index=True) # Professional charts st.markdown('
Performance Analytics
', unsafe_allow_html=True) col1, col2 = st.columns(2) with col1: # Clean bar chart fig1 = px.bar( material_df, x='Material Group', y=['Current Rate', 'Target Rate'], title="Fulfillment Rates: Current vs Target", color_discrete_sequence=['#3b82f6', '#64748b'] ) fig1.update_layout( plot_bgcolor='white', paper_bgcolor='white', font_family="Inter", title_font_size=14, title_font_color="#1e293b", xaxis_tickangle=-45, height=400, showlegend=True, legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1) ) st.plotly_chart(fig1, use_container_width=True) with col2: # Clean pie chart risk_counts = material_df['Risk Level'].value_counts() fig2 = px.pie( values=risk_counts.values, names=risk_counts.index, title="Risk Distribution", color_discrete_sequence=['#22c55e', '#f59e0b', '#ef4444'] ) fig2.update_layout( plot_bgcolor='white', paper_bgcolor='white', font_family="Inter", title_font_size=14, title_font_color="#1e293b", height=400 ) st.plotly_chart(fig2, use_container_width=True) # Clean footer st.markdown("""
Dashboard last updated: {timestamp} • Auto-refresh: Every 15 minutes • Data accuracy: 99.7%
""".format(timestamp=datetime.now().strftime("%B %d, %Y at %I:%M %p")), unsafe_allow_html=True)