""" Main application entry point for the Syncora Data Generation Platform """ import streamlit as st from config.styles import get_minimal_css from utils.session_state import initialize_session_state from utils.data_processing import generate_sample_data from utils.aws_s3 import check_aws_credentials from components.file_processing import ( render_file_upload_with_cloud_section, render_all_configuration ) from components.data_generation import ( render_api_key_validation_step, render_generation_and_results ) def setup_page(): """Setup page configuration and styling""" st.set_page_config( page_title="Syncora", page_icon="🤖", layout="wide", initial_sidebar_state="collapsed" ) st.markdown(get_minimal_css(), unsafe_allow_html=True) def render_header(): """Render the compact header with progress indicator""" st.markdown( '
' '

Syncora

' '

AI-Powered Data Generation Platform

' '
', unsafe_allow_html=True ) # Cloud Storage Status indicator aws_status = check_aws_credentials() if aws_status['valid']: st.success(f"🌟 Cloud Storage: {aws_status['message']}") else: st.warning(f"⚠️ Storage Status: {aws_status['message']}") # Progress indicator render_progress_indicator() def render_progress_indicator(): """Render step progress indicator""" # Check completion status api_valid = (st.session_state.get('api_validation', {}).get('valid', False) and st.session_state.get('validated_api_key', '')) # Check if file has been uploaded (look for any cloud_file_link in session state) file_uploaded = any(str(key).startswith('cloud_file_link_') for key in st.session_state.keys()) # Check if configuration is set config_set = st.session_state.get('config') is not None # Create progress indicator col1, col2, col3, col4 = st.columns(4) steps = [ ("🔑", "API Key", api_valid), ("📁", "Upload", file_uploaded), ("⚙️", "Config", config_set), ("🚀", "Generate", False) # Will be updated based on generation ] cols = [col1, col2, col3, col4] for i, (icon, label, completed) in enumerate(steps): with cols[i]: if completed: st.markdown(f'
{icon}
{label} ✅
', unsafe_allow_html=True) else: st.markdown(f'
{icon}
{label}
', unsafe_allow_html=True) st.markdown("---") def main(): """Main application function""" try: # Setup page setup_page() # Initialize session state initialize_session_state() # Render header render_header() # Create main layout - always show 2 columns col1, col2 = st.columns([1, 1], gap="large") with col1: # Step 1: API Key Validation (Always shown) api_key_valid = render_api_key_validation_step() # Step 2: File upload section with automatic cloud upload (disabled if API key not valid) uploaded_file, file_link = render_file_upload_with_cloud_section(enabled=bool(api_key_valid)) with col2: # Step 3: All Configuration settings (disabled if no file link) config = render_all_configuration(enabled=bool(api_key_valid and file_link is not None)) # Step 4: Data generation and results (disabled if previous steps not completed) all_steps_complete = bool(api_key_valid and file_link is not None and config is not None) render_generation_and_results(file_link, config, enabled=all_steps_complete) # Footer - make it more compact st.markdown("---") col_footer1, col_footer2 = st.columns(2) with col_footer1: st.caption("🔗 API Access Available") with col_footer2: st.caption("🚀 Powered by Syncora AI") except Exception as e: st.error(f"⚠️ An unexpected error occurred. Please refresh the page and try again.") # Log error details for production debugging without exposing to user import logging logging.error(f"Application error: {str(e)}", exc_info=True) if __name__ == "__main__": main()