Sana sağlam rules buluruz
teşekkür ederim ama benimk sanki daha iyi
---
description:
globs:
alwaysApply: true
---
# Proje Anayasası
Bu dosya, projede kod kalitesi ve tutarlılık için uyulması gereken **temel kuralları** içerir.
## 1. MVVM Mimarisi (ZORUNLU)
### Repository Katmanı
- **Cache Strategy:** 5dk timeout ile cache yönetimi
- **Error Handling:** Try-catch + Talker logging
- **Data Access:** SQLite/Drift ile veri erişimi
### ViewModel Katmanı
- **State Management:** `ChangeNotifier` + `Provider`
- **Dependency Injection:** `GetIt.registerFactory()`
- **No UI Logic:** Flutter widget'larına referans yok
- **Proper Disposal:** Memory leak önleme
### View Katmanı
- **Consumer Pattern:** `Consumer<ViewModel>` kullanımı
- **No Business Logic:** Sadece UI rendering
- **Widget Separation:** Küçük, yeniden kullanılabilir parçalar
## 2. UI/UX Standartları (ZORUNLU)
### Tema Sistemi
- **Renkler:** `AppColors` sınıfından kullan
- **Spacing:** `AppSpacing.md` (16px) standard padding
- **Typography:** `AppTypography.textTheme`
- **Border Radius:** Kartlar:16px, Butonlar:8px
### Loading & Error States
- **Loading:** `CircularProgressIndicator` + açıklayıcı text
- **Error:** User-friendly mesaj + SnackBar
- **Success:** Green SnackBar confirmation
### Form Standards
- **Input Fields:** Icon prefix + consistent styling
- **Button Layout:** Wrap layout ile responsive
- **Card Design:** `AppColors.settings.sectionBackground`
## 3. Export Fonksiyonları
### Desteklenen Formatlar
- **PDF:** Professional formatting + headers
- **Excel:** Bold headers + proper data types
- **CSV:** Standard comma-separated format
- **Print:** Windows printer dialog
- **Email:** SMTP + PDF attachment
### User Experience
- **File Control:** `file_picker` ile save location
- **Async Operations:** Non-blocking export
- **Feedback:** Success/error SnackBar
## 4. Performance Kuralları
### Memory Management
- **Const Usage:** Mümkün olan her yerde `const`
- **Cache Timeout:** 5dk automatic clear
- **Dispose Pattern:** ViewModel'lerde proper cleanup
### Widget Performance
- **Build Methods:** Pure functions, no side effects
- **State Updates:** Minimal `notifyListeners()` calls
- **Large Data:** Pagination + lazy loading
## 5. Error Handling & Logging
### Talker Integration (ZORUNLU)
```dart
try {
// operation
_talker.info('Operation successful');
} catch (e, stackTrace) {
_error = 'User-friendly message';
_talker.error('Operation failed', e, stackTrace);
notifyListeners();
}
```
### User Feedback Standards
- **Error Messages:** Anlaşılır, actionable
- **Loading States:** Progress indicator + text
- **Success Confirmation:** Visual feedback
## 6. Kodlama Standartları
### İsimlendirme
- **Dosyalar:** `snake_case.dart`
- **Sınıflar:** `UpperCamelCase`
- **Değişkenler:** `lowerCamelCase`
- **Boolean:** Pozitif ifade (`isLoading`, `hasData`)
### Clean Code
- **SRP:** Her sınıf/metot tek sorumluluk
- **DRY:** Kod tekrarından kaçın
- **KISS:** Basit çözümler tercih et
- **Constructor Injection:** GetIt DI pattern
## 7. Service Locator Pattern
### ViewModel Registration
```dart
getIt.registerFactory<ExampleViewModel>(() =>
ExampleViewModel(getIt(), getIt(), getIt()));
```
### Service Registration
```dart
getIt.registerLazySingleton<ExampleService>(() =>
ExampleService(getIt<Talker>()));
```
## 8. Feature Development Checklist
### Yeni Feature Oluştururken
1. ✅ **ViewModel:** Proper DI + error handling
2. ✅ **Repository:** Cache + data access
3. ✅ **UI Components:** Design system compliance
4. ✅ **Service Locator:** Dependency registration
5. ✅ **Export Functions:** If data-centric
6. ✅ **Error States:** Comprehensive handling
7. ✅ **Loading States:** User feedback
### Code Review Points
- MVVM mimari uygunluğu
- Design system kullanımı
- Error handling kapsamlılığı
- Performance considerations
- Code reusability
---
**Bu kurallar kod kalitesini garanti eder. Her yeni development bu standartlara uygun yapılmalıdır.**