Menixis commited on
Commit
c96308a
·
verified ·
1 Parent(s): 9160c7e

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +80 -13
  2. app.py +843 -0
  3. requirements.txt +3 -3
README.md CHANGED
@@ -1,20 +1,87 @@
1
  ---
2
- title: Dashboard
3
- emoji: 🚀
4
- colorFrom: red
5
- colorTo: red
6
- sdk: docker
7
- app_port: 8501
8
- tags:
9
- - streamlit
10
  pinned: false
11
- short_description: Streamlit template space
12
  license: mit
 
13
  ---
14
 
15
- # Welcome to Streamlit!
16
 
17
- Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
18
 
19
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
20
- forums](https://discuss.streamlit.io).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Procurement Automation Roadmap
3
+ emoji: 🛒
4
+ colorFrom: blue
5
+ colorTo: indigo
6
+ sdk: streamlit
7
+ sdk_version: 1.39.0
8
+ app_file: app.py
 
9
  pinned: false
 
10
  license: mit
11
+ short_description: Interactive automation roadmap procurement officer tasks
12
  ---
13
 
14
+ # 🛒 Procurement Automation Roadmap
15
 
16
+ An interactive Streamlit web app that visualizes the automation journey for **4 key tasks** performed by procurement officers (พนักงานจัดหา) in the Gas Pipeline Business Unit (ระบบท่อส่งก๊าซฯ).
17
 
18
+ ## 🎯 Target Activities
19
+
20
+ | Code | Activity (EN) | Activity (TH) |
21
+ | ----- | ------------------------- | -------------------------------------- |
22
+ | 1.4 | TOR/PR Review | พนง.จัดหา ตรวจสอบ TOR/PR |
23
+ | 2.1.1 | Issue RFQ to Vendors | พนง.จัดหา ออก RFQ เพื่อเชิญผู้ค้าเสนอราคา |
24
+ | 2.2 | Review Vendor Quotations | พนง.จัดหา ตรวจสอบเอกสารเสนอราคา |
25
+ | 3.1 | Create VA / PO / LOI | พนง.จัดหา จัดทำ VA/PO/LOI |
26
+
27
+ ## ✨ Features
28
+
29
+ - 🏠 **Executive Summary** — vision, scope, aggregate impact
30
+ - 📋 **Task deep-dives** — pain points, automation opportunities, phased plan, KPIs, tech stack per task
31
+ - 🗺️ **Visual Gantt roadmap** — phased delivery across all 4 tasks (Phase 1 → Phase 4)
32
+ - 💰 **ROI Calculator** — interactive sliders to estimate annual savings for your team size
33
+ - 🛠️ **Technology Stack** — layered reference architecture + risks & mitigations
34
+
35
+ ## 🚀 Deploy on Hugging Face Spaces
36
+
37
+ 1. Create a new Space at <https://huggingface.co/new-space>
38
+ 2. Choose **Streamlit** as the SDK
39
+ 3. Upload these three files:
40
+ - `app.py`
41
+ - `requirements.txt`
42
+ - `README.md` (this file — the front matter at the top is what configures the Space)
43
+ 4. The Space will build and launch automatically (~1–2 minutes)
44
+
45
+ ## 🖥️ Run Locally
46
+
47
+ ```bash
48
+ pip install -r requirements.txt
49
+ streamlit run app.py
50
+ ```
51
+
52
+ Then open <http://localhost:8501>.
53
+
54
+ ## 🏗️ The 4-Phase Strategy
55
+
56
+ | Phase | Duration | Focus |
57
+ | ---------------------- | ----------- | ---------------------------------------------------------------- |
58
+ | 1. Quick Wins | 0–3 months | Templates, OCR, checklists, email merge — day-one friction relief |
59
+ | 2. Foundation | 3–6 months | SAP MM / DP / SP integration, rule engines, workflow, dashboards |
60
+ | 3. Intelligence | 6–12 months | LLM document analysis, vendor recommender, anomaly detection |
61
+ | 4. Full Automation | 12+ months | Straight-through processing, human-in-the-loop on exceptions |
62
+
63
+ ## 📊 Aggregate Impact (Targeted)
64
+
65
+ - **~85% cycle-time reduction** across the 4 tasks
66
+ - **~2,400 hours/year saved** per officer
67
+ - **~88% fewer errors** → less rework
68
+ - **98% SLA compliance** (+23 pp)
69
+
70
+ ## 📂 Project Structure
71
+
72
+ ```
73
+ .
74
+ ├── app.py # Streamlit application
75
+ ├── requirements.txt # Python dependencies
76
+ └── README.md # This file + HF Space config
77
+ ```
78
+
79
+ ## 📝 Notes
80
+
81
+ - Source workflow: PTT Gas Pipeline procurement (Work Flow กระบวนการจัดหา)
82
+ - Out of scope: User, Planner, BSA, ผจ.จบ., committee, and vendor-side activities — these can be added in follow-on phases
83
+ - ROI numbers are illustrative; refine with your own time studies and cost models
84
+
85
+ ## 📜 License
86
+
87
+ MIT
app.py ADDED
@@ -0,0 +1,843 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Procurement Automation Roadmap
3
+ An interactive web app for visualizing the automation journey of 4 key procurement tasks.
4
+
5
+ Deploy on Hugging Face Spaces (SDK: Streamlit).
6
+ """
7
+
8
+ import streamlit as st
9
+ import pandas as pd
10
+ import plotly.express as px
11
+ import plotly.graph_objects as go
12
+ from datetime import datetime
13
+
14
+ # ------------------------------------------------------------------
15
+ # Page config
16
+ # ------------------------------------------------------------------
17
+ st.set_page_config(
18
+ page_title="Procurement Automation Roadmap",
19
+ page_icon="🛒",
20
+ layout="wide",
21
+ initial_sidebar_state="expanded",
22
+ )
23
+
24
+ # ------------------------------------------------------------------
25
+ # Custom CSS
26
+ # ------------------------------------------------------------------
27
+ st.markdown(
28
+ """
29
+ <style>
30
+ .main-header {
31
+ font-size: 2.2rem;
32
+ font-weight: 700;
33
+ background: linear-gradient(90deg, #1f4e79 0%, #2e86ab 100%);
34
+ -webkit-background-clip: text;
35
+ -webkit-text-fill-color: transparent;
36
+ padding: 0.5rem 0;
37
+ }
38
+ .task-badge {
39
+ background-color: #1f4e79;
40
+ color: white;
41
+ padding: 0.25rem 0.75rem;
42
+ border-radius: 12px;
43
+ font-size: 0.85rem;
44
+ font-weight: 600;
45
+ display: inline-block;
46
+ }
47
+ .phase-card {
48
+ background: #f8fafc;
49
+ border-left: 4px solid #1f4e79;
50
+ padding: 1rem;
51
+ border-radius: 6px;
52
+ margin-bottom: 0.75rem;
53
+ }
54
+ .metric-card {
55
+ background: linear-gradient(135deg, #f0f7ff 0%, #e0efff 100%);
56
+ padding: 1rem;
57
+ border-radius: 8px;
58
+ border: 1px solid #cfe2ff;
59
+ }
60
+ .pain-point {
61
+ background: #fff5f5;
62
+ border-left: 3px solid #e53e3e;
63
+ padding: 0.6rem 0.9rem;
64
+ border-radius: 4px;
65
+ margin: 0.3rem 0;
66
+ }
67
+ .opportunity {
68
+ background: #f0fff4;
69
+ border-left: 3px solid #38a169;
70
+ padding: 0.6rem 0.9rem;
71
+ border-radius: 4px;
72
+ margin: 0.3rem 0;
73
+ }
74
+ .stTabs [data-baseweb="tab-list"] { gap: 4px; }
75
+ .stTabs [data-baseweb="tab"] {
76
+ padding: 0.5rem 1rem;
77
+ background: #f1f5f9;
78
+ border-radius: 6px 6px 0 0;
79
+ }
80
+ .stTabs [aria-selected="true"] {
81
+ background: #1f4e79 !important;
82
+ color: white !important;
83
+ }
84
+ </style>
85
+ """,
86
+ unsafe_allow_html=True,
87
+ )
88
+
89
+ # ------------------------------------------------------------------
90
+ # Data definitions
91
+ # ------------------------------------------------------------------
92
+ TASKS = {
93
+ "1.4": {
94
+ "code": "1.4",
95
+ "title_th": "พนง.จัดหา ตรวจสอบ TOR/PR",
96
+ "title_en": "TOR/PR Review",
97
+ "icon": "📋",
98
+ "process": "1. TOR/PR Review",
99
+ "description": (
100
+ "Procurement officer reviews Terms of Reference (TOR) and Purchase Requisition (PR) "
101
+ "for completeness, accuracy, and compliance before initiating the sourcing process. "
102
+ "After review, the officer must verify in the Supplier Portal (SP)."
103
+ ),
104
+ "pain_points": [
105
+ "Manual page-by-page review of TOR/PR documents (15-45 min per request)",
106
+ "Inconsistent review standards across officers",
107
+ "Missing or ambiguous specifications discovered late in the process",
108
+ "Difficult to verify budget alignment against the procurement plan",
109
+ "Manual cross-checking with Approved Vendor List (AVL) and MESC codes",
110
+ "Repetitive verification across SAP MM, DP (Digital Procurement), and SP",
111
+ ],
112
+ "opportunities": [
113
+ "AI-powered document parser extracts key fields automatically (scope, budget, deliverables, timeline)",
114
+ "Rule-based validation engine for mandatory fields and budget thresholds",
115
+ "LLM-based ambiguity detection in technical specifications",
116
+ "Auto-suggest procurement method (ตกลงราคา / พิเศษ / ประมูล) from rule matrix",
117
+ "Auto-link to Technical TOR Template library for spec quality benchmarking",
118
+ "One-click cross-system verification: PR (DP) ↔ Plan ↔ AVL ↔ MESC ↔ Budget",
119
+ "Risk scoring dashboard highlights items needing human attention",
120
+ ],
121
+ "phases": [
122
+ {
123
+ "phase": "Phase 1: Quick Wins",
124
+ "duration": "0–3 months",
125
+ "items": [
126
+ "Build TOR/PR template checklist (web form) with auto-validation",
127
+ "Deploy OCR + structured field extraction (Azure Doc Intelligence / Textract)",
128
+ "Automated email notification with parsed summary to assigned officer",
129
+ ],
130
+ },
131
+ {
132
+ "phase": "Phase 2: Foundation",
133
+ "duration": "3–6 months",
134
+ "items": [
135
+ "Integrate with SAP MM (PR data), DP, and SP via API/RFC",
136
+ "Rule engine for budget, mandatory fields, MESC validity, AVL match",
137
+ "Audit log + dashboard for review SLA tracking",
138
+ ],
139
+ },
140
+ {
141
+ "phase": "Phase 3: Intelligence",
142
+ "duration": "6–12 months",
143
+ "items": [
144
+ "LLM-based spec quality scoring (clarity, completeness, ambiguity flags)",
145
+ "Auto-classify procurement method based on value, urgency, and category",
146
+ "Similar-PR retrieval (RAG over historical PRs) for benchmarking",
147
+ ],
148
+ },
149
+ {
150
+ "phase": "Phase 4: Full Automation",
151
+ "duration": "12+ months",
152
+ "items": [
153
+ "Straight-through verification for low-risk, routine PRs",
154
+ "Human-in-the-loop only for exceptions (risk score > threshold)",
155
+ "Continuous learning loop from officer feedback (RLHF-style)",
156
+ ],
157
+ },
158
+ ],
159
+ "kpis": {
160
+ "Review time": ("30 min", "5 min", "-83%"),
161
+ "Error rate": ("8%", "1%", "-87%"),
162
+ "SLA compliance": ("75%", "98%", "+23pp"),
163
+ },
164
+ "tech_stack": [
165
+ "Azure Document Intelligence / AWS Textract (OCR)",
166
+ "LangChain + Claude/GPT-4 (LLM analysis)",
167
+ "FastAPI backend",
168
+ "SAP RFC / OData connectors",
169
+ "PostgreSQL (audit log)",
170
+ "Streamlit / React (officer dashboard)",
171
+ ],
172
+ },
173
+ "2.1.1": {
174
+ "code": "2.1.1",
175
+ "title_th": "พนง.จัดหา ออก RFQ เพื่อเชิญผู้ค้าเสนอราคา",
176
+ "title_en": "Issue RFQ to Invite Vendors (Negotiated / Special Method)",
177
+ "icon": "📨",
178
+ "process": "2. RFQ Process",
179
+ "description": (
180
+ "For negotiated price (ตกลงราคา) or special method (พิเศษ) procurement, the officer issues "
181
+ "an RFQ to invite vendors registered in the Supplier Portal (SP) to submit quotations."
182
+ ),
183
+ "pain_points": [
184
+ "Manual vendor search in SP (filter by category, AVL status, performance)",
185
+ "Manual RFQ document drafting (terms, specs, deadlines) — copy-paste prone to error",
186
+ "Manually sending RFQ to each vendor and tracking acknowledgements",
187
+ "No central status view; follow-ups via phone/email scattered",
188
+ "Difficult to enforce minimum-vendor policy (e.g., 3 quotations required)",
189
+ ],
190
+ "opportunities": [
191
+ "Smart vendor recommender ranks vendors by category fit, AVL status, past performance, capacity",
192
+ "Auto-generated RFQ from TOR (template + dynamic clauses)",
193
+ "Bulk send via SP/email with personalized cover note (LLM-drafted)",
194
+ "Live tracking dashboard: sent → opened → accepted → submitted",
195
+ "Auto-reminder cadence with escalation rules",
196
+ "Policy guard: blocks send if minimum vendors not met",
197
+ ],
198
+ "phases": [
199
+ {
200
+ "phase": "Phase 1: Quick Wins",
201
+ "duration": "0–3 months",
202
+ "items": [
203
+ "RFQ template library with dynamic placeholders (TOR fields auto-fill)",
204
+ "Vendor list filter UI (category, AVL, region) with one-click export",
205
+ "Email merge: send personalized RFQ to selected vendors in one click",
206
+ ],
207
+ },
208
+ {
209
+ "phase": "Phase 2: Foundation",
210
+ "duration": "3–6 months",
211
+ "items": [
212
+ "Integration with SP API: pull vendor data, push RFQ, track responses",
213
+ "RFQ tracker dashboard: real-time status, deadline countdown, vendor engagement",
214
+ "Automatic reminder workflow (T-3, T-1, post-deadline escalation)",
215
+ ],
216
+ },
217
+ {
218
+ "phase": "Phase 3: Intelligence",
219
+ "duration": "6–12 months",
220
+ "items": [
221
+ "AI vendor recommender: ranks by historical win rate, price competitiveness, on-time delivery, category fit",
222
+ "Predicted response rate per vendor — pre-flight check before send",
223
+ "Anomaly flag: detects vendors that should not be invited (debarred, conflict of interest)",
224
+ ],
225
+ },
226
+ {
227
+ "phase": "Phase 4: Full Automation",
228
+ "duration": "12+ months",
229
+ "items": [
230
+ "End-to-end RFQ orchestration: triggered automatically post TOR/PR approval",
231
+ "Self-service for routine categories (officer reviews only edge cases)",
232
+ "Predictive sourcing: suggest framework agreement opportunities",
233
+ ],
234
+ },
235
+ ],
236
+ "kpis": {
237
+ "RFQ creation time": ("60 min", "10 min", "-83%"),
238
+ "Vendor response rate": ("55%", "85%", "+30pp"),
239
+ "Min-vendor compliance": ("82%", "100%", "+18pp"),
240
+ },
241
+ "tech_stack": [
242
+ "Supplier Portal API integration",
243
+ "Jinja2 / DOCX templating",
244
+ "Microsoft Graph / SMTP for email automation",
245
+ "n8n / Camunda workflow engine",
246
+ "ML recommender (LightGBM / collaborative filtering)",
247
+ "Streamlit / React tracker dashboard",
248
+ ],
249
+ },
250
+ "2.2": {
251
+ "code": "2.2",
252
+ "title_th": "พนง.จัดหา ตรวจสอบเอกสารเสนอราคา",
253
+ "title_en": "Review Vendor Quotation Documents",
254
+ "icon": "🔍",
255
+ "process": "2. RFQ Process",
256
+ "description": (
257
+ "Procurement officer reviews quotation documents submitted by vendors to check compliance "
258
+ "with TOR specifications, completeness of documents, pricing, and validity of terms."
259
+ ),
260
+ "pain_points": [
261
+ "Manually extracting prices and terms from inconsistent PDF formats (15–30 min per quote)",
262
+ "Side-by-side spec comparison done in Excel — error-prone, time-consuming",
263
+ "Hard to spot pricing anomalies or collusion patterns",
264
+ "Document checklist (BG, authorization letter, etc.) manually verified",
265
+ "No structured tabulation; bid analysis report compiled manually",
266
+ ],
267
+ "opportunities": [
268
+ "Auto-extract line items, unit prices, lead time, validity from PDF quotes (any format)",
269
+ "Auto bid tabulation with side-by-side comparison + variance analysis",
270
+ "AI compliance check: line-by-line match against TOR requirements",
271
+ "Anomaly detection: flag pricing outliers, identical bids, suspicious patterns",
272
+ "Document completeness checklist auto-verified (BG, signatures, validity dates)",
273
+ "One-click bid evaluation report (export to PDF/Word)",
274
+ ],
275
+ "phases": [
276
+ {
277
+ "phase": "Phase 1: Quick Wins",
278
+ "duration": "0–3 months",
279
+ "items": [
280
+ "Quotation upload portal with auto-tagging (vendor, RFQ ID, date)",
281
+ "OCR + table extraction for structured pricing data",
282
+ "Auto-generated tabulation Excel from extracted data",
283
+ ],
284
+ },
285
+ {
286
+ "phase": "Phase 2: Foundation",
287
+ "duration": "3–6 months",
288
+ "items": [
289
+ "Document completeness checker (BG, authorization, validity)",
290
+ "Compliance matrix: TOR requirements vs. vendor response (auto-mapped)",
291
+ "Bid evaluation report generator (one-click PDF/Word)",
292
+ ],
293
+ },
294
+ {
295
+ "phase": "Phase 3: Intelligence",
296
+ "duration": "6–12 months",
297
+ "items": [
298
+ "LLM-based spec compliance scoring (handles paraphrased responses)",
299
+ "Anomaly detection: pricing outliers, identical bids, bid-rigging signals",
300
+ "Historical benchmarking: 'this price is X% above market average'",
301
+ ],
302
+ },
303
+ {
304
+ "phase": "Phase 4: Full Automation",
305
+ "duration": "12+ months",
306
+ "items": [
307
+ "Auto-recommend winning vendor with justification narrative",
308
+ "Integrated with procurement committee dashboard for approval",
309
+ "Continuous learning from committee decisions to refine scoring",
310
+ ],
311
+ },
312
+ ],
313
+ "kpis": {
314
+ "Quote review time": ("90 min", "15 min", "-83%"),
315
+ "Compliance accuracy": ("85%", "99%", "+14pp"),
316
+ "Anomalies detected": ("manual", "auto", "—"),
317
+ },
318
+ "tech_stack": [
319
+ "Azure Document Intelligence / LlamaParse (table extraction)",
320
+ "Claude / GPT-4 with structured output (compliance check)",
321
+ "pandas + Plotly (tabulation & visualization)",
322
+ "scikit-learn / PyOD (anomaly detection)",
323
+ "python-docx / ReportLab (report generation)",
324
+ "Vector DB (Qdrant / Pinecone) for historical price benchmark",
325
+ ],
326
+ },
327
+ "3.1": {
328
+ "code": "3.1",
329
+ "title_th": "พนง.จัดหา จัดทำ VA/PO/LOI",
330
+ "title_en": "Create VA / PO / LOI",
331
+ "icon": "📄",
332
+ "process": "3. PO/LOI Process",
333
+ "description": (
334
+ "After award decision, the procurement officer creates the Value Agreement (VA), "
335
+ "Purchase Order (PO), or Letter of Intent (LOI) documents in SAP MM and the document system."
336
+ ),
337
+ "pain_points": [
338
+ "Manual data entry from quotation/award decision into SAP MM (high error risk)",
339
+ "Choosing the right document type (VA vs PO vs LOI) requires policy lookup",
340
+ "Manual template selection and population of clauses",
341
+ "Inconsistent payment terms, delivery terms, and warranty clauses across documents",
342
+ "Manual routing for approval based on value threshold (<5 MB vs >5 MB)",
343
+ "Hand-off to BSA for SAP entry — duplicate work and delay",
344
+ ],
345
+ "opportunities": [
346
+ "Auto-generate VA/PO/LOI draft from RFQ award data + vendor master + TOR",
347
+ "Smart document-type selector based on policy rules (value, duration, type)",
348
+ "Clause library with auto-insertion based on procurement type and risk profile",
349
+ "Direct SAP MM creation via BAPI/RFC (eliminates BSA re-entry)",
350
+ "Auto-routing for approval based on value thresholds (<5MB OC route, >5MB to นสญ.)",
351
+ "E-signature integration (DocuSign / Adobe Sign) for vendor acknowledgement",
352
+ ],
353
+ "phases": [
354
+ {
355
+ "phase": "Phase 1: Quick Wins",
356
+ "duration": "0–3 months",
357
+ "items": [
358
+ "Document type decision wizard (VA / PO / LOI based on inputs)",
359
+ "Template library with smart clause insertion",
360
+ "Auto-populate draft from award decision + vendor master export",
361
+ ],
362
+ },
363
+ {
364
+ "phase": "Phase 2: Foundation",
365
+ "duration": "3–6 months",
366
+ "items": [
367
+ "SAP MM integration (BAPI/RFC) — create PO directly from approved draft",
368
+ "Approval workflow with value-threshold routing (<5MB OC vs >5MB นสญ.)",
369
+ "Document version control + audit trail",
370
+ ],
371
+ },
372
+ {
373
+ "phase": "Phase 3: Intelligence",
374
+ "duration": "6–12 months",
375
+ "items": [
376
+ "AI clause recommender based on risk profile and historical patterns",
377
+ "Anomaly detection on terms (e.g., payment terms inconsistent with policy)",
378
+ "Smart linking to existing framework agreements (avoids duplicate VAs)",
379
+ ],
380
+ },
381
+ {
382
+ "phase": "Phase 4: Full Automation",
383
+ "duration": "12+ months",
384
+ "items": [
385
+ "Straight-through processing for routine POs under threshold",
386
+ "Integrated e-signature with vendor portal (auto-trigger 3.4)",
387
+ "Real-time contract intelligence dashboard for committee review",
388
+ ],
389
+ },
390
+ ],
391
+ "kpis": {
392
+ "Doc creation time": ("75 min", "10 min", "-87%"),
393
+ "Data entry errors": ("12%", "1%", "-92%"),
394
+ "Approval cycle time": ("3 days", "0.5 day", "-83%"),
395
+ },
396
+ "tech_stack": [
397
+ "SAP RFC / BAPI / OData",
398
+ "python-docx / docxtpl (template engine)",
399
+ "Camunda / n8n (approval workflow)",
400
+ "DocuSign API / Adobe Sign (e-signature)",
401
+ "Claude / GPT-4 (clause recommender)",
402
+ "PostgreSQL + audit log",
403
+ ],
404
+ },
405
+ }
406
+
407
+ # ------------------------------------------------------------------
408
+ # Sidebar
409
+ # ------------------------------------------------------------------
410
+ with st.sidebar:
411
+ st.markdown("### 🛒 Procurement Automation")
412
+ st.markdown("**Roadmap & Strategy Tool**")
413
+ st.markdown("---")
414
+
415
+ page = st.radio(
416
+ "Navigate",
417
+ [
418
+ "🏠 Executive Summary",
419
+ "📋 1.4 TOR/PR Review",
420
+ "📨 2.1.1 RFQ Process",
421
+ "🔍 2.2 Quotation Review",
422
+ "📄 3.1 VA/PO/LOI Creation",
423
+ "🗺️ Visual Roadmap (Gantt)",
424
+ "💰 ROI Calculator",
425
+ "🛠️ Technology Stack",
426
+ ],
427
+ label_visibility="collapsed",
428
+ )
429
+
430
+ st.markdown("---")
431
+ st.caption("Built for procurement officers in the Gas Pipeline Business Unit (ระบบท่อส่งก๊าซฯ).")
432
+ st.caption(f"📅 Generated {datetime.now().strftime('%Y-%m-%d')}")
433
+
434
+ # ------------------------------------------------------------------
435
+ # Helper renderers
436
+ # ------------------------------------------------------------------
437
+ def render_task_detail(task_key: str):
438
+ t = TASKS[task_key]
439
+
440
+ st.markdown(
441
+ f"<div class='main-header'>{t['icon']} {t['code']} — {t['title_en']}</div>",
442
+ unsafe_allow_html=True,
443
+ )
444
+ st.markdown(f"**ภาษาไทย:** {t['title_th']}")
445
+ st.markdown(f"<span class='task-badge'>{t['process']}</span>", unsafe_allow_html=True)
446
+ st.markdown("")
447
+ st.info(t["description"])
448
+
449
+ # KPI metrics
450
+ st.markdown("#### 📊 Expected Impact")
451
+ cols = st.columns(len(t["kpis"]))
452
+ for col, (kpi_name, (before, after, delta)) in zip(cols, t["kpis"].items()):
453
+ with col:
454
+ st.metric(label=kpi_name, value=after, delta=delta, delta_color="inverse"
455
+ if delta.startswith("-") else "normal")
456
+ st.caption(f"Current: **{before}** → Target: **{after}**")
457
+
458
+ st.markdown("---")
459
+
460
+ # Pain points and opportunities side by side
461
+ col1, col2 = st.columns(2)
462
+ with col1:
463
+ st.markdown("#### 🔴 Current Pain Points")
464
+ for p in t["pain_points"]:
465
+ st.markdown(f"<div class='pain-point'>{p}</div>", unsafe_allow_html=True)
466
+ with col2:
467
+ st.markdown("#### 🟢 Automation Opportunities")
468
+ for o in t["opportunities"]:
469
+ st.markdown(f"<div class='opportunity'>{o}</div>", unsafe_allow_html=True)
470
+
471
+ st.markdown("---")
472
+
473
+ # Phased roadmap
474
+ st.markdown("#### 🗺️ Phased Roadmap")
475
+ for i, phase in enumerate(t["phases"]):
476
+ with st.expander(f"**{phase['phase']}** ({phase['duration']})", expanded=(i == 0)):
477
+ for item in phase["items"]:
478
+ st.markdown(f"- {item}")
479
+
480
+ st.markdown("---")
481
+
482
+ # Tech stack
483
+ st.markdown("#### 🛠️ Technology Stack")
484
+ cols = st.columns(2)
485
+ for i, tech in enumerate(t["tech_stack"]):
486
+ with cols[i % 2]:
487
+ st.markdown(f"• {tech}")
488
+
489
+
490
+ # ------------------------------------------------------------------
491
+ # Pages
492
+ # ------------------------------------------------------------------
493
+ if page == "🏠 Executive Summary":
494
+ st.markdown(
495
+ "<div class='main-header'>🛒 Procurement Automation Roadmap</div>",
496
+ unsafe_allow_html=True,
497
+ )
498
+ st.markdown(
499
+ "**An automation program for procurement officers (พนักงานจัดหา) — "
500
+ "Gas Pipeline Business Unit (ระบบท่อส่งก๊าซฯ)**"
501
+ )
502
+ st.markdown("---")
503
+
504
+ st.markdown("### 🎯 Vision")
505
+ st.markdown(
506
+ "Transform 4 high-friction procurement tasks into AI-augmented, mostly-automated workflows — "
507
+ "freeing officers to focus on **strategic sourcing, supplier relationships, and risk management** "
508
+ "instead of repetitive document handling and data entry."
509
+ )
510
+
511
+ st.markdown("### 📌 Scope — 4 Target Activities")
512
+ overview_df = pd.DataFrame(
513
+ [
514
+ {
515
+ "Code": "1.4",
516
+ "Activity (EN)": "TOR/PR Review",
517
+ "Activity (TH)": "ตรวจสอบ TOR/PR",
518
+ "Process": "1. TOR/PR Review",
519
+ "Automation Potential": "High",
520
+ },
521
+ {
522
+ "Code": "2.1.1",
523
+ "Activity (EN)": "Issue RFQ to Vendors",
524
+ "Activity (TH)": "ออก RFQ เชิญผู้ค้าเสนอราคา",
525
+ "Process": "2. RFQ Process",
526
+ "Automation Potential": "High",
527
+ },
528
+ {
529
+ "Code": "2.2",
530
+ "Activity (EN)": "Review Vendor Quotations",
531
+ "Activity (TH)": "ตรวจสอบเอกสารเสนอราคา",
532
+ "Process": "2. RFQ Process",
533
+ "Automation Potential": "Very High",
534
+ },
535
+ {
536
+ "Code": "3.1",
537
+ "Activity (EN)": "Create VA/PO/LOI",
538
+ "Activity (TH)": "จัดทำ VA/PO/LOI",
539
+ "Process": "3. PO/LOI Process",
540
+ "Automation Potential": "Very High",
541
+ },
542
+ ]
543
+ )
544
+ st.dataframe(overview_df, use_container_width=True, hide_index=True)
545
+
546
+ st.markdown("### 📈 Aggregate Expected Impact")
547
+ c1, c2, c3, c4 = st.columns(4)
548
+ c1.metric("Cycle time reduction", "~85%", "across all 4 tasks")
549
+ c2.metric("Officer hours saved", "~2,400 hrs/yr", "per officer")
550
+ c3.metric("Error rate", "↓ 88%", "fewer rework cycles")
551
+ c4.metric("SLA compliance", "98%", "+23 pp")
552
+
553
+ st.markdown("---")
554
+ st.markdown("### 🏗️ 4-Phase Strategy (12+ months)")
555
+
556
+ phase_overview = [
557
+ ("Phase 1: Quick Wins", "0–3 months",
558
+ "Lightweight tools the team can use day-one: templates, OCR, checklists, email merge. "
559
+ "Low integration cost, immediate friction reduction."),
560
+ ("Phase 2: Foundation", "3–6 months",
561
+ "Integrate with SAP MM, DP, SP. Build rule engines, workflow automation, and dashboards. "
562
+ "Replace manual hand-offs with API-driven flows."),
563
+ ("Phase 3: Intelligence", "6–12 months",
564
+ "Layer in AI/ML: LLM-based document analysis, vendor recommenders, anomaly detection, "
565
+ "compliance scoring. Officers shift from doing to reviewing."),
566
+ ("Phase 4: Full Automation", "12+ months",
567
+ "Straight-through processing for routine cases. Human-in-the-loop only on exceptions. "
568
+ "Continuous learning loop refines the system."),
569
+ ]
570
+ for name, duration, desc in phase_overview:
571
+ st.markdown(
572
+ f"<div class='phase-card'><b>{name}</b> "
573
+ f"<span style='color:#64748b'>({duration})</span><br>{desc}</div>",
574
+ unsafe_allow_html=True,
575
+ )
576
+
577
+ st.markdown("### 🧭 How to use this app")
578
+ st.markdown(
579
+ "- Use the **sidebar** to navigate task-by-task or jump to the visual Gantt roadmap.\n"
580
+ "- Each task page shows pain points, automation opportunities, phased plan, KPIs, and tech stack.\n"
581
+ "- Try the **💰 ROI Calculator** to estimate savings for your team size."
582
+ )
583
+
584
+ elif page == "📋 1.4 TOR/PR Review":
585
+ render_task_detail("1.4")
586
+
587
+ elif page == "📨 2.1.1 RFQ Process":
588
+ render_task_detail("2.1.1")
589
+
590
+ elif page == "🔍 2.2 Quotation Review":
591
+ render_task_detail("2.2")
592
+
593
+ elif page == "📄 3.1 VA/PO/LOI Creation":
594
+ render_task_detail("3.1")
595
+
596
+ elif page == "🗺️ Visual Roadmap (Gantt)":
597
+ st.markdown(
598
+ "<div class='main-header'>🗺️ Visual Roadmap (Gantt View)</div>",
599
+ unsafe_allow_html=True,
600
+ )
601
+ st.markdown(
602
+ "Phased delivery plan across the 4 target activities. "
603
+ "Hover any bar for details."
604
+ )
605
+
606
+ # Build Gantt data
607
+ rows = []
608
+ phase_durations = {
609
+ "Phase 1: Quick Wins": (0, 3),
610
+ "Phase 2: Foundation": (3, 6),
611
+ "Phase 3: Intelligence": (6, 12),
612
+ "Phase 4: Full Automation": (12, 18),
613
+ }
614
+ today = datetime(2026, 5, 1)
615
+ for code, t in TASKS.items():
616
+ for phase in t["phases"]:
617
+ start_m, end_m = phase_durations[phase["phase"]]
618
+ start_date = pd.Timestamp(today) + pd.DateOffset(months=start_m)
619
+ end_date = pd.Timestamp(today) + pd.DateOffset(months=end_m)
620
+ rows.append(
621
+ {
622
+ "Task": f"{code} {t['title_en']}",
623
+ "Phase": phase["phase"],
624
+ "Start": start_date,
625
+ "Finish": end_date,
626
+ "Description": "<br>• " + "<br>• ".join(phase["items"]),
627
+ }
628
+ )
629
+ gantt_df = pd.DataFrame(rows)
630
+
631
+ fig = px.timeline(
632
+ gantt_df,
633
+ x_start="Start",
634
+ x_end="Finish",
635
+ y="Task",
636
+ color="Phase",
637
+ hover_data={"Description": True, "Start": False, "Finish": False, "Task": False},
638
+ color_discrete_map={
639
+ "Phase 1: Quick Wins": "#60a5fa",
640
+ "Phase 2: Foundation": "#1f4e79",
641
+ "Phase 3: Intelligence": "#10b981",
642
+ "Phase 4: Full Automation": "#f59e0b",
643
+ },
644
+ )
645
+ fig.update_yaxes(autorange="reversed")
646
+ fig.update_layout(
647
+ height=500,
648
+ margin=dict(l=10, r=10, t=30, b=10),
649
+ legend_title_text="",
650
+ legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1),
651
+ )
652
+ st.plotly_chart(fig, use_container_width=True)
653
+
654
+ st.markdown("### 📌 Cross-cutting milestones")
655
+ milestones = pd.DataFrame(
656
+ [
657
+ {"Month": "M3", "Milestone": "All 4 tasks have working Phase-1 tooling in pilot"},
658
+ {"Month": "M6", "Milestone": "SAP MM + DP + SP integrations live"},
659
+ {"Month": "M9", "Milestone": "AI/LLM features in production for tasks 1.4 & 2.2"},
660
+ {"Month": "M12", "Milestone": "Officers handling >50% of cases in 'review mode' only"},
661
+ {"Month": "M18", "Milestone": "Straight-through processing for routine procurement"},
662
+ ]
663
+ )
664
+ st.dataframe(milestones, use_container_width=True, hide_index=True)
665
+
666
+ elif page == "💰 ROI Calculator":
667
+ st.markdown(
668
+ "<div class='main-header'>💰 ROI Calculator</div>",
669
+ unsafe_allow_html=True,
670
+ )
671
+ st.markdown("Estimate annual savings from automating the 4 target tasks.")
672
+
673
+ col1, col2 = st.columns(2)
674
+ with col1:
675
+ st.markdown("#### 📥 Inputs")
676
+ n_officers = st.number_input("Number of procurement officers", 1, 200, 15)
677
+ cases_per_month = st.number_input("Procurement cases per officer per month", 1, 100, 20)
678
+ hourly_cost = st.number_input("Fully-loaded officer cost per hour (THB)", 100, 5000, 800)
679
+ adoption = st.slider("Phase-2 target adoption rate (%)", 30, 100, 75)
680
+
681
+ # Time savings assumptions (minutes per case, before → after)
682
+ time_savings = {
683
+ "1.4 TOR/PR Review": (30, 5),
684
+ "2.1.1 RFQ": (60, 10),
685
+ "2.2 Quote Review": (90, 15),
686
+ "3.1 VA/PO/LOI": (75, 10),
687
+ }
688
+
689
+ saved_min_per_case = sum(before - after for before, after in time_savings.values())
690
+ cases_per_year = cases_per_month * 12
691
+ total_cases = n_officers * cases_per_year
692
+
693
+ saved_hours = (saved_min_per_case * total_cases / 60) * (adoption / 100)
694
+ saved_thb = saved_hours * hourly_cost
695
+
696
+ with col2:
697
+ st.markdown("#### 📤 Estimated Annual Impact")
698
+ st.metric("Hours saved per year", f"{saved_hours:,.0f} hrs")
699
+ st.metric("THB saved per year", f"฿{saved_thb:,.0f}")
700
+ st.metric("Per-case time saved", f"{saved_min_per_case} min", "across 4 tasks")
701
+ st.caption("Conservative estimate; assumes Phase-2 maturity and stated adoption rate.")
702
+
703
+ st.markdown("---")
704
+ st.markdown("#### 📊 Time saved breakdown (minutes per case)")
705
+ breakdown = pd.DataFrame(
706
+ [
707
+ {"Task": k, "Before (min)": b, "After (min)": a, "Saved (min)": b - a}
708
+ for k, (b, a) in time_savings.items()
709
+ ]
710
+ )
711
+ fig = go.Figure()
712
+ fig.add_trace(go.Bar(name="Before", x=breakdown["Task"], y=breakdown["Before (min)"],
713
+ marker_color="#fca5a5"))
714
+ fig.add_trace(go.Bar(name="After", x=breakdown["Task"], y=breakdown["After (min)"],
715
+ marker_color="#86efac"))
716
+ fig.update_layout(
717
+ barmode="group",
718
+ height=380,
719
+ margin=dict(l=10, r=10, t=30, b=10),
720
+ yaxis_title="Minutes per case",
721
+ legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1),
722
+ )
723
+ st.plotly_chart(fig, use_container_width=True)
724
+
725
+ st.markdown("#### 💡 Investment ballpark")
726
+ st.markdown(
727
+ "- **Phase 1** (0–3 mo): ฿0.5–1.5M (templates, OCR, integrations-lite)\n"
728
+ "- **Phase 2** (3–6 mo): ฿2–5M (SAP/DP/SP integration, workflow engine, dashboards)\n"
729
+ "- **Phase 3** (6–12 mo): ฿3–7M (LLM/ML features, recommenders, anomaly detection)\n"
730
+ "- **Phase 4** (12+ mo): ฿2–4M (STP refinements, learning loop)\n"
731
+ "- **Run cost**: ~15–20% of build per year (cloud, licenses, support)\n\n"
732
+ "*Ranges only — refine with vendor quotes and internal cost models.*"
733
+ )
734
+
735
+ elif page == "🛠️ Technology Stack":
736
+ st.markdown(
737
+ "<div class='main-header'>🛠️ Technology Stack — Reference Architecture</div>",
738
+ unsafe_allow_html=True,
739
+ )
740
+
741
+ st.markdown("### 🧩 Layered View")
742
+ layers = {
743
+ "📱 Officer Experience Layer": [
744
+ "Streamlit / React web app for officer dashboards",
745
+ "Microsoft Teams bot for notifications & quick actions",
746
+ "Mobile-responsive PWA for approval on-the-go",
747
+ ],
748
+ "🤖 AI & Intelligence Layer": [
749
+ "Claude / GPT-4 (via API) for document understanding, spec analysis, clause recommendation",
750
+ "LangChain / LlamaIndex for orchestration & RAG over historical PRs/POs",
751
+ "Azure Document Intelligence / AWS Textract for OCR + structured extraction",
752
+ "Vector DB (Qdrant / Pinecone / pgvector) for similarity search & benchmarking",
753
+ "scikit-learn / LightGBM / PyOD for vendor scoring & anomaly detection",
754
+ ],
755
+ "⚙️ Workflow & Automation Layer": [
756
+ "Camunda / n8n / Power Automate for approval routing & business workflows",
757
+ "FastAPI / Node.js services for business logic",
758
+ "Celery / Temporal for long-running tasks (RFQ tracking, reminders)",
759
+ ],
760
+ "🔌 Integration Layer": [
761
+ "SAP MM via RFC / BAPI / OData (PR, PO, Vendor Master, Material Master)",
762
+ "Digital Procurement (DP) API for PR approval status",
763
+ "Supplier Portal (SP) API for vendor verification & RFQ distribution",
764
+ "Microsoft Graph / SMTP for email automation",
765
+ "DocuSign / Adobe Sign for e-signature",
766
+ ],
767
+ "💾 Data & Audit Layer": [
768
+ "PostgreSQL for transactional & audit data",
769
+ "S3 / Azure Blob for document storage",
770
+ "ELK / OpenSearch for log analytics",
771
+ "Power BI / Metabase for executive dashboards",
772
+ ],
773
+ "🔐 Security & Governance": [
774
+ "SSO via Azure AD / Keycloak",
775
+ "Role-based access control (RBAC) aligned with PTT procurement policy",
776
+ "Audit trail for every automated decision (regulatory traceability)",
777
+ "Data classification & DLP for vendor/financial data",
778
+ ],
779
+ }
780
+
781
+ for layer, items in layers.items():
782
+ with st.expander(f"**{layer}**", expanded=True):
783
+ for it in items:
784
+ st.markdown(f"- {it}")
785
+
786
+ st.markdown("### 🏗️ Suggested Build Order")
787
+ st.markdown(
788
+ "1. **Foundation first**: integration layer (SAP/DP/SP connectors) + data layer + auth. "
789
+ "Everything else depends on these.\n"
790
+ "2. **One task end-to-end**: pick Task 2.2 (Quotation Review) as the pilot — highest impact, "
791
+ "most contained, easiest to demo value.\n"
792
+ "3. **Officer experience**: ship the dashboard early even with manual flows behind it — "
793
+ "drives adoption and surfaces requirements.\n"
794
+ "4. **AI layer last** for any given task: rule-based first, AI on top once data flows are stable."
795
+ )
796
+
797
+ st.markdown("### ⚠️ Risks & Mitigations")
798
+ risks = pd.DataFrame(
799
+ [
800
+ {
801
+ "Risk": "SAP integration delays",
802
+ "Likelihood": "High",
803
+ "Impact": "High",
804
+ "Mitigation": "Engage SAP CoE early; start with read-only OData; fall back to RPA if needed",
805
+ },
806
+ {
807
+ "Risk": "Officer resistance to automation",
808
+ "Likelihood": "Medium",
809
+ "Impact": "High",
810
+ "Mitigation": "Co-design with officers; frame as 'augment, not replace'; clear win-win cases",
811
+ },
812
+ {
813
+ "Risk": "LLM accuracy on Thai TOR/PR documents",
814
+ "Likelihood": "Medium",
815
+ "Impact": "Medium",
816
+ "Mitigation": "Few-shot prompting with PTT examples; human-in-the-loop for low-confidence; eval set",
817
+ },
818
+ {
819
+ "Risk": "Data quality in vendor master / MESC",
820
+ "Likelihood": "High",
821
+ "Impact": "Medium",
822
+ "Mitigation": "Data cleanup project in parallel; surface quality issues in dashboard",
823
+ },
824
+ {
825
+ "Risk": "Audit & compliance concerns",
826
+ "Likelihood": "Medium",
827
+ "Impact": "High",
828
+ "Mitigation": "Audit log every decision; align with PTT procurement policy & internal audit early",
829
+ },
830
+ ]
831
+ )
832
+ st.dataframe(risks, use_container_width=True, hide_index=True)
833
+
834
+ # ------------------------------------------------------------------
835
+ # Footer
836
+ # ------------------------------------------------------------------
837
+ st.markdown("---")
838
+ st.caption(
839
+ "📋 Source workflow: PTT Gas Pipeline procurement process (Work Flow กระบวนการจัดหา). "
840
+ "This roadmap covers the 4 procurement-officer-led activities. "
841
+ "Other workflow steps (User, Planner, BSA, ผจ.จบ., committee, vendor) are out of scope here "
842
+ "but can be added in follow-on phases."
843
+ )
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
- altair
2
- pandas
3
- streamlit
 
1
+ streamlit==1.39.0
2
+ pandas==2.2.3
3
+ plotly==5.24.1