GitHub Action
Sync from GitHub
ef78361
Raw
History Blame Contribute Delete
2.35 kB
"""ChainShift Brand Risk Monitoring Dashboard v10.0.
Feature Plugin Architecture: ์ƒˆ ๊ธฐ๋Šฅ = features/ ๋””๋ ‰ํ† ๋ฆฌ ์ƒ์„ฑ โ†’ ์ž๋™ ๋“ฑ๋ก.
"""
import streamlit as st
from core.styles import DASHBOARD_CSS
from sidebar import render_sidebar
from registry import discover_features
# =============================================================================
# Page Config
# =============================================================================
st.set_page_config(
page_title="ChainShift Dashboard",
page_icon="โšก",
layout="wide",
initial_sidebar_state="expanded",
)
st.markdown(DASHBOARD_CSS, unsafe_allow_html=True)
st.title("ChainShift")
st.caption("AI ๊ฒ€์ƒ‰ ํ”Œ๋žซํผ์—์„œ ๋ธŒ๋žœ๋“œ๊ฐ€ ์–ด๋–ป๊ฒŒ ์–ธ๊ธ‰๋˜๊ณ  ์ธ์šฉ๋˜๋Š”์ง€ ๋ถ„์„ํ•ฉ๋‹ˆ๋‹ค")
# =============================================================================
# Sidebar (์ธ์ฆ + ์บ ํŽ˜์ธ ์„ ํƒ)
# =============================================================================
sidebar_result = render_sidebar()
if not sidebar_result:
st.stop()
auth_info, selected_campaign_id, selected_campaign_display = sidebar_result
# =============================================================================
# Feature Discovery + Rendering
# =============================================================================
features = discover_features()
if not features:
st.error("๋“ฑ๋ก๋œ Feature๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. features/ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.")
st.stop()
# Base context shared by all features
base_ctx = {
"api_key": auth_info.get("api_key"),
"access_token": auth_info.get("access_token"),
"campaign_id": selected_campaign_id,
"campaign_name": selected_campaign_display,
"user_email": auth_info.get("email"),
}
# Create tabs from discovered features
tab_labels = [f"{f['config']['icon']} {f['config']['name']}" for f in features]
tabs = st.tabs(tab_labels)
for tab, feature in zip(tabs, features):
with tab:
try:
feature["module"].render(base_ctx)
except Exception as e:
st.error(f"{feature['config']['name']} ๋กœ๋”ฉ ์‹คํŒจ: {e}")
# =============================================================================
# Footer
# =============================================================================
st.markdown("---")
st.caption("ChainShift v10.0")