# BiteBudget

BiteBudget is a Flutter app for nutrition and weight tracking. It helps users manage meals and activities, follow their weight history, and track a personal daily bitePoints budget.

## Features

- Track body data such as weight, height, birthdate, gender, and activity level.
- Record food and sport activities in a weekly logbook.
- Calculate bitePoints from food nutrition values and personal body data.
- Browse and manage food entries, including favorites and barcode scanning.
- View weight history and body statistics.
- Receive local reminders.
- Use the app in German (`de_DE`); the app is configured for portrait orientation.

## Tech Stack

- Flutter and Dart `^3.10.7`
- Riverpod with generated providers
- Appwrite for authentication and data storage
- GoRouter for navigation and authentication redirects
- Freezed and `json_serializable` for immutable and JSON models
- Flutter Form Builder and validators
- Flutter Local Notifications and timezone support
- Flutter Test and Mocktail

## Project Structure

- `lib/main.dart`: initializes Flutter, locale/date data, timezone data, provider scope, and the app.
- `lib/router.dart`: app routes and authentication redirects.
- `lib/core/`: shared providers, widgets, layouts, mixins, and utilities.
- `lib/features/<feature>/`: feature-specific models, providers, repositories, services, and UI.
- `test/unit/` and `test/widgets/`: unit and widget tests following the `lib/` feature structure.
- `functions/`: standalone Appwrite Functions. Each function has its own `pubspec.yaml`.
- `appwrite.config.json`: Appwrite project, function, database, table, and column configuration.

Feature repositories perform Appwrite data access. Riverpod providers coordinate repository calls and UI state. Keep feature-specific code within its feature; put reusable application code in `lib/core/`.

## Requirements

- Flutter SDK compatible with Dart `^3.10.7`
- An Appwrite project configured for this app
- Flutter platform tooling for the target platform (for example, Android Studio/SDK for Android)

The Appwrite client endpoint and project ID are currently configured in `lib/core/provider/appwrite_provider.dart`. The Appwrite resource definitions are in `appwrite.config.json`.

## Setup And Run

From the repository root:

```sh
flutter pub get
dart run build_runner build --delete-conflicting-outputs
flutter run
```

Code generation is required after changing annotated Riverpod providers or Freezed/JSON models. Generated `*.g.dart` and `*.freezed.dart` files are maintained by `build_runner`; do not edit them manually.

## Development Checks

```sh
flutter analyze
flutter test
```

Run a single test by passing its repository-relative path, for example:

```sh
flutter test test/unit/core/utils/points_calculator_test.dart
```

Tests are organized under `test/unit/<path matching lib/>` and `test/widgets/<path matching lib/>`.

## Appwrite Functions

The functions under `functions/` are separate Dart packages and manage their own dependencies. Run package commands from the relevant function directory, for example:

```sh
dart pub get
```

When changing a function or Appwrite resource, keep its implementation and the corresponding definitions in `appwrite.config.json` in sync.
