File size: 26,625 Bytes
b378e61
 
 
 
 
e86e389
 
b378e61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e86e389
 
 
 
 
 
 
 
 
 
 
b378e61
 
 
 
 
 
e86e389
b378e61
e86e389
b378e61
 
 
 
e86e389
b378e61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e86e389
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b378e61
 
 
 
 
 
 
 
 
 
 
 
 
e86e389
b378e61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e86e389
 
 
 
 
 
b378e61
 
e86e389
b378e61
e86e389
b378e61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e86e389
 
 
 
 
b378e61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e86e389
 
 
b378e61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e86e389
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b378e61
 
 
 
 
 
 
 
e86e389
 
 
 
 
 
b378e61
 
 
e86e389
b378e61
 
 
 
 
 
 
 
e86e389
b378e61
 
 
 
 
 
 
 
 
 
 
 
e86e389
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b378e61
e86e389
b378e61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e86e389
 
 
 
 
 
 
 
 
 
 
 
 
b378e61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e86e389
 
 
b378e61
 
 
 
 
e86e389
 
 
b378e61
 
e86e389
b378e61
e86e389
 
b378e61
 
e86e389
b378e61
 
 
 
e86e389
b378e61
 
e86e389
b378e61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e86e389
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b378e61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e86e389
 
 
b378e61
 
 
 
 
 
 
 
e86e389
 
 
 
 
b378e61
e86e389
b378e61
 
 
 
 
e86e389
b378e61
e86e389
b378e61
 
e86e389
 
 
 
 
 
b378e61
 
 
 
 
e86e389
 
 
 
 
b378e61
 
 
e86e389
b378e61
e86e389
 
 
 
 
 
 
 
 
b378e61
 
 
 
 
e86e389
 
 
 
 
b378e61
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
import gradio as gr
import pandas as pd
import numpy as np
from datetime import datetime
import plotly.graph_objects as go
import re
from urllib.parse import urlparse

class StartupValuationCalculator:
    def __init__(self):
        # 업쒅별 벀치마크 λ©€ν‹°ν”Œ (EV/ARR)
        self.industry_multiples = {
            "SaaS - B2B": {"low": 3, "mid": 6, "high": 10},
            "SaaS - B2C": {"low": 2, "mid": 4, "high": 7},
            "λ§ˆμΌ“ν”Œλ ˆμ΄μŠ€": {"low": 2, "mid": 5, "high": 8},
            "이컀머슀": {"low": 1, "mid": 2.5, "high": 4},
            "ν•€ν…Œν¬": {"low": 3, "mid": 5, "high": 8},
            "ν—¬μŠ€μΌ€μ–΄": {"low": 4, "mid": 7, "high": 12},
            "AI/λ”₯ν…Œν¬": {"low": 5, "mid": 8, "high": 15},
            "기타": {"low": 2, "mid": 4, "high": 6}
        }
        
        # μ„±μž₯λ₯  μ‘°μ • κ³„μˆ˜
        self.growth_adjustments = {
            "0-20%": 0.7,
            "20-50%": 0.9,
            "50-100%": 1.1,
            "100-200%": 1.3,
            "200%+": 1.5
        }
        
        # λ‹¨μœ„κ²½μ œ 점수 κ°€μ€‘μΉ˜
        self.unit_economics_weights = {
            "ltv_cac_ratio": 0.3,
            "gross_margin": 0.3,
            "retention": 0.2,
            "payback": 0.2
        }
        
        # IP μžμ‚° κ°€μΉ˜ κ°€μ€‘μΉ˜
        self.ip_asset_weights = {
            "patents": 0.25,
            "papers": 0.15,
            "domains": 0.15,
            "trademarks": 0.10,
            "github": 0.10,
            "awards": 0.10,
            "team": 0.15
        }
    
    def calculate_arr(self, monthly_revenue, revenue_type):
        """μ›” λ§€μΆœμ„ μ—°κ°„ 반볡 맀좜(ARR)둜 λ³€ν™˜"""
        if revenue_type == "κ΅¬λ…ν˜• (SaaS)":
            return monthly_revenue * 12
        elif revenue_type == "κ±°λž˜μˆ˜μˆ˜λ£Œν˜•":
            return monthly_revenue * 12 * 0.8
        else:
            return monthly_revenue * 12 * 0.6
    
    def calculate_ltv(self, arpu, gross_margin, monthly_churn):
        """LTV 계산"""
        if monthly_churn == 0:
            monthly_churn = 0.01
        return arpu * (gross_margin / 100) / monthly_churn
    
    def calculate_cac(self, monthly_marketing, monthly_sales, new_customers):
        """CAC 계산"""
        if new_customers == 0:
            return 0
        return (monthly_marketing + monthly_sales) / new_customers
    
    def calculate_payback(self, cac, arpu, gross_margin):
        """Payback Period 계산 (κ°œμ›”)"""
        if arpu * (gross_margin / 100) == 0:
            return 999
        return cac / (arpu * (gross_margin / 100))
    
    def get_unit_economics_score(self, ltv_cac_ratio, gross_margin, retention_rate, payback_months):
        """λ‹¨μœ„κ²½μ œ 점수 계산 (0-100)"""
        scores = {
            "ltv_cac_ratio": min(100, (ltv_cac_ratio / 3) * 100) if ltv_cac_ratio > 0 else 0,
            "gross_margin": min(100, gross_margin * 1.25),
            "retention": retention_rate,
            "payback": max(0, 100 - (payback_months / 24) * 100) if payback_months < 999 else 0
        }
        
        total_score = sum(scores[key] * self.unit_economics_weights[key] for key in scores)
        return total_score
    
    def evaluate_domain(self, domains):
        """도메인 κ°€μΉ˜ 평가"""
        if not domains:
            return 0
        
        domain_list = [d.strip() for d in domains.split(',') if d.strip()]
        score = 0
        
        for domain in domain_list:
            parsed = urlparse(domain if domain.startswith('http') else f'http://{domain}')
            domain_name = parsed.netloc or parsed.path
            
            # .com 도메인 가산점
            if domain_name.endswith('.com'):
                score += 30
            elif domain_name.endswith(('.io', '.ai', '.tech')):
                score += 20
            else:
                score += 10
            
            # 짧은 도메인 가산점
            name_length = len(domain_name.split('.')[0])
            if name_length <= 5:
                score += 20
            elif name_length <= 8:
                score += 10
        
        return min(100, score / len(domain_list))
    
    def evaluate_patents(self, patent_filed, patent_granted):
        """νŠΉν—ˆ κ°€μΉ˜ 평가"""
        score = 0
        score += patent_filed * 15  # μΆœμ› νŠΉν—ˆλ‹Ή 15점
        score += patent_granted * 30  # 등둝 νŠΉν—ˆλ‹Ή 30점
        return min(100, score)
    
    def evaluate_papers(self, papers):
        """λ…Όλ¬Έ κ°€μΉ˜ 평가"""
        if not papers:
            return 0
        
        paper_count = len([p.strip() for p in papers.split('\n') if p.strip()])
        score = paper_count * 20  # λ…Όλ¬Έλ‹Ή 20점
        
        # μ£Όμš” ν•™νšŒ/저널 ν‚€μ›Œλ“œ 체크
        prestigious_keywords = ['Nature', 'Science', 'IEEE', 'ACM', 'CVPR', 'NeurIPS', 'ICML']
        for keyword in prestigious_keywords:
            if keyword.lower() in papers.lower():
                score += 10
        
        return min(100, score)
    
    def evaluate_github(self, github_url, github_stars):
        """GitHub μ €μž₯μ†Œ 평가"""
        if not github_url:
            return 0
        
        score = 0
        if github_stars >= 1000:
            score = 80
        elif github_stars >= 500:
            score = 60
        elif github_stars >= 100:
            score = 40
        elif github_stars >= 50:
            score = 20
        else:
            score = 10
        
        return score
    
    def evaluate_team(self, team_size, phd_count, serial_entrepreneurs, big_tech_experience):
        """νŒ€ μ—­λŸ‰ 평가"""
        score = 0
        
        # νŒ€ 규λͺ¨
        if team_size >= 20:
            score += 20
        elif team_size >= 10:
            score += 15
        elif team_size >= 5:
            score += 10
        
        # 박사 ν•™μœ„
        score += min(30, phd_count * 10)
        
        # 연쇄창업가
        score += min(30, serial_entrepreneurs * 15)
        
        # λΉ…ν…Œν¬ κ²½ν—˜
        score += min(20, big_tech_experience * 5)
        
        return min(100, score)
    
    def calculate_ip_score(self, ip_data):
        """μ§€μ μž¬μ‚° μ’…ν•© 점수 계산"""
        scores = {
            "patents": self.evaluate_patents(ip_data["patent_filed"], ip_data["patent_granted"]),
            "papers": self.evaluate_papers(ip_data["papers"]),
            "domains": self.evaluate_domain(ip_data["domains"]),
            "trademarks": min(100, ip_data["trademarks"] * 20),
            "github": self.evaluate_github(ip_data["github_url"], ip_data["github_stars"]),
            "awards": min(100, ip_data["awards"] * 25),
            "team": self.evaluate_team(
                ip_data["team_size"], ip_data["phd_count"],
                ip_data["serial_entrepreneurs"], ip_data["big_tech_experience"]
            )
        }
        
        total_score = sum(scores[key] * self.ip_asset_weights[key] for key in scores)
        return total_score, scores
    
    def get_growth_category(self, growth_rate):
        """μ„±μž₯λ₯  μΉ΄ν…Œκ³ λ¦¬ κ²°μ •"""
        if growth_rate < 20:
            return "0-20%"
        elif growth_rate < 50:
            return "20-50%"
        elif growth_rate < 100:
            return "50-100%"
        elif growth_rate < 200:
            return "100-200%"
        else:
            return "200%+"
    
    def calculate_valuation(self, data, ip_data):
        """μ’…ν•© κ°€μΉ˜ν‰κ°€ 계산"""
        # ARR 계산
        arr = self.calculate_arr(data["monthly_revenue"], data["revenue_type"])
        
        # λ‹¨μœ„κ²½μ œ 계산
        ltv = self.calculate_ltv(data["arpu"], data["gross_margin"], data["monthly_churn"])
        cac = self.calculate_cac(data["monthly_marketing"], data["monthly_sales"], data["new_customers"])
        ltv_cac_ratio = ltv / cac if cac > 0 else 0
        payback = self.calculate_payback(cac, data["arpu"], data["gross_margin"])
        
        # λ‹¨μœ„κ²½μ œ 점수
        ue_score = self.get_unit_economics_score(
            ltv_cac_ratio, data["gross_margin"], data["retention_rate"], payback
        )
        
        # IP μžμ‚° 점수
        ip_score, ip_breakdown = self.calculate_ip_score(ip_data)
        
        # μ’…ν•© 점수 (λ‹¨μœ„κ²½μ œ 60%, IP 40%)
        combined_score = ue_score * 0.6 + ip_score * 0.4
        
        # κΈ°λ³Έ λ©€ν‹°ν”Œ 선택
        multiples = self.industry_multiples[data["industry"]]
        if combined_score >= 80:
            base_multiple = multiples["high"]
        elif combined_score >= 50:
            base_multiple = multiples["mid"]
        else:
            base_multiple = multiples["low"]
        
        # μ„±μž₯λ₯  μ‘°μ •
        growth_adj = self.growth_adjustments[self.get_growth_category(data["growth_rate"])]
        adjusted_multiple = base_multiple * growth_adj
        
        # μŠ€ν…Œμ΄μ§€ μ‘°μ •
        stage_adj = {
            "MVP/베타": 0.7,
            "초기 맀좜": 0.85,
            "μ„±μž₯ 단계": 1.0,
            "μˆ˜μ΅μ„± 확보": 1.2
        }
        
        # IP μžμ‚° 프리미엄 (μ΅œλŒ€ 20%)
        ip_premium = 1 + (ip_score / 100 * 0.2)
        
        final_multiple = adjusted_multiple * stage_adj[data["stage"]] * ip_premium
        
        # μ΅œμ’… κ°€μΉ˜ν‰κ°€
        valuation = arr * final_multiple
        
        # λŸ°μ›¨μ΄ 계산
        runway = data["cash_balance"] / data["burn_rate"] if data["burn_rate"] > 0 else 999
        
        return {
            "valuation": valuation,
            "arr": arr,
            "multiple": final_multiple,
            "ltv": ltv,
            "cac": cac,
            "ltv_cac_ratio": ltv_cac_ratio,
            "payback": payback,
            "ue_score": ue_score,
            "ip_score": ip_score,
            "ip_breakdown": ip_breakdown,
            "combined_score": combined_score,
            "runway": runway
        }
    
    def create_comparison_chart(self, valuation, industry, arr):
        """동쒅업계 비ꡐ 차트 생성"""
        multiples = self.industry_multiples[industry]
        
        fig = go.Figure()
        
        # 업계 λ²”μœ„
        low_val = arr * multiples["low"]
        mid_val = arr * multiples["mid"]
        high_val = arr * multiples["high"]
        
        # λ§‰λŒ€ κ·Έλž˜ν”„
        fig.add_trace(go.Bar(
            x=["ν•˜μœ„ 25%", "쀑간값", "μƒμœ„ 25%", "ν˜„μž¬ κΈ°μ—…"],
            y=[low_val, mid_val, high_val, valuation],
            text=[f"${low_val/1000000:.1f}M", f"${mid_val/1000000:.1f}M", 
                  f"${high_val/1000000:.1f}M", f"${valuation/1000000:.1f}M"],
            textposition="outside",
            marker_color=["lightgray", "gray", "darkgray", "blue"]
        ))
        
        fig.update_layout(
            title=f"{industry} 업계 κ°€μΉ˜ν‰κ°€ 비ꡐ",
            yaxis_title="κΈ°μ—…κ°€μΉ˜ (USD)",
            showlegend=False,
            height=400
        )
        
        return fig
    
    def create_ip_breakdown_chart(self, ip_breakdown):
        """IP μžμ‚° 뢄석 차트"""
        categories = list(ip_breakdown.keys())
        values = list(ip_breakdown.values())
        
        fig = go.Figure(data=[
            go.Radar(
                r=values,
                theta=categories,
                fill='toself',
                name='IP μžμ‚° 점수'
            )
        ])
        
        fig.update_layout(
            polar=dict(
                radialaxis=dict(
                    visible=True,
                    range=[0, 100]
                )
            ),
            showlegend=False,
            title="μ§€μ μž¬μ‚° μžμ‚° 뢄석"
        )
        
        return fig

def create_ui():
    calculator = StartupValuationCalculator()
    
    def process_valuation(
        company_name, founded_year, industry, stage, revenue_type,
        monthly_revenue, growth_rate, arpu, gross_margin, monthly_churn,
        retention_rate, new_customers, monthly_marketing, monthly_sales,
        cash_balance, burn_rate,
        # IP κ΄€λ ¨ μž…λ ₯
        domains, patent_filed, patent_granted, papers, trademarks,
        github_url, github_stars, awards, partnerships,
        team_size, phd_count, serial_entrepreneurs, big_tech_experience,
        media_coverage, app_downloads, social_followers
    ):
        # μž…λ ₯κ°’ 검증
        if monthly_revenue <= 0:
            return "μ›” λ§€μΆœμ„ μž…λ ₯ν•΄μ£Όμ„Έμš”.", None, None, None
        
        # 데이터 μ€€λΉ„
        data = {
            "company_name": company_name,
            "founded_year": founded_year,
            "industry": industry,
            "stage": stage,
            "revenue_type": revenue_type,
            "monthly_revenue": monthly_revenue * 1000,
            "growth_rate": growth_rate,
            "arpu": arpu,
            "gross_margin": gross_margin,
            "monthly_churn": monthly_churn / 100,
            "retention_rate": retention_rate,
            "new_customers": new_customers,
            "monthly_marketing": monthly_marketing * 1000,
            "monthly_sales": monthly_sales * 1000,
            "cash_balance": cash_balance * 1000,
            "burn_rate": burn_rate * 1000
        }
        
        ip_data = {
            "domains": domains,
            "patent_filed": patent_filed,
            "patent_granted": patent_granted,
            "papers": papers,
            "trademarks": trademarks,
            "github_url": github_url,
            "github_stars": github_stars,
            "awards": awards,
            "partnerships": partnerships,
            "team_size": team_size,
            "phd_count": phd_count,
            "serial_entrepreneurs": serial_entrepreneurs,
            "big_tech_experience": big_tech_experience,
            "media_coverage": media_coverage,
            "app_downloads": app_downloads,
            "social_followers": social_followers
        }
        
        # κ°€μΉ˜ν‰κ°€ 계산
        results = calculator.calculate_valuation(data, ip_data)
        
        # κ²°κ³Ό ν¬λ§·νŒ…
        valuation_text = f"""
# πŸš€ {company_name} κ°€μΉ˜ν‰κ°€ κ²°κ³Ό

## πŸ“Š μ£Όμš” μ§€ν‘œ
- **κΈ°μ—…κ°€μΉ˜**: ${results['valuation']/1000000:.1f}M (β‚©{results['valuation']/1000000*1300:.0f}μ–΅)
- **ARR**: ${results['arr']/1000000:.1f}M
- **적용 λ©€ν‹°ν”Œ**: {results['multiple']:.1f}x

## πŸ’° λ‹¨μœ„κ²½μ œ
- **LTV**: ${results['ltv']:.0f}
- **CAC**: ${results['cac']:.0f}
- **LTV/CAC**: {results['ltv_cac_ratio']:.1f}x
- **Payback Period**: {results['payback']:.1f}κ°œμ›”
- **λ‹¨μœ„κ²½μ œ 점수**: {results['ue_score']:.0f}/100

## 🎯 μ§€μ μž¬μ‚° 및 λ¬΄ν˜•μžμ‚°
- **IP μžμ‚° 점수**: {results['ip_score']:.0f}/100
- **μ’…ν•© 점수**: {results['combined_score']:.0f}/100

### IP μžμ‚° μ„ΈλΆ€ 평가:
- νŠΉν—ˆ: {results['ip_breakdown']['patents']:.0f}/100
- λ…Όλ¬Έ: {results['ip_breakdown']['papers']:.0f}/100
- 도메인: {results['ip_breakdown']['domains']:.0f}/100
- μƒν‘œκΆŒ: {results['ip_breakdown']['trademarks']:.0f}/100
- μ˜€ν”ˆμ†ŒμŠ€: {results['ip_breakdown']['github']:.0f}/100
- μˆ˜μƒμ‹€μ : {results['ip_breakdown']['awards']:.0f}/100
- νŒ€ μ—­λŸ‰: {results['ip_breakdown']['team']:.0f}/100

## πŸƒ 재무 건전성
- **ν˜„κΈˆ λŸ°μ›¨μ΄**: {results['runway']:.1f}κ°œμ›”
- **μ›”κ°„ 번레이트**: ${burn_rate}K

## πŸ’‘ 평가 μΈμ‚¬μ΄νŠΈ
"""
        # μΈμ‚¬μ΄νŠΈ μΆ”κ°€
        if results['ltv_cac_ratio'] < 1:
            valuation_text += "- ⚠️ LTV/CAC λΉ„μœ¨μ΄ 1 λ―Έλ§Œμž…λ‹ˆλ‹€. λ§ˆμΌ€νŒ… νš¨μœ¨μ„± κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.\n"
        elif results['ltv_cac_ratio'] > 3:
            valuation_text += "- βœ… μš°μˆ˜ν•œ LTV/CAC λΉ„μœ¨μ„ 보이고 μžˆμŠ΅λ‹ˆλ‹€.\n"
        
        if results['runway'] < 12:
            valuation_text += "- ⚠️ λŸ°μ›¨μ΄κ°€ 12κ°œμ›” λ―Έλ§Œμž…λ‹ˆλ‹€. μΆ”κ°€ μžκΈˆμ‘°λ‹¬μ„ κ³ λ €ν•˜μ„Έμš”.\n"
        
        if gross_margin < 60:
            valuation_text += "- πŸ“ˆ 맀좜총이읡λ₯  κ°œμ„  μ—¬μ§€κ°€ μžˆμŠ΅λ‹ˆλ‹€. (업계 평균: 70-80%)\n"
        
        if results['ip_score'] > 70:
            valuation_text += "- πŸ† κ°•λ ₯ν•œ IP 포트폴리였λ₯Ό λ³΄μœ ν•˜κ³  μžˆμ–΄ κ°€μΉ˜ν‰κ°€μ— 프리미엄이 μ μš©λ˜μ—ˆμŠ΅λ‹ˆλ‹€.\n"
        
        # 비ꡐ 차트 생성
        comparison_chart = calculator.create_comparison_chart(
            results['valuation'], industry, results['arr']
        )
        
        # IP 뢄석 차트
        ip_chart = calculator.create_ip_breakdown_chart(results['ip_breakdown'])
        
        # 상세 뢄석 ν…Œμ΄λΈ”
        metrics_df = pd.DataFrame({
            "μ§€ν‘œ": ["μ›” 맀좜", "μ—° μ„±μž₯λ₯ ", "맀좜총이읡λ₯ ", "μ›” μ΄νƒˆλ₯ ", "고객 μœ μ§€μœ¨", "IP μžμ‚° 점수"],
            "ν˜„μž¬ κ°’": [f"${monthly_revenue}K", f"{growth_rate}%", f"{gross_margin}%", 
                      f"{monthly_churn}%", f"{retention_rate}%", f"{results['ip_score']:.0f}/100"],
            "업계 평균": ["N/A", "50-100%", "70-80%", "2-5%", "80-90%", "50/100"]
        })
        
        return valuation_text, comparison_chart, ip_chart, metrics_df
    
    # Gradio UI
    with gr.Blocks(title="μŠ€νƒ€νŠΈμ—… κ°€μΉ˜ν‰κ°€ 계산기", theme=gr.themes.Soft()) as demo:
        gr.Markdown("""
        # πŸ¦„ μŠ€νƒ€νŠΈμ—… κ°€μΉ˜ν‰κ°€ μžλ™ν™” μ‹œμŠ€ν…œ v2.0
        
        κ°„λ‹¨ν•œ 정보 μž…λ ₯만으둜 κ·€μ‚¬μ˜ μ˜ˆμƒ κΈ°μ—…κ°€μΉ˜λ₯Ό μ‚°μΆœν•˜κ³  동쒅업계와 λΉ„κ΅ν•΄λ“œλ¦½λ‹ˆλ‹€.
        이제 μ§€μ μž¬μ‚°κ³Ό λ¬΄ν˜•μžμ‚°κΉŒμ§€ μ’…ν•©μ μœΌλ‘œ ν‰κ°€ν•©λ‹ˆλ‹€.
        """)
        
        with gr.Tab("κΈ°λ³Έ 정보"):
            with gr.Row():
                company_name = gr.Textbox(label="νšŒμ‚¬λͺ…", value="우리 μŠ€νƒ€νŠΈμ—…")
                founded_year = gr.Slider(2015, 2024, value=2022, step=1, label="섀립연도")
            
            with gr.Row():
                industry = gr.Dropdown(
                    choices=list(calculator.industry_multiples.keys()),
                    value="SaaS - B2B",
                    label="μ‚°μ—… λΆ„λ₯˜"
                )
                stage = gr.Radio(
                    choices=["MVP/베타", "초기 맀좜", "μ„±μž₯ 단계", "μˆ˜μ΅μ„± 확보"],
                    value="초기 맀좜",
                    label="사업 단계"
                )
            
            revenue_type = gr.Radio(
                choices=["κ΅¬λ…ν˜• (SaaS)", "κ±°λž˜μˆ˜μˆ˜λ£Œν˜•", "μΌνšŒμ„± 판맀"],
                value="κ΅¬λ…ν˜• (SaaS)",
                label="수읡 λͺ¨λΈ"
            )
        
        with gr.Tab("맀좜 및 μ„±μž₯"):
            gr.Markdown("### πŸ’° 맀좜 정보 (λ‹¨μœ„: 천 λ‹¬λŸ¬)")
            with gr.Row():
                monthly_revenue = gr.Number(label="μ›” 맀좜 ($K)", value=50)
                growth_rate = gr.Slider(0, 300, value=100, step=10, 
                                       label="μ—°κ°„ μ„±μž₯λ₯  (%)")
            
            with gr.Row():
                arpu = gr.Number(label="고객당 평균 맀좜 (ARPU) ($)", value=100)
                gross_margin = gr.Slider(0, 100, value=70, step=5,
                                        label="맀좜총이읡λ₯  (%)")
        
        with gr.Tab("고객 및 λ§ˆμΌ€νŒ…"):
            gr.Markdown("### πŸ‘₯ 고객 μ§€ν‘œ")
            with gr.Row():
                retention_rate = gr.Slider(0, 100, value=85, step=5,
                                          label="μ›”κ°„ 고객 μœ μ§€μœ¨ (%)")
                monthly_churn = gr.Slider(0, 20, value=3, step=0.5,
                                         label="μ›” μ΄νƒˆλ₯  (%)")
            
            gr.Markdown("### πŸ“’ λ§ˆμΌ€νŒ… νš¨μœ¨μ„±")
            with gr.Row():
                new_customers = gr.Number(label="μ›” μ‹ κ·œ 고객 수", value=50)
                monthly_marketing = gr.Number(label="μ›” λ§ˆμΌ€νŒ… λΉ„μš© ($K)", value=20)
                monthly_sales = gr.Number(label="μ›” μ˜μ—… λΉ„μš© ($K)", value=15)
        
        with gr.Tab("μ§€μ μž¬μ‚° 및 기술"):
            gr.Markdown("### πŸ“š νŠΉν—ˆ 및 λ…Όλ¬Έ")
            with gr.Row():
                patent_filed = gr.Number(label="μΆœμ› νŠΉν—ˆ 수", value=2)
                patent_granted = gr.Number(label="등둝 νŠΉν—ˆ 수", value=1)
                trademarks = gr.Number(label="μƒν‘œκΆŒ 수", value=1)
            
            papers = gr.Textbox(
                label="λ°œν‘œ λ…Όλ¬Έ (ν•œ 쀄에 ν•˜λ‚˜μ”©, URL 포함 κ°€λŠ₯)",
                lines=3,
                placeholder="예: https://arxiv.org/abs/2301.12345 - AI Model Optimization\nICML 2023 - Novel Approach to Machine Learning"
            )
            
            gr.Markdown("### 🌐 λ””μ§€ν„Έ μžμ‚°")
            domains = gr.Textbox(
                label="보유 도메인 (μ‰Όν‘œλ‘œ ꡬ뢄)",
                placeholder="예: mycompany.com, mycompany.ai, myproduct.io"
            )
            
            with gr.Row():
                github_url = gr.Textbox(
                    label="GitHub μ €μž₯μ†Œ URL",
                    placeholder="https://github.com/yourcompany/yourrepo"
                )
                github_stars = gr.Number(label="GitHub μŠ€νƒ€ 수", value=100)
            
            gr.Markdown("### πŸ† 인증 및 μˆ˜μƒ")
            with gr.Row():
                awards = gr.Number(label="μ£Όμš” μˆ˜μƒ 싀적 수", value=1)
                partnerships = gr.Number(label="μ „λž΅μ  νŒŒνŠΈλ„ˆμ‹­ 수", value=2)
        
        with gr.Tab("νŒ€ 및 λΈŒλžœλ“œ"):
            gr.Markdown("### πŸ‘₯ νŒ€ ꡬ성")
            with gr.Row():
                team_size = gr.Number(label="전체 νŒ€ 규λͺ¨", value=10)
                phd_count = gr.Number(label="박사 ν•™μœ„ 보유자 수", value=1)
            
            with gr.Row():
                serial_entrepreneurs = gr.Number(label="연쇄창업가 수", value=1)
                big_tech_experience = gr.Number(label="λΉ…ν…Œν¬ μΆœμ‹  인원", value=2)
            
            gr.Markdown("### πŸ“± λΈŒλžœλ“œ 및 μ‚¬μš©μž 기반")
            with gr.Row():
                media_coverage = gr.Number(label="μ£Όμš” μ–Έλ‘  보도 수", value=5)
                app_downloads = gr.Number(label="μ•± λ‹€μš΄λ‘œλ“œ 수 (만)", value=10)
                social_followers = gr.Number(label="μ†Œμ…œλ―Έλ””μ–΄ νŒ”λ‘œμ›Œ (천)", value=50)
        
        with gr.Tab("재무 ν˜„ν™©"):
            gr.Markdown("### πŸ’Έ ν˜„κΈˆ 상황 (λ‹¨μœ„: 천 λ‹¬λŸ¬)")
            with gr.Row():
                cash_balance = gr.Number(label="ν˜„κΈˆ μž”κ³  ($K)", value=1000)
                burn_rate = gr.Number(label="μ›” 번레이트 ($K)", value=80)
        
        # 평가 μ‹€ν–‰ λ²„νŠΌ
        evaluate_btn = gr.Button("πŸ” κ°€μΉ˜ν‰κ°€ μ‹€ν–‰", variant="primary", size="lg")
        
        # κ²°κ³Ό 좜λ ₯
        with gr.Row():
            with gr.Column(scale=2):
                valuation_output = gr.Markdown(label="평가 κ²°κ³Ό")
            with gr.Column(scale=1):
                metrics_table = gr.DataFrame(label="μ£Όμš” μ§€ν‘œ 비ꡐ")
        
        with gr.Row():
            comparison_chart = gr.Plot(label="동쒅업계 비ꡐ")
            ip_chart = gr.Plot(label="IP μžμ‚° 뢄석")
        
        # 이벀트 μ—°κ²°
        evaluate_btn.click(
            process_valuation,
            inputs=[
                company_name, founded_year, industry, stage, revenue_type,
                monthly_revenue, growth_rate, arpu, gross_margin, monthly_churn,
                retention_rate, new_customers, monthly_marketing, monthly_sales,
                cash_balance, burn_rate,
                domains, patent_filed, patent_granted, papers, trademarks,
                github_url, github_stars, awards, partnerships,
                team_size, phd_count, serial_entrepreneurs, big_tech_experience,
                media_coverage, app_downloads, social_followers
            ],
            outputs=[valuation_output, comparison_chart, ip_chart, metrics_table]
        )
        
        # μ˜ˆμ‹œ 데이터 λ²„νŠΌλ“€
        gr.Markdown("### πŸ“ μ˜ˆμ‹œ λ°μ΄ν„°λ‘œ ν…ŒμŠ€νŠΈν•˜κΈ°")
        with gr.Row():
            gr.Button("AI μŠ€νƒ€νŠΈμ—… μ˜ˆμ‹œ").click(
                lambda: [
                    "AI Tech Corp", 2021, "AI/λ”₯ν…Œν¬", "μ„±μž₯ 단계", "κ΅¬λ…ν˜• (SaaS)",
                    100, 150, 200, 75, 2,
                    90, 40, 30, 20,
                    2000, 120,
                    "aitech.com, aitech.ai", 5, 2, 
                    "NeurIPS 2023 - Novel AI Architecture\nhttps://arxiv.org/abs/2023.12345", 3,
                    "https://github.com/aitech/core", 500, 3, 5,
                    15, 3, 2, 4,
                    10, 50, 100
                ],
                outputs=[
                    company_name, founded_year, industry, stage, revenue_type,
                    monthly_revenue, growth_rate, arpu, gross_margin, monthly_churn,
                    retention_rate, new_customers, monthly_marketing, monthly_sales,
                    cash_balance, burn_rate,
                    domains, patent_filed, patent_granted, papers, trademarks,
                    github_url, github_stars, awards, partnerships,
                    team_size, phd_count, serial_entrepreneurs, big_tech_experience,
                    media_coverage, app_downloads, social_followers
                ]
            )
            
            gr.Button("λ°”μ΄μ˜€ν…Œν¬ μ˜ˆμ‹œ").click(
                lambda: [
                    "BioHealth Inc", 2020, "ν—¬μŠ€μΌ€μ–΄", "초기 맀좜", "κ΅¬λ…ν˜• (SaaS)",
                    80, 200, 500, 85, 1,
                    95, 20, 40, 30,
                    3000, 150,
                    "biohealth.com, biohealth.health", 8, 4,
                    "Nature Medicine 2023 - Breakthrough in Drug Discovery\nScience 2023 - Novel Biomarker", 5,
                    "https://github.com/biohealth/research", 200, 5, 3,
                    25, 8, 1, 3,
                    15, 5, 30
                ],
                outputs=[
                    company_name, founded_year, industry, stage, revenue_type,
                    monthly_revenue, growth_rate, arpu, gross_margin, monthly_churn,
                    retention_rate, new_customers, monthly_marketing, monthly_sales,
                    cash_balance, burn_rate,
                    domains, patent_filed, patent_granted, papers, trademarks,
                    github_url, github_stars, awards, partnerships,
                    team_size, phd_count, serial_entrepreneurs, big_tech_experience,
                    media_coverage, app_downloads, social_followers
                ]
            )
    
    return demo

# μ‹€ν–‰
if __name__ == "__main__":
    demo = create_ui()
    demo.launch(share=True)