H.A.R.V.E.Y Web App is an interactive interface for querying government policies using AI. Focused exclusively on the web components:
- FastAPI Backend: REST API with CORS and async processing
- Streamlit Frontend: Stateful chat interface with real-time updates
- Configuration Management: JSON-based endpoint configuration
- Production-Ready: Port management and service orchestration
- Core Services:
fastapi uvicorn streamlit aiohttp
- Network: Localhost ports 8000 (API), 8501 (UI), 8001 (MLflow)
pip install -r src/requirements.txt# Start services (MLflow + FastAPI) from project root
python src/backend/services.pyMLFLOW can be viewed below link after this log - INFO: Application startup complete.
MLFLOW Link - http://0.0.0.0:8001
streamlit run src/frontend/streamlit.py --server.port 8501Frontend can be viewed on this link - http://localhost:8501
Modify frontend_config.json for different environments:
{
"CHAT_API": {
"endpoint": "http://your-production-domain:8000",
"chat_response_route": "/answer_query"
}
}sequenceDiagram
participant User
participant Streamlit
participant FastAPI
User->>Streamlit: Enters query
Streamlit->>FastAPI: POST /answer_query
FastAPI->>Streamlit: {answer, metadata}
Streamlit->>User: Displays formatted response
def start_mlflow():
# Starts MLflow tracking server
subprocess.Popen(["mlflow", "server", ...])
def start_fastapi():
# Launches ASGI server
uvicorn.run(...)@answer_query_router.post("/")
async def answer_query(query_body: MessagesList):
# Processes 3 types of payloads:
# 1. New user queries
# 2. Follow-up questions
# 3. Contextual requests# Session state initialization
if "messages" not in st.session_state:
st.session_state.messages = []
# Message processing
async def query_api(messages, api_url):
# Handles:
# - Timeouts (10s limit)
# - JSON serialization
# - Error recoveryweb-app/
├── backend/
│ ├── services.py # Service orchestrator
│ ├── backend.py # Core API config
│ ├── routes/ # API endpoints
│ └── models/ # Request/response schemas
└── frontend/
├── streamlit.py # Chat UI core
├── frontend.py # UI launcher
└── frontend_config.json
For RAG pipeline documentation, see RAG_README.md in the main directory.