# davidhealey/waistline architecture

> Architecture diagram of the GitHub repository davidhealey/waistline, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/davidhealey/waistline
- Repository: https://github.com/davidhealey/waistline

## Overview

##### Main Components Identification

The system consists of these key components:
- Frontend UI (Framework7-based)
- Local Storage/Database
- External Services Integration
- Core Application Logic

##### Component Relationships

Use these connection types:

##### Detailed Component Breakdown

Frontend Components:
**Activities/**
- Diary
- FoodList
- Foods-Meals-Recipes
- Goals
- Settings
- Statistics

Core Services:
**Services/**
- DatabaseHandler
- ExternalAPIs
- BarcodeScanner
- DataSync

##### Implementation Notes

- The app's privacy-focused nature
- Local data storage priority
- Optional online services
- Modular architecture

##### Technical Stack Indicators

Technology badges for:
- Cordova (Mobile framework)
- Framework7 (UI framework)
- JavaScript (Core language)
- SQLite (Local storage)

##### Additional Elements

Include:
- Version compatibility (Android 5.0+)
- Permission requirements
- Data backup/restore flows
- Localization support

Remember to include the relationship between the core application and the external services (Open Food Facts and USDA) as optional components that only activate when explicitly needed for barcode scanning or food database searches.

This architecture should reflect the app's commitment to privacy, offline-first functionality, and modular design while showing how all components work together to deliver the calorie counting and weight tracking features.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef ui fill:#f96,stroke:#333
    classDef core fill:#69f,stroke:#333
    classDef data fill:#666,stroke:#333
    classDef external fill:#6b6,stroke:#333
    classDef editor fill:#ff9,stroke:#333

    %% Main Layers
    subgraph UI["User Interface Layer"]
        Diary["Diary"]:::ui
        FoodList["Food List"]:::ui
        FoodsMealsRecipes["Foods/Meals/Recipes"]:::ui
        Goals["Goals"]:::ui
        Settings["Settings"]:::ui
        Statistics["Statistics"]:::ui
        SetupWizard["Setup Wizard"]:::ui
    end

    subgraph Core["Application Logic Layer"]
        DiaryMgmt["Diary Management"]:::core
        FoodListMgmt["Food List Management"]:::core
        FoodsMealsRecipesMgmt["Foods/Meals/Recipes Management"]:::core
        GoalsMgmt["Goals Management"]:::core
        SettingsMgmt["Settings Management"]:::core
        StatisticsMgmt["Statistics Module"]:::core
        BodyStats["Body Statistics"]:::core
        FoodCategories["Food Categories"]:::core
        Nutriments["Nutriments Management"]:::core
    end

    subgraph Editors["Editor Components"]
        FoodEditor["Food Editor"]:::editor
        RecipeEditor["Recipe Editor"]:::editor
        MealEditor["Meal Editor"]:::editor
    end

    subgraph Data["Data Management Layer"]
        DBHandler["Database Handler"]:::data
        Utils["Utilities"]:::data
    end

    subgraph External["External Services Layer"]
        OpenFoodFacts["Open Food Facts API"]:::external
        USDA["USDA Database"]:::external
        BarcodeScanner["Barcode Scanner"]:::external
    end

    %% Relationships
    Diary --> DiaryMgmt
    FoodList --> FoodListMgmt
    FoodsMealsRecipes --> FoodsMealsRecipesMgmt
    Goals --> GoalsMgmt
    Settings --> SettingsMgmt
    Statistics --> StatisticsMgmt

    DiaryMgmt --> DBHandler
    FoodListMgmt --> DBHandler
    FoodsMealsRecipesMgmt --> DBHandler
    GoalsMgmt --> DBHandler
    SettingsMgmt --> DBHandler
    StatisticsMgmt --> DBHandler

    FoodListMgmt -.-> OpenFoodFacts
    FoodListMgmt -.-> USDA
    FoodListMgmt -.-> BarcodeScanner

    SettingsMgmt --> BodyStats
    SettingsMgmt --> FoodCategories
    SettingsMgmt --> Nutriments

    FoodsMealsRecipesMgmt --> FoodEditor
    FoodsMealsRecipesMgmt --> RecipeEditor
    FoodsMealsRecipesMgmt --> MealEditor

    %% Click Events
    click DiaryMgmt "https://github.com/davidhealey/waistline/blob/master/www/activities/diary/js/diary.js"
    click FoodListMgmt "https://github.com/davidhealey/waistline/blob/master/www/activities/foodlist/js/foodlist.js"
    click FoodsMealsRecipesMgmt "https://github.com/davidhealey/waistline/blob/master/www/activities/foods-meals-recipes/js/foods-meals-recipes.js"
    click GoalsMgmt "https://github.com/davidhealey/waistline/blob/master/www/activities/goals/js/goals.js"
    click SettingsMgmt "https://github.com/davidhealey/waistline/blob/master/www/activities/settings/js/settings.js"
    click StatisticsMgmt "https://github.com/davidhealey/waistline/blob/master/www/activities/statistics/js/statistics.js"
    click SetupWizard "https://github.com/davidhealey/waistline/blob/master/www/activities/setup-wizard/js/setup-wizard.js"
    click DBHandler "https://github.com/davidhealey/waistline/blob/master/www/assets/js/db-handler.js"
    click OpenFoodFacts "https://github.com/davidhealey/waistline/blob/master/www/activities/foodlist/js/open-food-facts.js"
    click USDA "https://github.com/davidhealey/waistline/blob/master/www/activities/foodlist/js/usda.js"
    click Utils "https://github.com/davidhealey/waistline/blob/master/www/assets/js/utils.js"
    click BodyStats "https://github.com/davidhealey/waistline/blob/master/www/activities/settings/js/body-stats.js"
    click FoodCategories "https://github.com/davidhealey/waistline/blob/master/www/activities/settings/js/foods-categories.js"
    click Nutriments "https://github.com/davidhealey/waistline/blob/master/www/activities/settings/js/nutriments.js"
    click FoodEditor "https://github.com/davidhealey/waistline/blob/master/www/activities/foods-meals-recipes/js/food-editor.js"
    click RecipeEditor "https://github.com/davidhealey/waistline/blob/master/www/activities/recipes/js/recipe-editor.js"
    click MealEditor "https://github.com/davidhealey/waistline/blob/master/www/activities/meals/js/meal-editor.js"
```
