# mr-aicoder/axishealth.ai---your_fitness_agent architecture

> Architecture diagram of the GitHub repository mr-aicoder/axishealth.ai---your_fitness_agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mr-aicoder/axishealth.ai---your_fitness_agent
- Repository: https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent

## Overview

##### Project Type and Purpose
- From the README and file tree, AxisHealth.ai is a full-stack, Streamlit-based web application that provides a personalized AI-powered fitness dashboard.
- It uses multiple AI “agents” (analysis, coach, nutritionist, trainer) orchestrated via LangChain and powered by Google Gemini and Tavily Search to deliver conversational advice, adaptive planning, and real-time research.
- Persistent data (user profiles, logs, metrics) live in a simple JSON-based database (user_db.json) accessed via database.py.

##### File Structure
- Top level:
- app.py – Streamlit entry point (UI orchestrator)
- database.py – data access layer for user_db.json
- user_profile_structure.py – model/schema for profile data
- requirements.txt, .devcontainer/ – environment & tooling
- agents/ – Python modules implementing each AI agent (analysis_agent, coach_agent, nutritionist_agent, trainer_agent)
- pages/ – Streamlit “multi-page” UI components (get_started, my_dashboard, log_workout, meal_calculator, bmi_analyzer)
- user_db.json – lightweight file DB storing per-user records

##### Key Architecture Insights from README
- UI layer (Streamlit) presents tabs/pages to user
- Orchestrator logic in app.py routes UI events to the appropriate Agent
- Agents use LangChain & Google Gemini LLMs plus Tavily Search for external knowledge
- Analysis Agent recalculates and updates plans; other agents provide coaching, meal plans, and exercise advice
- All interactions are tracked per user and persisted via database.py → user_db.json

##### Main Components
a. Frontend (Streamlit UI)
- app.py + pages/ folder
- Displays tabs, captures user input (login, metrics, queries)
b. Backend Orchestrator
- Controller in app.py
- Routes requests from UI to appropriate Agent module
c. Agent Modules
- Analysis Agent, Coach Agent, Nutritionist Agent, Trainer Agent (agents/ directory)
- Each encapsulates specific logic and calls out to:
- LangChain orchestration layer
- Google Gemini LLM
- Tavily Search API
d. Data Layer
- database.py interacting with user_db.json
- user_profile_structure.py defining the schema
e. External Services
- Google Gemini (LLM)
- Tavily Search API
- (Potential future: OAuth or other external data sources)

##### Relationships and Interactions
- User (browser) ↔ Streamlit UI
- Streamlit UI → Controller (app.py) → Agent Modules
- Agent Modules → External LLM Service / Search API
- Controller & Agents ↔ Database Layer → user_db.json
- Feedback loop: Analysis Agent updates user plans stored back to the DB, UI reflects updates

##### Architectural Patterns and Design Principles
- Separation of Concerns: UI, orchestration, agent logic, and data persistence are in distinct modules
- Modular AI Agents: Each agent is a self-contained micro-component, making the system extensible
- Single-process deployment: All modules run together under Streamlit, but conceptually layered
- Configurable through environment variables (Google/Tavily API keys)

##### Technologies, Frameworks, and Libraries
- Streamlit for the frontend
- LangChain for multi-agent orchestration
- Google Gemini as the LLM engine
- Tavily Search for real-time information
- Python (dataclasses or Pydantic via user_profile_structure.py)
- JSON file database (user_db.json)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        UI["app.py\n(Streamlit Entry Point)"]:::ui
        GS["get_started.py\n(Page)"]:::ui
        MD["my_dashboard.py\n(Page)"]:::ui
        LW["log_workout.py\n(Page)"]:::ui
        MC["meal_calculator.py\n(Page)"]:::ui
        BA["bmi_analyzer.py\n(Page)"]:::ui
    end

    %% Orchestrator Layer
    subgraph "Orchestrator (Controller)"
        direction TB
        Controller["app.py\n(Controller Logic)"]:::logic
    end

    %% Agents Layer
    subgraph "AI Agent Modules"
        direction TB
        Analysis["analysis_agent.py\n(Analysis Agent)"]:::logic
        Coach["coach_agent.py\n(Coach Agent)"]:::logic
        Nutritionist["nutritionist_agent.py\n(Nutritionist Agent)"]:::logic
        Trainer["trainer_agent.py\n(Trainer Agent)"]:::logic
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        DBAccess["database.py\n(Data Access Layer)"]:::data
        Schema["user_profile_structure.py\n(Profile Schema)"]:::data
        JSONDB["user_db.json\n(JSON Database)"]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        LLM["Google Gemini\n(LLM Service)"]:::external
        Search["Tavily Search API"]:::external
    end

    %% User
    User["User (Browser)"]:::external

    %% Interactions
    User -->|"interacts with"| UI
    UI -->|"routes events"| Controller
    Controller -->|"calls"| Analysis
    Controller -->|"calls"| Coach
    Controller -->|"calls"| Nutritionist
    Controller -->|"calls"| Trainer
    Analysis -->|"LLM inference"| LLM
    Coach -->|"LLM inference"| LLM
    Nutritionist -->|"LLM inference"| LLM
    Trainer -->|"LLM inference"| LLM
    Analysis -->|"search queries"| Search
    Coach -->|"search queries"| Search
    Nutritionist -->|"search queries"| Search
    Trainer -->|"search queries"| Search
    Controller -->|"DB read/write"| DBAccess
    Analysis -->|"DB read/write"| DBAccess
    DBAccess -->|reads/writes| JSONDB
    DBAccess -->|uses schema| Schema

    %% Click Events
    click UI "https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent/blob/main/app.py"
    click GS "https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent/blob/main/pages/get_started.py"
    click MD "https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent/blob/main/pages/my_dashboard.py"
    click LW "https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent/blob/main/pages/log_workout.py"
    click MC "https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent/blob/main/pages/meal_calculator.py"
    click BA "https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent/blob/main/pages/bmi_analyzer.py"
    click Controller "https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent/blob/main/app.py"
    click Analysis "https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent/blob/main/agents/analysis_agent.py"
    click Coach "https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent/blob/main/agents/coach_agent.py"
    click Nutritionist "https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent/blob/main/agents/nutritionist_agent.py"
    click Trainer "https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent/blob/main/agents/trainer_agent.py"
    click DBAccess "https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent/blob/main/database.py"
    click Schema "https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent/blob/main/user_profile_structure.py"
    click JSONDB "https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent/blob/main/user_db.json"
    click Dev "https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent/blob/main/.devcontainer/devcontainer.json"
    click Req "https://github.com/mr-aicoder/axishealth.ai---your_fitness_agent/blob/main/requirements.txt"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#0366D6,color:#0366D6
    classDef logic fill:#DFF7DF,stroke:#28A745,color:#28A745
    classDef data fill:#FFE5B4,stroke:#FF8C00,color:#FF8C00
    classDef external fill:#E2E2E2,stroke:#888888,color:#555555
    class Dev,Req external
```
