# Agenda Tasks

A calendar-based daily task management application built with Flutter and FastAPI.

## Overview

Agenda Tasks helps you manage your daily tasks with a focus on what needs to be done today, not endless lists. Select a day, see your tasks, add new ones, mark them complete, or reschedule them for tomorrow.

## Features

- **Daily Agenda View**: See all tasks for a selected day
- **Calendar Navigation**: Browse and select dates easily
- **Task Management**: Create, edit, delete, and complete tasks
- **Priority Levels**: Low, Medium, High with color coding
- **Reschedule**: Move tasks to tomorrow with one tap
- **Filtering**: View All, Active, or Completed tasks
- **Internationalization**: English and German language support
- **Dark Mode**: System default, Light, or Dark theme

## Architecture

The project follows Clean Architecture principles with a clear separation of concerns:

```
lib/
├── core/                 # Shared utilities, DI, errors, logging
├── features/
│   ├── tasks/
│   │   ├── data/        # Models, DataSources, Repository implementations
│   │   ├── domain/      # Entities, Enums, Repository interfaces
│   │   └── presentation/# ViewModels, Pages, Widgets
│   └── settings/
├── routing/             # GoRouter configuration
└── l10n/               # Localization (ARB files)
```

### State Management

- **Provider** with ViewModel pattern
- Each feature has its own ViewModel (ChangeNotifier)
- Result pattern for error handling

### Routing

Using `go_router` for declarative routing:

| Route | Page |
|-------|------|
| `/` | Daily Agenda |
| `/calendar` | Calendar View |
| `/task/new?date=YYYY-MM-DD` | Create Task |
| `/task/:id/edit` | Edit Task |
| `/settings` | Settings |

## Backend

REST API built with FastAPI (Python):

```
backend/
├── app/
│   ├── main.py          # FastAPI app
│   ├── routes.py        # API endpoints
│   ├── models.py        # SQLAlchemy models
│   ├── schemas.py       # Pydantic schemas
│   ├── services.py      # Business logic
│   ├── db.py            # Database setup
│   └── tests/           # Pytest tests
└── requirements.txt
```

### API Endpoints

| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/health` | Health check |
| GET | `/tasks?date=YYYY-MM-DD` | Get tasks by date |
| POST | `/tasks` | Create task |
| PUT | `/tasks/{id}` | Update task |
| DELETE | `/tasks/{id}` | Delete task |
| PATCH | `/tasks/{id}/toggle` | Toggle completion |
| POST | `/tasks/{id}/reschedule` | Reschedule task |

## Getting Started

### Prerequisites

- Flutter SDK 3.10+
- Python 3.11+
- Android Studio / VS Code

### Backend Setup

```bash
cd backend

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Copy environment file
cp .env.example .env

# Run server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
```

### Frontend Setup

```bash
# Install dependencies
flutter pub get

# Generate localizations
flutter gen-l10n

# Run on Android (with backend running)
flutter run
```

### Environment Configuration

The app supports multiple environments via flavor configuration:

```bash
# Development (default)
flutter run
flutter run -t lib/main_dev.dart

# Production
flutter run -t lib/main_prod.dart --release

# With explicit environment variable
flutter run --dart-define=ENV=prod
```

Configuration is managed in `lib/core/config/app_config.dart`.

## Specialization Topic

**Testing + Internationalization**

This project focuses on two specialization areas for the HFTM Mobile Computing course:

1. **Testing**: Comprehensive test coverage with unit, widget, and integration tests
2. **Internationalization**: Full i18n support with English and German, locale-aware date formatting

## Testing Strategy

The project follows a multi-layered testing approach:

### Unit Tests
- **Domain Layer**: Entity validation, enum behavior
- **Data Layer**: Model serialization/deserialization (JSON)
- **Presentation Layer**: ViewModel business logic with mocked repositories

### Widget Tests
- Component rendering and display
- User interactions (tap, input)
- State changes and callbacks

### Integration Tests
- End-to-end user flows
- Navigation between screens
- Task creation and management lifecycle

### Running Tests

```bash
# Run all unit and widget tests
flutter test

# Run with coverage
flutter test --coverage

# Run integration tests (requires device/emulator)
flutter test integration_test

# Run specific test file
flutter test test/features/tasks/presentation/viewmodels/daily_tasks_viewmodel_test.dart
```

### Test Structure

```
test/
├── features/
│   ├── auth/
│   │   ├── data/models/          # Model serialization tests
│   │   └── domain/entities/      # Entity tests
│   ├── tasks/
│   │   ├── data/models/
│   │   ├── domain/
│   │   └── presentation/
│   │       ├── viewmodels/       # ViewModel unit tests
│   │       └── widgets/          # Widget tests
│   └── onboarding/
└── helpers/                      # Test utilities

integration_test/
└── app_test.dart                 # End-to-end tests
```

## Internationalization (i18n)

The app supports multiple languages through ARB files in `lib/l10n/`:

- `app_en.arb` - English (default)
- `app_de.arb` - German

### Adding a New Language

1. Create a new ARB file: `lib/l10n/app_XX.arb`
2. Copy content from `app_en.arb` and translate
3. Run `flutter gen-l10n`
4. Add the locale to `supportedLocales` in `SettingsViewModel`

## License

This project is part of a course at HFTM (Höhere Fachschule für Technik Mittelland).
