# 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("""
""", 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()