# frontend/app.py β€” SchemeImpactNet entry point # Run from project root: streamlit run frontend/app.py import sys, os sys.path.insert(0, os.path.dirname(__file__)) import streamlit as st st.set_page_config( page_title="SchemeImpactNet", page_icon="πŸ›οΈ", layout="wide", initial_sidebar_state="expanded", ) # ── Inject CSS first β€” before anything else ─────────────────────────────────── # Must happen before st.navigation() so sidebar styles are present when nav renders. st.markdown(""" """, unsafe_allow_html=True) # ── Sidebar brand + Gemini key input ───────────────────────────────────────── with st.sidebar: st.markdown("""

Policy Analytics

Scheme
ImpactNet

MNREGA Β· XGBoost Β· SciPy LP
7,758 district-years Β· 2014–2024

""", unsafe_allow_html=True) # ── Gemini API key β€” persisted in session_state, available on every page ── st.markdown("""

✦ AI Insights Key

""", unsafe_allow_html=True) key_input = st.text_input( "Gemini API Key", value=st.session_state.get("gemini_api_key", ""), type="password", placeholder="AIza... (optional)", help="Enables AI summaries on every page. Free at aistudio.google.com/apikey", key="sidebar_gemini_key", label_visibility="collapsed", ) if key_input: st.session_state["gemini_api_key"] = key_input # Status indicator if st.session_state.get("gemini_api_key"): st.markdown("""

βœ“ AI summaries active

""", unsafe_allow_html=True) else: st.markdown("""

Add key to unlock AI insights
aistudio.google.com β†—

""", unsafe_allow_html=True) # ── Page registry ───────────────────────────────────────────────────────────── pages = [ st.Page("pages/home.py", title="Home", icon="πŸ›οΈ", default=True), st.Page("pages/overview.py", title="Overview", icon="πŸ“Š"), st.Page("pages/districts.py", title="District Explorer", icon="πŸ”"), st.Page("pages/predictions.py", title="Predictions", icon="πŸ€–"), st.Page("pages/optimizer.py", title="Budget Optimizer", icon="βš–οΈ"), st.Page("pages/spatial.py", title="Spatial Map", icon="πŸ—ΊοΈ"), st.Page("pages/insights.py", title="Strategic Insights", icon="🧠"), st.Page("pages/gemini_insights.py", title="AI Insights", icon="✨"), ] pg = st.navigation(pages, position="sidebar") pg.run()