@mohamedmegahed/personal-health-navi
flwr new @mohamedmegahed/personal-health-naviPersonal Health Navi π€
- not completed app, we will try to work on it later. -
A Flower AgentApp that helps users explore and understand their sleep habits through a multi-agent workflow.
Personal Health Navi is a personal-health assistant built with the Flower Agent Framework. It uses several specialized AI agents that work together to analyze sleep-related questions and provide evidence-based, personalized insights.
The idea is simple:
User question β Sleep data β Specialist agents β Evidence β Personalized answer
For example, a user could ask:
"Why have I been sleeping poorly during the last two weeks?"
The application can analyze the user's available sleep data, identify relevant patterns, and explain possible relationships between sleep duration, sleep consistency, bedtime, wake time, and other available factors.
Important: Personal Health Navi is designed to support users in understanding their health data. It does not diagnose medical conditions or replace professional medical advice.
π§ Concept
Personal Health Navi uses a multi-agent workflow instead of asking a single AI agent to perform the entire task.
Each agent has a specific responsibility.
| Stage | Agent | Responsibility |
|---|---|---|
| 1 | agent/sleep_query_agent.py | Understands the user's question and determines which sleep data is needed |
| 2 | agent/sleep_analysis_agent.py | Analyzes sleep data, detects patterns and calculates relevant metrics |
| 3 | agent/health_summary_agent.py | Explains the findings in clear language and provides personalized, evidence-based guidance |
The main orchestrator coordinates the agents and passes the relevant information from one stage to the next.
βββββββββββββββββββββββ β User β β "Why is my sleep β β worse recently?" β ββββββββββββ¬βββββββββββ β βΌ βββββββββββββββββββββββ β Sleep Query Agent β β β β Understand question β β Select data needed β ββββββββββββ¬βββββββββββ β βΌ βββββββββββββββββββββββ β Sleep Analysis Agentβ β β β Analyze sleep data β β Find patterns β β Calculate metrics β ββββββββββββ¬βββββββββββ β βΌ βββββββββββββββββββββββ β Health Summary Agentβ β β β Explain findings β β Give context β β Cite evidence β ββββββββββββ¬βββββββββββ β βΌ βββββββββββββββββββββββ β Personalized Answer β βββββββββββββββββββββββ
π Example Use Cases
Personal Health Navi can support questions such as:
Sleep duration
"How many hours do I usually sleep?"
The system can calculate average sleep duration and compare different periods.
Sleep consistency
"Is my sleep schedule regular?"
The agents can analyze variations in bedtime and wake time.
Recent changes
"Has my sleep changed compared with last month?"
The system can compare recent sleep patterns with historical data.
Sleep patterns
"What patterns can you see in my sleep?"
The analysis agent can look for relationships between available sleep metrics.
Natural-language questions
Users do not need to understand the underlying data.
Instead of:
"Calculate my 14-day average sleep duration."
they can simply ask:
"How well have I been sleeping lately?"
The query agent translates the natural-language question into an appropriate analysis task.
π€ Multi-Agent Architecture
The application consists of several components.
personal-health-navi/ β βββ agent/ β βββ agent_app.py β βββ query_agent.py β βββ sleep_analysis_agent.py β βββ health_summary_agent.py β βββ runtime.py β βββ events.py β βββ connectors/ β βββ ui/ β βββ server.py β βββ ... β βββ README.md βββ RUNNING.md βββ pyproject.toml βββ ...
1. Query Agent
agent/query_agent.py
The first agent acts as the sleep-data navigator.
It receives the user's natural-language question and determines:
- What the user wants to know
- Which sleep metrics are relevant
- Which time period should be analyzed
- Whether additional context is required
- What analysis should be performed
For example:
User: "Why was my sleep worse this week?" β Query Agent: time_range = last_7_days metrics: - sleep_duration - bedtime - wake_time - sleep_consistency analysis: - compare with previous period - identify significant changes
The agent does not immediately generate the final answer. It prepares a structured task for the next agent.
2. Sleep Analysis Agent
agent/sleep_analysis_agent.py
The second agent works with the user's available sleep data.
It can perform tasks such as:
- Calculate average sleep duration
- Compare different time periods
- Analyze bedtime and wake-time consistency
- Identify changes over time
- Detect unusually short or long sleep periods
- Calculate sleep variability
- Compare weekdays and weekends
- Identify correlations between available variables
For example:
Last 7 days Average sleep: 6h 42m Previous 7 days: 7h 21m Average bedtime: 23:48 Previous period: 23:12 Average wake time: 06:31 Previous period: 06:34
The result is structured evidence that can be consumed by the final agent.
3. Health Summary Agent
agent/health_summary_agent.py
The final agent transforms the analysis into an understandable response.
It should:
- Explain the relevant findings
- Distinguish observations from possible explanations
- Avoid unsupported medical conclusions
- Clearly communicate uncertainty
- Use the user's own sleep data
- Provide practical context where appropriate
- Recommend professional medical advice when a situation warrants it
For example:
"Your average sleep duration decreased by approximately 39 minutes compared with the previous week. Most of the change appears to come from later bedtimes, while your wake time remained relatively stable."
The agent should not turn this observation into an unsupported diagnosis.
π AgentApp Orchestration
agent/agent_app.py is the main orchestrator.
It:
- Receives the user's question
- Reconstructs the conversation context
- Runs the Query Agent
- Passes the structured task to the Sleep Analysis Agent
- Passes the analysis to the Health Summary Agent
- Stores the pipeline result in context.state
- Streams relevant events to the UI
Conceptually:
query_result = query_agent.run(user_question) analysis_result = sleep_analysis_agent.run( query=query_result, sleep_data=sleep_data, ) final_answer = health_summary_agent.run( query=user_question, analysis=analysis_result, )
This separation makes each agent easier to test, modify, and improve.
π Sleep Data
The application can be designed to work with structured sleep information such as:
{ "date": "2026-09-15", "sleep_duration": "7h 12m", "bedtime": "23:05", "wake_time": "06:17", "sleep_score": 82 }
A larger dataset could contain:
- Date
- Sleep duration
- Bedtime
- Wake time
- Sleep score
- Sleep stages
- Resting heart rate
- Heart-rate variability
- Activity
- Exercise
- Other user-provided contextual information
The exact available metrics depend on the connected health-data source.
π Privacy by Design
Personal Health Navi is intended for personal health data, so privacy is an important part of the architecture.
The application should follow principles such as:
- Minimize the amount of health data sent to an AI model
- Process data locally where practical
- Avoid unnecessary storage of raw health data
- Separate identifying information from analytical data
- Use explicit user consent for data access
- Keep audit logs free of sensitive health information where possible
- Clearly communicate how data is processed
The multi-agent architecture also allows the application to control which data is exposed to each agent.
For example, the Query Agent may only need metadata about available metrics, while the Analysis Agent receives the actual sleep measurements.
π₯οΈ Browser UI
The ui/ folder provides a local interface for observing the agent workflow.
The UI can display:
- User question
- Current agent
- Agent status
- Sleep data used for analysis
- Analysis results
- Events generated by each agent
- Final response
Example:
ββββββββββββββββββββββββββββββββββββββββββββββββ β Personal Health Navi β ββββββββββββββββββββββββββββββββββββββββββββββββ€ β β β User: Why has my sleep been worse lately? β β β β β Query Agent β β Identified: last 7 days β β β β β Sleep Analysis Agent β β Average sleep: 6h 42m β β Previous period: 7h 21m β β β β β Health Summary Agent β β Generating explanation... β β β ββββββββββββββββββββββββββββββββββββββββββββββββ
Run the local UI with:
uv sync --extra ui uv run python ui/server.py
If a live model and connected data sources are configured:
uv run python ui/server.py --live
Open the URL printed by the server and submit a sleep-related question.
πΈ Why Flower?
Flower provides the AgentApp runtime and workflow infrastructure.
Instead of building a custom orchestration system, Personal Health Navi can use Flower to coordinate specialized agents.
The architecture can later be extended beyond sleep.
For example:
Personal Health Navi β ββββββββββββββββΌβββββββββββββββ β β β βΌ βΌ βΌ Sleep Activity Nutrition Agents Agents Agents β β β ββββββββββββββββΌβββββββββββββββ βΌ Health Context Agent β βΌ User Explanation
This makes the project a potential foundation for a broader personal health navigation system, while keeping each domain modular.
π§© Flower Runtime
Flower Runtime provides the model/runtime configuration and task context.
The AgentApp can access configured tools and connectors through the Flower runtime rather than embedding provider credentials directly in the application.
Connector access follows the AgentApp workflow, for example:
agent.connectors.tools(...) agent.connectors.call(...)
This keeps external integrations separated from the individual agents.
π Build
Install the project:
uv sync
Build the Flower App Bundle:
uv run flwr build
βΆοΈ Run with Flower
Log in to Flower SuperLink/SuperGrid as required by your environment:
uv run flwr login supergrid
Run the application:
uv run flwr run . supergrid --stream
You can override the default input:
uv run flwr run . supergrid \ --run-config 'agent.input="How consistent is my sleep schedule?"' \ --stream
π§ͺ Example Conversation
User
"How has my sleep changed over the last two weeks?"
Query Agent
Identifies:
Period: 14 days Required metrics: - sleep duration - bedtime - wake time - sleep consistency
Sleep Analysis Agent
Produces:
Average sleep: 6h 58m Sleep variability: 42m Average bedtime: 23:41 Average wake time: 06:39
and compares these values with the user's previous period when available.
Health Summary Agent
Produces a natural-language explanation:
Over the last two weeks, your sleep duration has been relatively consistent, but your bedtime has varied considerably between days. The main observable pattern is therefore sleep-schedule variability rather than a large change in total sleep duration. This is an observation from the available sleep data, not a medical diagnosis.
π οΈ Customization
The main workflow can be modified in:
agent/agent_app.py
Individual agent behavior can be changed in:
agent/query_agent.py agent/sleep_analysis_agent.py agent/health_summary_agent.py
Possible future extensions include:
- Apple Health integration
- Google Health Connect integration
- Wearable-device data
- Garmin data
- Fitbit data
- Oura data
- Activity and exercise data
- Personalized sleep goals
- Long-term trend analysis
- Multimodal health-data analysis
- Evidence retrieval from trusted health sources
- Local LLM inference
- Privacy-preserving federated workflows
πΊοΈ Future Vision
The long-term idea is to turn Personal Health Navi into a natural-language interface for personal health data.
Instead of manually navigating dashboards, users can ask questions such as:
"How did I sleep last week?"
"Is my sleep schedule becoming more regular?"
"What changed compared with last month?"
"Show me the days when my sleep duration was lowest."
"What patterns can you find in my sleep data?"
The agent workflow translates these questions into data queries and analyses, then converts the results into explanations that are easier to understand.
The goal is not to replace a doctor or make medical decisions.
The goal is to make personal health data easier for people to explore, understand, and discuss with qualified professionals when needed.
π Learn More
- Flower Agent documentation
- Flower documentation
- Flower GitHub
- See RUNNING.md for detailed instructions on running the AgentApp.
License
Add the project license here.