File size: 1,942 Bytes
ac40033
1ef4e10
 
86cf81a
 
 
 
 
 
 
 
 
 
 
0fb23b8
1ef4e10
 
c6fc32c
bc1cd44
1ef4e10
 
0fb23b8
bc1cd44
e1df50c
1ef4e10
 
 
 
 
e1df50c
 
 
 
 
 
 
 
1ef4e10
 
 
e1df50c
c6fc32c
 
 
1ef4e10
e1df50c
c6fc32c
 
 
ac40033
e1df50c
 
 
1ef4e10
6b8b495
 
1ef4e10
86cf81a
 
 
 
 
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
import gradio as gr
from pathlib import Path

# Initialize Sentry first (before other imports)
try:
    from utils.sentry_integration import initialize_sentry
    sentry_initialized = initialize_sentry()
    if sentry_initialized:
        print("✅ Sentry monitoring enabled")
    else:
        print("⚠️ Sentry monitoring disabled (no DSN configured)")
except Exception as e:
    raise

from utils.logger import Logger
from components.login_page import LoginPage
from components.dashboard_page import DashboardPage
from components.review_dashboard_page import ReviewDashboardPage
from utils.database import initialize_database
from config import conf

log = Logger()
initialize_database()

CSS_FILE = Path(__file__).parent / "assets" / "styles.css"
custom_css = CSS_FILE.read_text(encoding="utf-8")


def build_app() -> gr.Blocks:
    """
    می‌سازد و wiring کل اپلیکیشن را انجام می‌دهد.
    """
    demo = gr.Blocks(title=conf.APP_TITLE, css=custom_css)

    with demo:
        # حالت سراسری برنامه به‌صورت gr.State
        session_state = gr.State({})

        gr.Markdown(f"### {conf.APP_TITLE}")

        # صفحات
        login_page = LoginPage()
        dashboard_page = DashboardPage()  # Phase 1 interface
        review_dashboard_page = ReviewDashboardPage()  # Phase 2 interface

        # اتصال رویدادها
        login_page.register_callbacks(dashboard_page, session_state, review_dashboard_page)
        dashboard_page.register_callbacks(login_page, session_state, demo, review_dashboard_page)
        review_dashboard_page.register_callbacks(login_page, session_state, demo)

    # صف پردازش گرادیو
    demo.queue(default_concurrency_limit=50)
    log.info("App Started.")
    return demo


if __name__ == "__main__":
    try:
        log.info("Launching App ...")
        build_app().launch()
    except Exception as err:
        raise