How harshhh28/hia works
Project Type and Purpose
• This is a single-page, interactive full-stack application built with Streamlit as the front-end UI. Its purpose is to allow users to authenticate, upload and process PDF blood reports, and then use an AI-driven analysis agent (with multi-model cascades) to provide personalized health insights.
• The project integrates with Supabase for authentication and database operations and uses external AI models (via Groq API) for processing.
Key Components
a. Frontend/UI Layer:
• Built with Streamlit (files in the .streamlit directory and UI components in src/components such as analysis_form.py, auth_pages.py, footer.py, and sidebar.py).
• Handles user interactions like login, file uploads, and display of analysis results.
b. Authentication & Session Management:
• Found under src/auth (auth_service.py and session_manager.py), which integrates with Supabase Auth.
• Separate module sessions are managed to handle secure access.
c. AI Analysis and Agent-Based Architecture:
• The core health insights functionality resides in the AI agents housed under src/agents (analysis_agent.py and model_manager.py, with the README also noting agent management and model fallback logic).
• The pattern here is an agent-based cascade: one primary AI model is used first, with secondary models as backups via a fallback mechanism.
d. AI Service Integration:
• Located in src/services/ai_service.py; this module handles interaction with the Groq API and ingestion of responses from various models.
e. PDF Processing:
• Implemented in src/utils/pdf_extractor.py using PDFPlumber.
• This component extracts text from uploaded blood reports (and is triggered likely by the UI on file upload).
f. Configuration and Utilities:
• Configurations (app_config.py, prompts.py, sample_data.py) in src/config set global settings and AI prompt data.
• Additional utilities (like validators under src/utils/validators.py) support input checks.
g. Database & Schema:
• The public/db directory and SQL script (script.sql) denote that Supabase manages the database where session histories and report analyses are stored.
• Extra emphasis on the database is also shown via instructions in the README.
Relationships and Interactions
• User actions (via the Streamlit UI) will interact with authentication modules (src/auth) for login and session management.
• Once authenticated, users can upload a PDF report. The UI component calls the PDF extractor (src/utils/pdf_extractor.py) to convert the PDF content into text.
• The text is then passed to an analysis agent (src/agents/analysis_agent.py), which uses the AI service (src/services/ai_service.py) for processing. This service, in turn, communicates with multiple AI models (with priority ordering defined via the model_manager and fallback logic).
• After processing, the AI-generated insights are sent back to UI components for display, and may also be logged/stored in the Supabase database.
• The configuration files (src/config) parameterize many of these interactions (such as API keys, prompt templates, etc.).
Architectural Patterns and Design Principles
• The project follows an agent-based and layered architecture:
• Presentation Layer (Streamlit UI components)
• Application Layer (Authentication, PDF processing, AI analysis, agent management)
• Integration Layer (Supabase for DB/auth and external AI models via Groq API)
• Emphasis is on modularity: separate directories and files for agents, services, authentication, and utilities ensure loose coupling.
• The use of configuration files enables easier environment changes without deep code modifications.