haileyhalimj@gmail.com commited on
Commit
aedf8cc
·
1 Parent(s): 29592c6

Architechture diagram

Browse files
Files changed (1) hide show
  1. ARCHITECTURE_DIAGRAM.md +729 -0
ARCHITECTURE_DIAGRAM.md ADDED
@@ -0,0 +1,729 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🏗️ Supply Roster Optimization Tool - Architecture Diagram
2
+
3
+ ## 📋 System Overview
4
+
5
+ 이 문서는 Supply Roster Optimization Tool의 전체 아키텍처와 데이터 흐름을 설명합니다.
6
+
7
+ ---
8
+
9
+ ## 🎯 High-Level Architecture
10
+
11
+ ```mermaid
12
+ graph TB
13
+ subgraph "🚀 Entry Points"
14
+ MAIN[main.py<br/>Main Entry Point]
15
+ APP[ui/app.py<br/>Streamlit App]
16
+ end
17
+
18
+ subgraph "🎨 UI Layer - Streamlit Pages"
19
+ CONFIG[config_page.py<br/>Settings & Configuration]
20
+ RESULTS[optimization_results.py<br/>Results Visualization]
21
+ VALIDATION[demand_validation_viz.py<br/>Data Validation]
22
+ end
23
+
24
+ subgraph "🧮 Core Logic"
25
+ OPTIMIZER[optimizer_real.py<br/>OR-Tools Optimization<br/>OR-Tools CBC Solver]
26
+ FILTER[demand_filtering.py<br/>Demand Filtering Logic]
27
+ end
28
+
29
+ subgraph "⚙️ Configuration"
30
+ OPT_CONFIG[optimization_config.py<br/>Dynamic Configuration<br/>Parameters & Settings]
31
+ CONSTANTS[constants.py<br/>Enums & Constants<br/>ShiftType, LineType, KitLevel]
32
+ PATHS[paths.yaml<br/>File Path Configuration]
33
+ end
34
+
35
+ subgraph "🔄 Data Preprocessing"
36
+ CONVERTER[excel_to_csv_converter.py<br/>Excel → CSV]
37
+ EXTRACT[extract.py<br/>Data Reading Functions]
38
+ TRANSFORM[transform.py<br/>Data Transformation]
39
+ HIERARCHY[hierarchy_parser.py<br/>Kit Hierarchy Parser]
40
+ CLEANER[kit_composition_cleaner.py<br/>Data Cleaning]
41
+ PREPROCESS[data_preprocess.py<br/>Main Preprocessing]
42
+ end
43
+
44
+ subgraph "📊 Data Sources"
45
+ EXCEL[(Excel Files<br/>AI Project document.xlsx)]
46
+ CSV[(CSV Files<br/>30+ Data Files)]
47
+ HIERARCHY_JSON[(kit_hierarchy.json<br/>Kit Dependencies)]
48
+ end
49
+
50
+ subgraph "📈 Visualization"
51
+ PLOTLY[Plotly Charts<br/>Interactive Visualizations]
52
+ HIERARCHY_DASH[hierarchy_dashboard.py<br/>Hierarchy Visualization]
53
+ KIT_REL[kit_relationships.py<br/>Kit Relationships]
54
+ end
55
+
56
+ %% Entry Points Flow
57
+ MAIN --> APP
58
+ APP --> CONFIG
59
+ APP --> RESULTS
60
+ APP --> VALIDATION
61
+
62
+ %% UI to Core Logic
63
+ CONFIG -->|User Settings| OPT_CONFIG
64
+ CONFIG -->|Run Optimization| OPTIMIZER
65
+ RESULTS -->|Display Results| PLOTLY
66
+ VALIDATION -->|Validate Data| FILTER
67
+
68
+ %% Configuration Flow
69
+ OPT_CONFIG --> CONSTANTS
70
+ OPT_CONFIG --> PATHS
71
+ OPT_CONFIG --> EXTRACT
72
+ OPTIMIZER --> OPT_CONFIG
73
+
74
+ %% Preprocessing Flow
75
+ EXCEL -->|Convert| CONVERTER
76
+ CONVERTER --> CSV
77
+ CSV --> EXTRACT
78
+ EXTRACT --> TRANSFORM
79
+ EXTRACT --> HIERARCHY
80
+ TRANSFORM --> PREPROCESS
81
+ HIERARCHY -->|Parse| HIERARCHY_JSON
82
+ HIERARCHY_JSON --> OPT_CONFIG
83
+ CLEANER --> CSV
84
+
85
+ %% Data to Optimization
86
+ CSV --> EXTRACT
87
+ EXTRACT -->|Read Data| OPT_CONFIG
88
+ HIERARCHY_JSON -->|Dependencies| OPT_CONFIG
89
+ OPT_CONFIG -->|Parameters| OPTIMIZER
90
+
91
+ %% Optimization to Results
92
+ OPTIMIZER -->|Results| RESULTS
93
+ FILTER -->|Filtered Data| VALIDATION
94
+
95
+ %% Visualization
96
+ RESULTS --> PLOTLY
97
+ RESULTS --> HIERARCHY_DASH
98
+ RESULTS --> KIT_REL
99
+
100
+ %% Styling
101
+ classDef entryPoint fill:#4CAF50,stroke:#2E7D32,color:#fff
102
+ classDef ui fill:#2196F3,stroke:#1565C0,color:#fff
103
+ classDef core fill:#FF9800,stroke:#E65100,color:#fff
104
+ classDef config fill:#9C27B0,stroke:#6A1B9A,color:#fff
105
+ classDef preprocess fill:#00BCD4,stroke:#006064,color:#fff
106
+ classDef data fill:#607D8B,stroke:#37474F,color:#fff
107
+ classDef viz fill:#E91E63,stroke:#880E4F,color:#fff
108
+
109
+ class MAIN,APP entryPoint
110
+ class CONFIG,RESULTS,VALIDATION ui
111
+ class OPTIMIZER,FILTER core
112
+ class OPT_CONFIG,CONSTANTS,PATHS config
113
+ class CONVERTER,EXTRACT,TRANSFORM,HIERARCHY,CLEANER,PREPROCESS preprocess
114
+ class EXCEL,CSV,HIERARCHY_JSON data
115
+ class PLOTLY,HIERARCHY_DASH,KIT_REL viz
116
+ ```
117
+
118
+ ---
119
+
120
+ ## 🔄 Data Flow Details
121
+
122
+ ```mermaid
123
+ flowchart LR
124
+ subgraph "1️⃣ Data Ingestion"
125
+ A1[Excel Files] -->|excel_to_csv_converter.py| A2[CSV Files]
126
+ A2 -->|hierarchy_parser.py| A3[kit_hierarchy.json]
127
+ end
128
+
129
+ subgraph "2️⃣ Data Processing"
130
+ B1[extract.py<br/>Read Functions]
131
+ B2[transform.py<br/>Transform Logic]
132
+ B3[data_preprocess.py<br/>Main Processing]
133
+
134
+ A2 --> B1
135
+ B1 --> B2
136
+ B2 --> B3
137
+ A3 --> B1
138
+ end
139
+
140
+ subgraph "3️⃣ Configuration"
141
+ C1[optimization_config.py]
142
+ C2[Dynamic Parameters:<br/>- Products<br/>- Demand<br/>- Employees<br/>- Costs<br/>- Hierarchy]
143
+
144
+ B3 --> C1
145
+ C1 --> C2
146
+ end
147
+
148
+ subgraph "4️⃣ Optimization"
149
+ D1[optimizer_real.py]
150
+ D2[OR-Tools CBC Solver]
151
+ D3[Variables:<br/>- Assignment<br/>- Hours<br/>- Units<br/>- Employee Count]
152
+ D4[Constraints:<br/>- Demand<br/>- Capacity<br/>- Dependencies<br/>- Staffing]
153
+
154
+ C2 --> D1
155
+ D1 --> D2
156
+ D2 --> D3
157
+ D3 --> D4
158
+ end
159
+
160
+ subgraph "5️⃣ Results"
161
+ E1[Optimization Results:<br/>- Schedule<br/>- Production<br/>- Costs<br/>- Headcount]
162
+ E2[Visualization:<br/>- Charts<br/>- Tables<br/>- Analysis]
163
+
164
+ D4 --> E1
165
+ E1 --> E2
166
+ end
167
+
168
+ style A1 fill:#607D8B,color:#fff
169
+ style A2 fill:#607D8B,color:#fff
170
+ style A3 fill:#607D8B,color:#fff
171
+ style B1 fill:#00BCD4,color:#fff
172
+ style B2 fill:#00BCD4,color:#fff
173
+ style B3 fill:#00BCD4,color:#fff
174
+ style C1 fill:#9C27B0,color:#fff
175
+ style C2 fill:#9C27B0,color:#fff
176
+ style D1 fill:#FF9800,color:#fff
177
+ style D2 fill:#FF9800,color:#fff
178
+ style D3 fill:#FF9800,color:#fff
179
+ style D4 fill:#FF9800,color:#fff
180
+ style E1 fill:#2196F3,color:#fff
181
+ style E2 fill:#E91E63,color:#fff
182
+ ```
183
+
184
+ ---
185
+
186
+ ## 📦 Key Data Files & Their Purpose
187
+
188
+ ```mermaid
189
+ mindmap
190
+ root((Data Sources))
191
+ Raw Excel
192
+ AI Project document.xlsx
193
+ 30+ sheets of data
194
+ Production orders
195
+ Workforce info
196
+ Kit compositions
197
+ CSV Files
198
+ Demand Data
199
+ COOIS_Planned_and_Released.csv
200
+ Active_Kit_overview.csv
201
+ Order_management_Gui.csv
202
+ Workforce Data
203
+ WH_Workforce_Hourly_Pay_Scale.csv
204
+ workforce_info.csv
205
+ Fixed_Workstation_manning.csv
206
+ Production Data
207
+ Kits__Calculation.csv
208
+ Kit_Composition_and_relation.csv
209
+ Material_Master_WMS.csv
210
+ Capacity Data
211
+ Work_Centre_Capacity.csv
212
+ work_shift_timing.csv
213
+ Bagging_Workcenters.csv
214
+ Long_line_Workcenters.csv
215
+ Short_line_Workcenters.csv
216
+ Hierarchy Data
217
+ kit_hierarchy.json
218
+ Master → Subkit → Prepack
219
+ Dependencies
220
+ Production order
221
+ ```
222
+
223
+ ---
224
+
225
+ ## 🧮 Optimization Model Components
226
+
227
+ ```mermaid
228
+ graph TD
229
+ subgraph "📥 Input Parameters"
230
+ I1[Products & Demand<br/>What to produce & how much]
231
+ I2[Workforce<br/>Available employees by type]
232
+ I3[Production Lines<br/>Long lines, Short lines]
233
+ I4[Costs<br/>Hourly rates by shift]
234
+ I5[Kit Hierarchy<br/>Dependencies & levels]
235
+ end
236
+
237
+ subgraph "🎯 Optimization Variables"
238
+ V1[Assignment Variables<br/>Product → Line × Shift × Day]
239
+ V2[Hours Variables<br/>Production time per assignment]
240
+ V3[Units Variables<br/>Production quantity]
241
+ V4[Employee Count Variables<br/>Workers needed per shift]
242
+ end
243
+
244
+ subgraph "⚖️ Constraints"
245
+ C1[Demand Constraints<br/>Must meet exact demand]
246
+ C2[Capacity Constraints<br/>Line & worker limits]
247
+ C3[Hierarchy Constraints<br/>Dependencies first]
248
+ C4[Staffing Constraints<br/>Min UNICEF employees]
249
+ C5[Shift Ordering<br/>Overtime rules]
250
+ C6[Line Compatibility<br/>Product-line matching]
251
+ end
252
+
253
+ subgraph "🎯 Objective Function"
254
+ O1[Minimize Total Labor Cost<br/>Cost = Σ employees × hours × hourly_rate]
255
+ end
256
+
257
+ subgraph "✅ Output Results"
258
+ R1[Production Schedule<br/>Day × Line × Shift × Product]
259
+ R2[Employee Allocation<br/>Type × Shift × Day × Count]
260
+ R3[Cost Breakdown<br/>Total cost & per employee type]
261
+ R4[Production Metrics<br/>Units produced & fulfillment %]
262
+ end
263
+
264
+ I1 --> V1
265
+ I2 --> V4
266
+ I3 --> V1
267
+ I4 --> O1
268
+ I5 --> C3
269
+
270
+ V1 --> C1
271
+ V1 --> C2
272
+ V1 --> C6
273
+ V2 --> C2
274
+ V2 --> C5
275
+ V3 --> C1
276
+ V4 --> C4
277
+
278
+ C1 --> O1
279
+ C2 --> O1
280
+ C3 --> O1
281
+ C4 --> O1
282
+ C5 --> O1
283
+ C6 --> O1
284
+
285
+ O1 --> R1
286
+ O1 --> R2
287
+ O1 --> R3
288
+ O1 --> R4
289
+
290
+ classDef input fill:#4CAF50,stroke:#2E7D32,color:#fff
291
+ classDef variable fill:#2196F3,stroke:#1565C0,color:#fff
292
+ classDef constraint fill:#FF9800,stroke:#E65100,color:#fff
293
+ classDef objective fill:#9C27B0,stroke:#6A1B9A,color:#fff
294
+ classDef output fill:#E91E63,stroke:#880E4F,color:#fff
295
+
296
+ class I1,I2,I3,I4,I5 input
297
+ class V1,V2,V3,V4 variable
298
+ class C1,C2,C3,C4,C5,C6 constraint
299
+ class O1 objective
300
+ class R1,R2,R3,R4 output
301
+ ```
302
+
303
+ ---
304
+
305
+ ## 🎨 UI Components & User Flow
306
+
307
+ ```mermaid
308
+ journey
309
+ title User Journey Through the Application
310
+ section 1. Launch
311
+ Run main.py: 5: User
312
+ Streamlit starts: 5: System
313
+ App loads: 5: System
314
+ section 2. Configuration
315
+ Navigate to Settings: 5: User
316
+ Select date range: 5: User
317
+ Configure workforce: 4: User
318
+ Set cost rates: 4: User
319
+ Choose shifts: 4: User
320
+ section 3. Optimization
321
+ Click "Optimize": 5: User
322
+ Load data: 5: System
323
+ Run OR-Tools: 3: System
324
+ Generate solution: 3: System
325
+ section 4. Results
326
+ View weekly summary: 5: User
327
+ Explore daily breakdown: 4: User
328
+ Check line schedules: 4: User
329
+ Analyze costs: 4: User
330
+ section 5. Validation
331
+ Review demand data: 4: User
332
+ Check input data: 4: User
333
+ Validate results: 5: User
334
+ ```
335
+
336
+ ---
337
+
338
+ ## 🔍 Module Dependency Graph
339
+
340
+ ```mermaid
341
+ graph LR
342
+ subgraph "UI Modules"
343
+ UI1[app.py]
344
+ UI2[config_page.py]
345
+ UI3[optimization_results.py]
346
+ UI4[demand_validation_viz.py]
347
+ end
348
+
349
+ subgraph "Model Modules"
350
+ M1[optimizer_real.py]
351
+ M2[demand_filtering.py]
352
+ end
353
+
354
+ subgraph "Config Modules"
355
+ C1[optimization_config.py]
356
+ C2[constants.py]
357
+ C3[paths.yaml]
358
+ end
359
+
360
+ subgraph "Preprocess Modules"
361
+ P1[extract.py]
362
+ P2[transform.py]
363
+ P3[hierarchy_parser.py]
364
+ P4[data_preprocess.py]
365
+ P5[excel_to_csv_converter.py]
366
+ end
367
+
368
+ subgraph "Visualization Modules"
369
+ V1[hierarchy_dashboard.py]
370
+ V2[kit_relationships.py]
371
+ end
372
+
373
+ UI1 --> UI2
374
+ UI1 --> UI3
375
+ UI1 --> UI4
376
+ UI2 --> C1
377
+ UI2 --> M1
378
+ UI3 --> C1
379
+ UI3 --> V1
380
+ UI3 --> V2
381
+ UI4 --> M2
382
+
383
+ M1 --> C1
384
+ M1 --> C2
385
+ M1 --> P1
386
+ M2 --> P1
387
+
388
+ C1 --> C2
389
+ C1 --> C3
390
+ C1 --> P1
391
+ C1 --> P3
392
+
393
+ P1 --> C3
394
+ P2 --> P1
395
+ P3 --> P1
396
+ P4 --> P1
397
+ P4 --> P2
398
+
399
+ V1 --> P3
400
+ V2 --> P3
401
+
402
+ classDef ui fill:#2196F3,stroke:#1565C0,color:#fff
403
+ classDef model fill:#FF9800,stroke:#E65100,color:#fff
404
+ classDef config fill:#9C27B0,stroke:#6A1B9A,color:#fff
405
+ classDef preprocess fill:#00BCD4,stroke:#006064,color:#fff
406
+ classDef viz fill:#E91E63,stroke:#880E4F,color:#fff
407
+
408
+ class UI1,UI2,UI3,UI4 ui
409
+ class M1,M2 model
410
+ class C1,C2,C3 config
411
+ class P1,P2,P3,P4,P5 preprocess
412
+ class V1,V2 viz
413
+ ```
414
+
415
+ ---
416
+
417
+ ## 📊 Kit Hierarchy System
418
+
419
+ ```mermaid
420
+ graph TD
421
+ subgraph "Kit Hierarchy Levels"
422
+ L0[Level 0: Prepack<br/>Base components<br/>No dependencies]
423
+ L1[Level 1: Subkit<br/>Intermediate assembly<br/>Depends on prepacks]
424
+ L2[Level 2: Master<br/>Final products<br/>Depends on subkits]
425
+ end
426
+
427
+ subgraph "Production Order"
428
+ P1[1st: Produce Prepacks]
429
+ P2[2nd: Assemble Subkits]
430
+ P3[3rd: Complete Masters]
431
+ end
432
+
433
+ subgraph "Dependency Rules"
434
+ D1[Dependencies must be<br/>produced before or<br/>at the same time]
435
+ D2[Topological sorting<br/>ensures correct order]
436
+ D3[Constraint in optimizer:<br/>dep_completion ≤ product_completion]
437
+ end
438
+
439
+ L0 --> P1
440
+ L1 --> P2
441
+ L2 --> P3
442
+ P1 --> P2
443
+ P2 --> P3
444
+
445
+ P1 --> D1
446
+ P2 --> D1
447
+ P3 --> D1
448
+ D1 --> D2
449
+ D2 --> D3
450
+
451
+ classDef level fill:#4CAF50,stroke:#2E7D32,color:#fff
452
+ classDef order fill:#2196F3,stroke:#1565C0,color:#fff
453
+ classDef rule fill:#FF9800,stroke:#E65100,color:#fff
454
+
455
+ class L0,L1,L2 level
456
+ class P1,P2,P3 order
457
+ class D1,D2,D3 rule
458
+ ```
459
+
460
+ ---
461
+
462
+ ## 🚀 Execution Flow
463
+
464
+ ```mermaid
465
+ sequenceDiagram
466
+ actor User
467
+ participant Main as main.py
468
+ participant App as Streamlit App
469
+ participant Config as Config Page
470
+ participant OptConfig as optimization_config.py
471
+ participant Extract as extract.py
472
+ participant Optimizer as optimizer_real.py
473
+ participant Results as Results Page
474
+
475
+ User->>Main: python main.py
476
+ Main->>App: Launch Streamlit
477
+ App->>Config: Show Settings Page
478
+
479
+ User->>Config: Configure parameters
480
+ Config->>OptConfig: Update settings
481
+
482
+ User->>Config: Click "Optimize"
483
+ Config->>Extract: Load CSV data
484
+ Extract-->>Config: Return data
485
+
486
+ Config->>OptConfig: Get all parameters
487
+ OptConfig-->>Config: Return config
488
+
489
+ Config->>Optimizer: run_optimization_for_week()
490
+
491
+ Optimizer->>OptConfig: Get products
492
+ Optimizer->>OptConfig: Get demand
493
+ Optimizer->>OptConfig: Get employees
494
+ Optimizer->>OptConfig: Get costs
495
+ Optimizer->>OptConfig: Get hierarchy
496
+
497
+ Optimizer->>Optimizer: Build OR-Tools model
498
+ Optimizer->>Optimizer: Add constraints
499
+ Optimizer->>Optimizer: Set objective
500
+ Optimizer->>Optimizer: Solve with CBC
501
+
502
+ Optimizer-->>Config: Return results
503
+ Config->>App: Store in session_state
504
+
505
+ User->>App: Navigate to Results
506
+ App->>Results: Display results
507
+ Results->>Results: Generate charts
508
+ Results-->>User: Show visualizations
509
+ ```
510
+
511
+ ---
512
+
513
+ ## 🔑 Key Technologies & Libraries
514
+
515
+ ```mermaid
516
+ mindmap
517
+ root((Tech Stack))
518
+ Python 3.10
519
+ Core Language
520
+ Streamlit
521
+ Web UI Framework
522
+ Interactive Dashboard
523
+ Session State Management
524
+ OR-Tools
525
+ Optimization Engine
526
+ CBC Solver
527
+ Linear Programming
528
+ Data Processing
529
+ Pandas
530
+ CSV/Excel handling
531
+ Data transformation
532
+ NumPy
533
+ Numerical operations
534
+ Visualization
535
+ Plotly
536
+ Interactive charts
537
+ Bar charts
538
+ Pie charts
539
+ Timeline charts
540
+ File Formats
541
+ CSV
542
+ Data storage
543
+ JSON
544
+ Hierarchy storage
545
+ YAML
546
+ Configuration
547
+ ```
548
+
549
+ ---
550
+
551
+ ## 📝 Configuration Files
552
+
553
+ ### paths.yaml
554
+ 데이터 파일 경로를 중앙집중식으로 관리:
555
+ - CSV 파일 경로
556
+ - Excel 파일 경로
557
+ - Hierarchy JSON 경로
558
+
559
+ ### optimization_config.py
560
+ 동적 최적화 파라미터 관리:
561
+ - 제품 리스트 (`get_product_list()`)
562
+ - 수요 데이터 (`get_demand_dictionary()`)
563
+ - 직��� 타입 (`get_employee_type_list()`)
564
+ - 비용 정보 (`get_cost_list_per_emp_shift()`)
565
+ - 계층 구조 (`KIT_LEVELS`, `KIT_DEPENDENCIES`)
566
+ - 라인 설정 (`get_line_list()`, `get_line_cnt_per_type()`)
567
+ - 시프트 설정 (`get_active_shift_list()`)
568
+
569
+ ### constants.py
570
+ 상수 및 Enum 정의:
571
+ - `ShiftType`: Regular(1), Evening(2), Overtime(3)
572
+ - `LineType`: Long Line(6), Short Line(7)
573
+ - `KitLevel`: Prepack(0), Subkit(1), Master(2)
574
+
575
+ ---
576
+
577
+ ## 💡 Key Features
578
+
579
+ ### 1. Dynamic Configuration
580
+ - 모든 파라미터가 UI에서 동적으로 설정 가능
581
+ - Session state로 상태 관리
582
+ - 실시간 데이터 로딩
583
+
584
+ ### 2. Hierarchy-Based Optimization
585
+ - 3단계 계층 구조 (Prepack → Subkit → Master)
586
+ - 의존성 제약 조건 자동 적용
587
+ - Topological sorting으로 생산 순서 결정
588
+
589
+ ### 3. Multi-Shift Scheduling
590
+ - Regular, Evening, Overtime 시프트 지원
591
+ - 시프트별 다른 비용 설정
592
+ - Bulk/Partial 급여 지급 방식 선택
593
+
594
+ ### 4. Comprehensive Visualization
595
+ - 주간 생산 요약
596
+ - 일별 직원 배치
597
+ - 라인별 스케줄
598
+ - 비용 분석
599
+ - 계층 구조 시각화
600
+
601
+ ### 5. Data Validation
602
+ - 수요 데이터 검증
603
+ - 입력 데이터 검증
604
+ - 실행 가능성 체크
605
+
606
+ ---
607
+
608
+ ## 🎯 Optimization Objective
609
+
610
+ **목표**: 총 인건비(Total Labor Cost) 최소화
611
+
612
+ ```
613
+ Minimize: Σ (employee_type, shift, day) [
614
+ hourly_rate × hours_worked × employees_count
615
+ ]
616
+ ```
617
+
618
+ **제약 조건**:
619
+ 1. **수요 충족**: 각 제품의 주간 수요를 정확히 생산
620
+ 2. **용량 제한**: 라인별, 시프트별 작업 시간 제한
621
+ 3. **계층 제약**: 의존성 제품을 먼저 생산
622
+ 4. **인력 제약**: 직원 타입별 일일 가용 인원 제한
623
+ 5. **라인 호환**: 제품-라인 타입 매칭
624
+ 6. **시프트 순서**: Overtime은 Regular 90% 사용 시에만
625
+ 7. **최소 인원**: UNICEF 직원 최소 인원 보장
626
+
627
+ ---
628
+
629
+ ## 📈 Performance Considerations
630
+
631
+ ### OR-Tools CBC Solver
632
+ - **장점**: 무료 오픈소스, 상업용 가능, 합리적인 성능
633
+ - **단점**: 대규모 문제에서 느릴 수 있음
634
+ - **최적화**:
635
+ - 변수 개수 최소화
636
+ - 제약 조건 효율화
637
+ - 사전 필터링으로 불필요한 조합 제거
638
+
639
+ ### Data Loading
640
+ - **CSV 캐싱**: Streamlit `@st.cache_data` 사용
641
+ - **Session State**: 최적화 결과 저장
642
+ - **Lazy Loading**: 필요한 데이터만 로딩
643
+
644
+ ---
645
+
646
+ ## 🔧 Future Enhancement Opportunities
647
+
648
+ 1. **Database Integration**: CSV → PostgreSQL/MySQL
649
+ 2. **Advanced Solver**: CBC → Gurobi/CPLEX for faster solving
650
+ 3. **Real-time Updates**: WebSocket for live optimization status
651
+ 4. **Machine Learning**: 수요 예측, 생산 시간 예측
652
+ 5. **Multi-objective**: 비용 외에 완료 시간, 자원 활용도 고려
653
+ 6. **Parallel Processing**: 다중 시나리오 동시 실행
654
+ 7. **Export Features**: PDF 리포트, Excel 결과 내보내기
655
+
656
+ ---
657
+
658
+ ## 📚 Documentation Structure
659
+
660
+ ```
661
+ SD_roster_real/
662
+ ├── README.md # 프로젝트 개요 및 빠른 시작
663
+ ├── ARCHITECTURE_DIAGRAM.md # 이 파일 - 아키텍처 다이어그램
664
+ ├── requirements.txt # Python 의존성
665
+ ├── setup.py # 패키지 설정
666
+
667
+ ├── main.py # 메인 진입점
668
+
669
+ ├── ui/ # Streamlit UI
670
+ │ ├── app.py # 메인 앱
671
+ │ └── pages/ # 페이지 컴포넌트
672
+
673
+ ├── src/ # 핵심 비즈니스 로직
674
+ │ ├── config/ # 설정 관리
675
+ │ ├── models/ # 최적화 모델
676
+ │ ├── preprocess/ # 데이터 전처리
677
+ │ └── visualization/ # 차트 생성
678
+
679
+ ├── data/ # 데이터 파일
680
+ │ ├── real_data_excel/ # 원본 Excel
681
+ │ │ └── converted_csv/ # 변환된 CSV
682
+ │ └── hierarchy_exports/ # 계층 구조 JSON
683
+
684
+ └── notebook/ # Jupyter 노트북 (분석용)
685
+ ```
686
+
687
+ ---
688
+
689
+ ## 🎓 Learning Path
690
+
691
+ 이 프로젝트를 이해하는 권장 순서:
692
+
693
+ 1. **Start**: `README.md` - 프로젝트 개요
694
+ 2. **Run**: `main.py` → `ui/app.py` - 앱 실행
695
+ 3. **UI**: `ui/pages/config_page.py` - UI 구조 이해
696
+ 4. **Config**: `src/config/optimization_config.py` - 설정 시스템
697
+ 5. **Data**: `src/preprocess/extract.py` - 데이터 로딩
698
+ 6. **Core**: `src/models/optimizer_real.py` - 최적화 로직
699
+ 7. **Results**: `ui/pages/optimization_results.py` - 결과 시각화
700
+ 8. **Architecture**: 이 파일 - 전체 그림
701
+
702
+ ---
703
+
704
+ ## 📞 Component Interaction Summary
705
+
706
+ | Layer | Components | Purpose | Key Technologies |
707
+ |-------|-----------|---------|-----------------|
708
+ | **Entry** | main.py, app.py | Application launch | Python, Streamlit |
709
+ | **UI** | config_page, optimization_results, demand_validation_viz | User interface | Streamlit, Plotly |
710
+ | **Core** | optimizer_real, demand_filtering | Business logic | OR-Tools, NumPy |
711
+ | **Config** | optimization_config, constants, paths | Configuration | Python, YAML |
712
+ | **Preprocess** | extract, transform, hierarchy_parser | Data preparation | Pandas, JSON |
713
+ | **Data** | CSV files, JSON files | Data storage | CSV, JSON |
714
+ | **Viz** | Plotly charts, hierarchy_dashboard | Visualization | Plotly, Matplotlib |
715
+
716
+ ---
717
+
718
+ ## ✅ Conclusion
719
+
720
+ 이 Supply Roster Optimization Tool은:
721
+
722
+ - **모듈화된 구조**: 각 레이어가 명확히 분리됨
723
+ - **동적 설정**: UI에서 모든 파라미터 조정 가능
724
+ - **강력한 최적화**: OR-Tools로 복잡한 제약 조건 처리
725
+ - **직관적인 시각화**: Plotly로 결과를 명확히 표시
726
+ - **확장 가능**: 새로운 기능 추가가 용이한 구조
727
+
728
+ 전체 시스템은 **데이터 수집 → 전처리 → 설정 → 최적화 → 결과 표시**의 파이프라인으로 동작합니다.
729
+