import subprocess import sys import time def main(): print("Starting Finance LLM System...") # Start FastAPI backend print("Starting FastAPI Backend on port 8000...") backend = subprocess.Popen( [sys.executable, "-m", "uvicorn", "src.api.main:app", "--reload"], ) # Wait for the API to initialize time.sleep(5) # Start Streamlit frontend print("Starting Streamlit Frontend...") frontend = subprocess.Popen( [sys.executable, "-m", "streamlit", "run", "src/ui/streamlit_app.py"] ) print("\nSystem is live! If your browser didn't open automatically, go to http://localhost:8501") print("Press Ctrl+C to stop both servers.") try: # Keep the script running to keep the subprocesses alive backend.wait() frontend.wait() except KeyboardInterrupt: print("\nShutting down servers...") backend.terminate() frontend.terminate() backend.wait() frontend.wait() print("Shutdown complete.") if __name__ == "__main__": main()