PD03 commited on
Commit
a0aabd2
Β·
verified Β·
1 Parent(s): 6236516

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +164 -38
src/streamlit_app.py CHANGED
@@ -1,40 +1,166 @@
1
- import altair as alt
2
- import numpy as np
3
- import pandas as pd
4
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- """
7
- # Welcome to Streamlit!
8
-
9
- Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
10
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
11
- forums](https://discuss.streamlit.io).
12
-
13
- In the meantime, below is an example of what you can do with just a few lines of code:
14
- """
15
-
16
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
18
-
19
- indices = np.linspace(0, 1, num_points)
20
- theta = 2 * np.pi * num_turns * indices
21
- radius = indices
22
-
23
- x = radius * np.cos(theta)
24
- y = radius * np.sin(theta)
25
-
26
- df = pd.DataFrame({
27
- "x": x,
28
- "y": y,
29
- "idx": indices,
30
- "rand": np.random.randn(num_points),
31
- })
32
-
33
- st.altair_chart(alt.Chart(df, height=700, width=700)
34
- .mark_point(filled=True)
35
- .encode(
36
- x=alt.X("x", axis=None),
37
- y=alt.Y("y", axis=None),
38
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
40
- ))
 
 
 
 
1
  import streamlit as st
2
+ import pandas as pd
3
+ import plotly.express as px
4
+ import plotly.graph_objects as go
5
+
6
+ # Page config
7
+ st.set_page_config(
8
+ page_title="Auto Digital Public Infrastructure",
9
+ page_icon="πŸ”—",
10
+ layout="wide",
11
+ initial_sidebar_state="expanded"
12
+ )
13
+
14
+ # Custom CSS for styling
15
+ st.markdown("""
16
+ <style>
17
+ .main-header {
18
+ background-color: #4a5568;
19
+ color: white;
20
+ padding: 1rem;
21
+ border-radius: 0.5rem;
22
+ margin-bottom: 1rem;
23
+ }
24
+ .metric-card {
25
+ background-color: #f7fafc;
26
+ padding: 1rem;
27
+ border-radius: 0.5rem;
28
+ border-left: 4px solid #3182ce;
29
+ }
30
+ </style>
31
+ """, unsafe_allow_html=True)
32
+
33
+ # Sample data functions (since we can't import separate files easily)
34
+ @st.cache_data
35
+ def get_material_data():
36
+ return pd.DataFrame({
37
+ 'Material group': ['Engine', 'Hydraulic Cylinder', 'Seating and Interiors',
38
+ 'Batteries', 'Control Arms', 'Ball Joints', 'Semiconductors',
39
+ 'Sensors', 'Brake system', 'Shock Absorbers'],
40
+ 'Fulfillment rate': [70, 65, 62, 70, 72, 70, 76, 75, 78, 80],
41
+ 'Projected Fulfillment rate': [62, 65, 67, 68, 70, 71, 75, 76, 78, 80],
42
+ 'MoM trend': [6.8, 4.1, 3.9, 1.1, 1.2, 6.8, 4.1, 3.9, 1.1, 1.2]
43
+ })
44
+
45
+ @st.cache_data
46
+ def get_overall_metrics():
47
+ return {
48
+ 'fulfillment': 86,
49
+ 'mom_change': 1.5,
50
+ 'material_groups': 3,
51
+ 'skus': 1705,
52
+ 'material_groups_at_risk': 20,
53
+ 'risk_mom_change': 2.2,
54
+ 'skus_at_risk': 25,
55
+ 'sku_risk_mom_change': 4.1
56
+ }
57
+
58
+ # Header
59
+ st.markdown("""
60
+ <div class="main-header">
61
+ <h1>πŸ”— Auto Digital Public Infrastructure</h1>
62
+ <h2 style="color: #ffd700;">SUPPLY CHAIN RESILIENCE- CT- Overall metrics</h2>
63
+ </div>
64
+ """, unsafe_allow_html=True)
65
+
66
+ # Sidebar navigation
67
+ with st.sidebar:
68
+ st.markdown("### Navigation")
69
+ st.markdown("**Master Screen**")
70
+
71
+ nav_options = [
72
+ "HOME",
73
+ "Supply Chain Resilience",
74
+ "SC Control Tower",
75
+ "Material Group View",
76
+ "Supplier View",
77
+ "Demand & Capacity Mgmt.",
78
+ "Insights & Trends",
79
+ "Use-Case 2",
80
+ "Use-Case 3",
81
+ "...other use-cases"
82
+ ]
83
+
84
+ selected_nav = st.selectbox("Select Page", nav_options, index=1)
85
+
86
+ # Filters section
87
+ st.markdown("### Filters/Splices")
88
+
89
+ col1, col2, col3, col4, col5, col6, col7 = st.columns(7)
90
+
91
+ with col1:
92
+ plant_location = st.selectbox("Plant location", ["Chennai", "Mumbai", "Delhi"], index=0)
93
+
94
+ with col2:
95
+ material_group = st.selectbox("Material group", ["All", "Engine", "Electronics"], index=0)
96
+
97
+ with col3:
98
+ part_sku = st.selectbox("Part/SKU", ["All", "SKU001", "SKU002"], index=0)
99
+
100
+ with col4:
101
+ time_period = st.selectbox("Time Period", ["FY2026", "FY2025", "FY2027"], index=0)
102
+
103
+ with col5:
104
+ month = st.selectbox("Month", ["May", "June", "July"], index=0)
105
+
106
+ with col6:
107
+ supplier_type = st.selectbox("Supplier type", ["All", "Tier 1", "Tier 2"], index=0)
108
+
109
+ with col7:
110
+ supplier_name = st.selectbox("Supplier Name", ["All", "Supplier A", "Supplier B"], index=0)
111
+
112
+ # Get data
113
+ material_df = get_material_data()
114
+ metrics = get_overall_metrics()
115
+
116
+ # Main content area
117
+ col1, col2 = st.columns([1, 2])
118
+
119
+ with col1:
120
+ # Overall metrics section
121
+ st.markdown("### πŸ“Š Overall metrics")
122
+
123
+ # Fulfillment metric
124
+ st.markdown(f"""
125
+ <div class="metric-card">
126
+ <h2>Fulfillment: {metrics['fulfillment']}%</h2>
127
+ <p style="color: green;">↑ {metrics['mom_change']}% MoM</p>
128
+ </div>
129
+ """, unsafe_allow_html=True)
130
+
131
+ # Other metrics in a 2x2 grid
132
+ met_col1, met_col2 = st.columns(2)
133
+
134
+ with met_col1:
135
+ st.metric("Material groups", metrics['material_groups'])
136
+ st.metric("% Material groups at risk", f"{metrics['material_groups_at_risk']}%",
137
+ delta=f"-{metrics['risk_mom_change']}% MoM")
138
+
139
+ with met_col2:
140
+ st.metric("SKUs", f"{metrics['skus']:,}")
141
+ st.metric("% SKUs at risk", f"{metrics['skus_at_risk']}%",
142
+ delta=f"↓{metrics['sku_risk_mom_change']}% MoM")
143
+
144
+ with col2:
145
+ # Material group fulfillment table
146
+ st.markdown("### πŸ“‹ Material group wise fulfillment rates")
147
+
148
+ # Display the dataframe
149
+ st.dataframe(material_df, use_container_width=True)
150
+
151
+ # Add a chart below
152
+ st.markdown("### πŸ“ˆ Fulfillment Rate Trends")
153
+
154
+ fig = px.bar(material_df,
155
+ x='Material group',
156
+ y=['Fulfillment rate', 'Projected Fulfillment rate'],
157
+ title="Current vs Projected Fulfillment Rates",
158
+ barmode='group')
159
+
160
+ fig.update_layout(
161
+ xaxis_tickangle=-45,
162
+ height=400,
163
+ showlegend=True
164
+ )
165
 
166
+ st.plotly_chart(fig, use_container_width=True)