"""
app.py โ Main Streamlit entry point for No-CelH Self-Learning RMS
Run: streamlit run app.py
Hugging Face Spaces: set SDK=streamlit, app_file=app.py
"""
import streamlit as st
st.set_page_config(
page_title="No-CelH ยท Self-Learning RMS",
page_icon="๐",
layout="wide",
initial_sidebar_state="expanded",
menu_items={
"Get Help": "https://www.wcoomd.org/en/topics/enforcement-and-compliance/activities-and-programmes/risk-management.aspx",
"Report a bug": None,
"About": "No-CelH: Self-Learning RMS โ WCO Accredited Expert Simulation Tool\n\nBuilt on DATE + gATE Active Learning (Kim et al. 2022, IEEE TKDE)",
},
)
import page1_intro
import page2_risk_register
import page3_simulation
import page4_results
import page5_optimisation
from styles import WCO_GOLD, WCO_NAVY, WCO_BORDER, WCO_CARD_BG, WCO_MUTED, WCO_RED, WCO_GREEN
PAGES = {
"๐ Introduction & Architecture": page1_intro,
"๐ Risk Register & Matrix": page2_risk_register,
"๐ Simulation Engine": page3_simulation,
"๐ Simulation Results": page4_results,
"๐ Bandwidth Optimisation": page5_optimisation,
}
def sidebar():
with st.sidebar:
st.markdown(f"""
๐
No-CelH
Self-Learning RMS
WCO ACCREDITED ยท v2.0
""", unsafe_allow_html=True)
st.markdown(f"""
Navigation
""", unsafe_allow_html=True)
selected = st.radio("", list(PAGES.keys()),
key="nav_page", label_visibility="collapsed")
st.markdown(f"
",
unsafe_allow_html=True)
# Session state status panel
sim_ready = "sim_df" in st.session_state
st.markdown(f"""
Session Status
{'โ
' if sim_ready else 'โฌ'} Simulation Run
{'โ
' if 'rule_weights' in st.session_state else 'โฌ'} Weights Configured
{'โ
' if 'sim_efficiency' in st.session_state else 'โฌ'} Results Available
""", unsafe_allow_html=True)
if sim_ready:
df = st.session_state.sim_df
eff = st.session_state.get("sim_efficiency", {}).get("hybrid", {})
st.markdown(f"""
Last Simulation
๐ฆ Bills: {len(df):,}
๐ด RED: {(df['channel']=='RED').sum()}
๐ก YEL: {(df['channel']=='YELLOW').sum()}
๐ข GRN: {(df['channel']=='GREEN').sum()}
๐จ Detected:
{(df['inspection_outcome']=='FRAUD_DETECTED').sum()}
๐ Efficiency:
{eff.get('efficiency_index',0):.3f}
""", unsafe_allow_html=True)
st.markdown(f"""
Based on: Kim et al. (2022)
Active Learning for Human-in-the-Loop Customs Inspection
IEEE TKDE ยท WCO Compendium
WCO BACUDA Initiative
""", unsafe_allow_html=True)
return selected
def main():
selected = sidebar()
PAGES[selected].show()
if __name__ == "__main__":
main()