import streamlit as st import os from dotenv import load_dotenv # Import local modules from src.pages import dashboard, decision_simulator, fund_monitoring, financial_advisor from src.utils.data_processing import ( generate_sample_startup_data, generate_sample_cash_flow_data, generate_sample_transactions_data ) # Load environment variables load_dotenv() # Constants DEFAULT_GROWTH_RATE = 0.08 # 8% monthly growth DEFAULT_BURN_RATE = 85000 # $85,000 monthly burn ENGINEER_SALARY = 10000 # $10,000 monthly cost per engineer ($120K/year) def main(): """ Main application entry point for Startup Finance Pilot """ # App configuration st.set_page_config( page_title="StartupFinancePilot", page_icon="💰", layout="wide", initial_sidebar_state="expanded" ) # Custom CSS (you might want to move this to a separate file in a larger project) st.markdown(""" """, unsafe_allow_html=True) # Initialize session state if 'startups' not in st.session_state: st.session_state.startups = {} if 'current_startup' not in st.session_state: st.session_state.current_startup = None if 'current_page' not in st.session_state: st.session_state.current_page = 'upload' if 'insights_cache' not in st.session_state: st.session_state.insights_cache = {} # Add sample data for demonstration sample_startup = generate_sample_startup_data() st.session_state.startups[sample_startup['name']] = { 'profile': sample_startup, 'cash_flow': generate_sample_cash_flow_data(), 'transactions': generate_sample_transactions_data() } st.session_state.current_startup = sample_startup['name'] # Sidebar navigation with st.sidebar: st.title("💰 StartupFinancePilot") st.write("AI-powered financial assistant for startups") # Startup selector if st.session_state.startups: startup_names = list(st.session_state.startups.keys()) selected_startup = st.selectbox( "Choose Startup", startup_names, index=startup_names.index(st.session_state.current_startup) ) st.session_state.current_startup = selected_startup # Show basic startup info startup_data = st.session_state.startups[selected_startup]['profile'] st.markdown(f""" **Stage:** {startup_data['stage']} **Cash:** ${startup_data['cash']:,} **Monthly Burn:** ${startup_data['burn_rate']:,} **Monthly Revenue:** ${startup_data['revenue']:,} """) # Navigation buttons st.markdown("
", unsafe_allow_html=True) page_options = { "📊 Financial Dashboard": "dashboard", "🔮 Decision Simulator": "simulator", "🕵️ Fund Monitoring": "monitoring", "🤖 AI Financial Advisor": "advisor" } for label, page_key in page_options.items(): if st.button(label, use_container_width=True): st.session_state.current_page = page_key st.experimental_rerun() # Render the correct page if st.session_state.current_page == 'dashboard': dashboard.render_financial_dashboard( st.session_state.startups[st.session_state.current_startup]['profile'], st.session_state.startups[st.session_state.current_startup]['cash_flow'] ) elif st.session_state.current_page == 'simulator': decision_simulator.render_decision_simulator( st.session_state.startups[st.session_state.current_startup]['profile'] ) elif st.session_state.current_page == 'monitoring': fund_monitoring.render_fund_monitoring( st.session_state.startups[st.session_state.current_startup]['transactions'] ) elif st.session_state.current_page == 'advisor': financial_advisor.render_ai_financial_advisor( st.session_state.startups[st.session_state.current_startup]['profile'] ) def validate_gemini_api_key(): """ Validate the Google Generative AI API key Returns: bool: True if API key is valid, False otherwise """ try: import google.generativeai as genai api_key = os.getenv('GOOGLE_API_KEY') if not api_key: st.error("🚨 Google API Key not found. Please set GOOGLE_API_KEY in your .env file.") return False genai.configure(api_key=api_key) model = genai.GenerativeModel('gemini-pro') # Try a simple test generation test_response = model.generate_content("Hello, can you confirm the API is working?") return True except Exception as e: st.error(f"🚨 Error validating API key: {e}") return False if __name__ == "__main__": # Check API key before running if validate_gemini_api_key(): main() else: st.warning("Please set up your Google Generative AI API key to use the application.")