Files
2026-10-28 02:37:56 -05:00

89 lines
2.5 KiB
Python

from pathlib import Path
import sys
import streamlit as st
APP_DIR = Path(__file__).resolve().parent
if str(APP_DIR) not in sys.path:
sys.path.insert(0, str(APP_DIR))
from utils.db import get_seasons # noqa: E402
st.set_page_config(
page_title="NBA Analytics",
page_icon=":material/sports_basketball:",
layout="wide",
)
# ============================================================
# GLOBAL SEASON STATE & SIDEBAR CONTROLS
# ============================================================
seasons = get_seasons()
season_options = seasons["season_start_year"].tolist()
season_labels = dict(zip(seasons["season_start_year"], seasons["season_display"]))
if "season" not in st.session_state or st.session_state["season"] not in season_labels:
st.session_state["season"] = season_options[0]
with st.sidebar:
st.markdown("### :material/sports_basketball: NBA Analytics")
st.caption("ARENA NOCTURNE // TELEMETRY MARTS")
st.selectbox(
"Season",
season_options,
key="season",
format_func=lambda x: season_labels.get(x, str(x)),
)
# ============================================================
# NATIVE STREAMLIT MULTIPAGE NAVIGATION
# ============================================================
nav = st.navigation(
{
"League & Teams": [
st.Page(
"app_pages/overview.py",
title="Overview",
icon=":material/dashboard:",
default=True,
),
st.Page(
"app_pages/teams.py",
title="Teams",
icon=":material/shield:",
),
st.Page(
"app_pages/head_to_head.py",
title="Head to Head",
icon=":material/swords:",
),
],
"Players & Shooting": [
st.Page(
"app_pages/player_lab.py",
title="Player Lab",
icon=":material/science:",
),
st.Page(
"app_pages/shot_charts.py",
title="Shot Charts",
icon=":material/my_location:",
),
],
"Game Dynamics": [
st.Page(
"app_pages/game_trends.py",
title="Game Trends",
icon=":material/trending_up:",
),
st.Page(
"app_pages/quarter_analysis.py",
title="Quarter Analysis",
icon=":material/timer:",
),
],
},
position="sidebar",
)
nav.run()