How cutc-mt/web_proxy works
Main Components
• Frontend/UI:
• Represented by main.py as the entry point and the pages directory (with modules like chat.py, settings.py, and simple_qa.py), which together form the interactive Streamlit web interface.
• Backend/Logic:
• Core Python processing contained within main.py and various modules in the utils directory—such as api_utils.py (for API calls), and helper utilities like enhance_prompt.py and kwmatch.py.
• Incorporate the chat_backends submodule, which integrates external chat services (like those referencing Azure OpenAI) through files azure_openai.py, azure_openai_legacy.py, and manager.py.
• Mock Server:
• Represented by mock_server.py, which is a FastAPI server acting as a simulated backend for handling or mimicking API interactions.
• Data Storage:
• Although not directly visible as a physical file, the README informs us that SQLite is used for persistent storage with supporting utility functions in db_utils.py.
Interactions and Relationships
• The front-end (Streamlit UI) interacts directly with the backend logic when a user submits a web request.
• The backend may rely on utility functions (in utils/) to prepare request data, enhance prompts, or perform keyword matching.
• When a request is made, the system may contact the mock server (via network calls) for simulated response processing.
• Data flow between the UI, backend logic, and database (SQLite) should be highlighted, showing how POST data is saved, retrieved, and exported.
• Integration points with external services (i.e., Azure OpenAI) via the chat_backends modules should also be depicted, representing how they extend core functionality.
Architectural Patterns and Design Principles
• Separation of concerns: Different directories (pages for UI, utils for business logic, and a separate file for the mock server) show clear module separation.
• Modular design: The usage of specialized modules for chat backends and database utilities allows for extensibility and easy maintenance.
• Proxy-based communication: Highlight that web requests are managed through a proxy setup with detailed configuration settings.
• The single entry point (main.py) for the Streamlit app and an isolated FastAPI service (in mock_server.py) indicate a loosely coupled architecture allowing independent development/testing of components.
Relevant Technologies and Frameworks
• Streamlit for the web interface.
• Python for backend processing.
• FastAPI used in the mock server.
• SQLite (accessed via db_utils.py) for data storage.
• Azure OpenAI integrations (as per the azure_openai modules) for possible chat functionality.