---
description: "MVVM architecture conventions for {{PROJECT_NAME}}"
alwaysApply: true
---

# MVVM Architecture — {{PROJECT_NAME}}

## Layer responsibilities
- **View** (Widget): Renders UI, dispatches user actions to ViewModel. Zero business logic.
- **ViewModel**: Holds UI state, calls Model/Repository, exposes streams/notifiers. Zero Flutter imports.
- **Model**: Plain Dart data structures + repository interfaces.

## Import rules
{{ARCH_IMPORT_RULES}}

## ViewModel rules
```dart
// ViewModel has NO Flutter imports — testable with plain dart test
class AuthViewModel extends ChangeNotifier {
  final AuthRepository _repository;
  AuthViewModel(this._repository);

  AuthViewState _state = const AuthViewState.initial();
  AuthViewState get state => _state;

  Future<void> login(String email, String password) async {
    _state = const AuthViewState.loading();
    notifyListeners();
    final result = await _repository.login(email, password);
    _state = result.fold(
      (error) => AuthViewState.error(error.message),
      (user)  => AuthViewState.success(user),
    );
    notifyListeners();
  }
}
```
