update products
This commit is contained in:
500
docs/EXPORTS_DOCUMENTATION.md
Normal file
500
docs/EXPORTS_DOCUMENTATION.md
Normal file
@@ -0,0 +1,500 @@
|
||||
# Clean Architecture Export Files Documentation
|
||||
|
||||
This document describes all barrel export files created for the retail POS application, following clean architecture principles.
|
||||
|
||||
## Overview
|
||||
|
||||
Barrel export files provide a clean, organized way to import code by:
|
||||
- Simplifying imports across the codebase
|
||||
- Enforcing layer separation and boundaries
|
||||
- Making refactoring easier
|
||||
- Improving IDE autocomplete
|
||||
- Documenting module structure
|
||||
|
||||
## File Structure
|
||||
|
||||
```
|
||||
lib/
|
||||
├── core/
|
||||
│ ├── core.dart # Main core export
|
||||
│ ├── config/
|
||||
│ │ └── config.dart # Configuration exports
|
||||
│ ├── constants/
|
||||
│ │ └── constants.dart # All constants
|
||||
│ ├── database/
|
||||
│ │ └── database.dart # Database utilities
|
||||
│ ├── di/
|
||||
│ │ └── di.dart # Dependency injection
|
||||
│ ├── errors/
|
||||
│ │ └── errors.dart # Exceptions & failures
|
||||
│ ├── network/
|
||||
│ │ └── network.dart # HTTP & network
|
||||
│ ├── storage/
|
||||
│ │ └── storage.dart # Secure storage
|
||||
│ ├── theme/
|
||||
│ │ └── theme.dart # Material 3 theme
|
||||
│ ├── utils/
|
||||
│ │ └── utils.dart # Utilities & helpers
|
||||
│ └── widgets/
|
||||
│ └── widgets.dart # Core widgets (already exists)
|
||||
├── features/
|
||||
│ ├── features.dart # Main features export
|
||||
│ ├── auth/
|
||||
│ │ ├── auth.dart # Main auth export
|
||||
│ │ ├── data/
|
||||
│ │ │ ├── data.dart # Auth data layer
|
||||
│ │ │ ├── datasources/
|
||||
│ │ │ └── models/
|
||||
│ │ │ └── models.dart # Auth models
|
||||
│ │ ├── domain/
|
||||
│ │ │ ├── domain.dart # Auth domain layer
|
||||
│ │ │ └── entities/
|
||||
│ │ │ └── entities.dart # Auth entities
|
||||
│ │ └── presentation/
|
||||
│ │ ├── presentation.dart # Auth presentation layer
|
||||
│ │ ├── pages/
|
||||
│ │ │ └── pages.dart # Auth pages
|
||||
│ │ └── widgets/
|
||||
│ │ └── widgets.dart # Auth widgets
|
||||
│ ├── categories/
|
||||
│ │ ├── categories.dart # Main categories export
|
||||
│ │ ├── data/
|
||||
│ │ │ ├── data.dart # Categories data layer
|
||||
│ │ │ ├── datasources/
|
||||
│ │ │ │ └── datasources.dart # Category data sources
|
||||
│ │ │ └── models/
|
||||
│ │ │ └── models.dart # Category models
|
||||
│ │ ├── domain/
|
||||
│ │ │ ├── domain.dart # Categories domain layer
|
||||
│ │ │ ├── entities/
|
||||
│ │ │ │ └── entities.dart # Category entities
|
||||
│ │ │ └── usecases/
|
||||
│ │ │ └── usecases.dart # Category use cases
|
||||
│ │ └── presentation/
|
||||
│ │ ├── presentation.dart # Categories presentation layer
|
||||
│ │ ├── pages/
|
||||
│ │ │ └── pages.dart # Category pages
|
||||
│ │ ├── providers/
|
||||
│ │ │ └── providers.dart # Category providers (already exists)
|
||||
│ │ └── widgets/
|
||||
│ │ └── widgets.dart # Category widgets (already exists)
|
||||
│ ├── home/
|
||||
│ │ ├── home.dart # Main home/cart export
|
||||
│ │ ├── data/
|
||||
│ │ │ ├── data.dart # Cart data layer
|
||||
│ │ │ ├── datasources/
|
||||
│ │ │ │ └── datasources.dart # Cart data sources
|
||||
│ │ │ └── models/
|
||||
│ │ │ └── models.dart # Cart models
|
||||
│ │ ├── domain/
|
||||
│ │ │ ├── domain.dart # Cart domain layer
|
||||
│ │ │ ├── entities/
|
||||
│ │ │ │ └── entities.dart # Cart entities
|
||||
│ │ │ └── usecases/
|
||||
│ │ │ └── usecases.dart # Cart use cases
|
||||
│ │ └── presentation/
|
||||
│ │ ├── presentation.dart # Cart presentation layer
|
||||
│ │ ├── pages/
|
||||
│ │ │ └── pages.dart # Cart pages
|
||||
│ │ ├── providers/
|
||||
│ │ │ └── providers.dart # Cart providers (already exists)
|
||||
│ │ └── widgets/
|
||||
│ │ └── widgets.dart # Cart widgets (already exists)
|
||||
│ ├── products/
|
||||
│ │ ├── products.dart # Main products export
|
||||
│ │ ├── data/
|
||||
│ │ │ ├── data.dart # Products data layer
|
||||
│ │ │ ├── datasources/
|
||||
│ │ │ │ └── datasources.dart # Product data sources
|
||||
│ │ │ └── models/
|
||||
│ │ │ └── models.dart # Product models
|
||||
│ │ ├── domain/
|
||||
│ │ │ ├── domain.dart # Products domain layer
|
||||
│ │ │ ├── entities/
|
||||
│ │ │ │ └── entities.dart # Product entities
|
||||
│ │ │ └── usecases/
|
||||
│ │ │ └── usecases.dart # Product use cases
|
||||
│ │ └── presentation/
|
||||
│ │ ├── presentation.dart # Products presentation layer
|
||||
│ │ ├── pages/
|
||||
│ │ │ └── pages.dart # Product pages
|
||||
│ │ ├── providers/
|
||||
│ │ │ └── providers.dart # Product providers
|
||||
│ │ └── widgets/
|
||||
│ │ └── widgets.dart # Product widgets (already exists)
|
||||
│ └── settings/
|
||||
│ ├── settings.dart # Main settings export
|
||||
│ ├── data/
|
||||
│ │ ├── data.dart # Settings data layer
|
||||
│ │ ├── datasources/
|
||||
│ │ │ └── datasources.dart # Settings data sources
|
||||
│ │ └── models/
|
||||
│ │ └── models.dart # Settings models
|
||||
│ ├── domain/
|
||||
│ │ ├── domain.dart # Settings domain layer
|
||||
│ │ ├── entities/
|
||||
│ │ │ └── entities.dart # Settings entities
|
||||
│ │ └── usecases/
|
||||
│ │ └── usecases.dart # Settings use cases
|
||||
│ └── presentation/
|
||||
│ ├── presentation.dart # Settings presentation layer
|
||||
│ ├── pages/
|
||||
│ │ └── pages.dart # Settings pages
|
||||
│ ├── providers/
|
||||
│ │ └── providers.dart # Settings providers (already exists)
|
||||
│ └── widgets/
|
||||
│ └── widgets.dart # Settings widgets
|
||||
└── shared/
|
||||
└── shared.dart # Shared components export
|
||||
```
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### 1. Importing Entire Features
|
||||
|
||||
```dart
|
||||
// Import complete auth feature (all layers)
|
||||
import 'package:retail/features/auth/auth.dart';
|
||||
|
||||
// Import complete products feature
|
||||
import 'package:retail/features/products/products.dart';
|
||||
|
||||
// Import all features at once
|
||||
import 'package:retail/features/features.dart';
|
||||
```
|
||||
|
||||
### 2. Importing Specific Layers
|
||||
|
||||
```dart
|
||||
// Import only auth domain layer (entities + repositories)
|
||||
import 'package:retail/features/auth/domain/domain.dart';
|
||||
|
||||
// Import only products presentation layer (pages + widgets + providers)
|
||||
import 'package:retail/features/products/presentation/presentation.dart';
|
||||
|
||||
// Import only cart data layer
|
||||
import 'package:retail/features/home/data/data.dart';
|
||||
```
|
||||
|
||||
### 3. Importing Specific Components
|
||||
|
||||
```dart
|
||||
// Import only auth entities
|
||||
import 'package:retail/features/auth/domain/entities/entities.dart';
|
||||
|
||||
// Import only product models
|
||||
import 'package:retail/features/products/data/models/models.dart';
|
||||
|
||||
// Import only category use cases
|
||||
import 'package:retail/features/categories/domain/usecases/usecases.dart';
|
||||
|
||||
// Import only product providers
|
||||
import 'package:retail/features/products/presentation/providers/providers.dart';
|
||||
```
|
||||
|
||||
### 4. Importing Core Utilities
|
||||
|
||||
```dart
|
||||
// Import all core utilities
|
||||
import 'package:retail/core/core.dart';
|
||||
|
||||
// Import only constants
|
||||
import 'package:retail/core/constants/constants.dart';
|
||||
|
||||
// Import only theme
|
||||
import 'package:retail/core/theme/theme.dart';
|
||||
|
||||
// Import only network utilities
|
||||
import 'package:retail/core/network/network.dart';
|
||||
|
||||
// Import only error handling
|
||||
import 'package:retail/core/errors/errors.dart';
|
||||
```
|
||||
|
||||
### 5. Importing Shared Components
|
||||
|
||||
```dart
|
||||
// Import shared widgets
|
||||
import 'package:retail/shared/shared.dart';
|
||||
```
|
||||
|
||||
## Clean Architecture Benefits
|
||||
|
||||
### Layer Isolation
|
||||
|
||||
The export structure enforces clean architecture principles:
|
||||
|
||||
```dart
|
||||
// ✅ GOOD: Domain layer importing from domain
|
||||
import 'package:retail/features/products/domain/domain.dart';
|
||||
|
||||
// ❌ BAD: Domain layer importing from data/presentation
|
||||
// Domain should never depend on outer layers
|
||||
import 'package:retail/features/products/data/data.dart';
|
||||
```
|
||||
|
||||
### Dependency Flow
|
||||
|
||||
Dependencies flow inward:
|
||||
- **Presentation** → Domain ← Data
|
||||
- **Data** → Domain (implements interfaces)
|
||||
- **Domain** → Independent (pure business logic)
|
||||
|
||||
```dart
|
||||
// In presentation layer - ✅ GOOD
|
||||
import 'package:retail/features/products/domain/domain.dart';
|
||||
|
||||
// In data layer - ✅ GOOD
|
||||
import 'package:retail/features/products/domain/domain.dart';
|
||||
|
||||
// In domain layer - ❌ NEVER
|
||||
// import 'package:retail/features/products/data/data.dart';
|
||||
// import 'package:retail/features/products/presentation/presentation.dart';
|
||||
```
|
||||
|
||||
## Feature Export Hierarchy
|
||||
|
||||
Each feature follows this export hierarchy:
|
||||
|
||||
```
|
||||
feature.dart # Top-level feature export
|
||||
├── data/data.dart # Data layer export
|
||||
│ ├── datasources/datasources.dart
|
||||
│ ├── models/models.dart
|
||||
│ └── repositories/ # Implementations (exported directly)
|
||||
├── domain/domain.dart # Domain layer export
|
||||
│ ├── entities/entities.dart
|
||||
│ ├── repositories/ # Interfaces (exported directly)
|
||||
│ └── usecases/usecases.dart
|
||||
└── presentation/presentation.dart # Presentation layer export
|
||||
├── pages/pages.dart
|
||||
├── providers/providers.dart
|
||||
└── widgets/widgets.dart
|
||||
```
|
||||
|
||||
## Import Guidelines
|
||||
|
||||
### DO's
|
||||
|
||||
1. **Import at the appropriate level**
|
||||
```dart
|
||||
// If you need the entire feature
|
||||
import 'package:retail/features/auth/auth.dart';
|
||||
|
||||
// If you only need domain entities
|
||||
import 'package:retail/features/auth/domain/entities/entities.dart';
|
||||
```
|
||||
|
||||
2. **Use barrel exports for cleaner code**
|
||||
```dart
|
||||
// ✅ Clean and maintainable
|
||||
import 'package:retail/features/products/presentation/presentation.dart';
|
||||
|
||||
// ❌ Messy and fragile
|
||||
import 'package:retail/features/products/presentation/pages/products_page.dart';
|
||||
import 'package:retail/features/products/presentation/widgets/product_card.dart';
|
||||
import 'package:retail/features/products/presentation/widgets/product_grid.dart';
|
||||
import 'package:retail/features/products/presentation/providers/products_provider.dart';
|
||||
```
|
||||
|
||||
3. **Respect layer boundaries**
|
||||
```dart
|
||||
// In a use case (domain layer)
|
||||
import 'package:retail/features/products/domain/domain.dart'; // ✅
|
||||
import 'package:retail/core/core.dart'; // ✅ (core is shared)
|
||||
```
|
||||
|
||||
### DON'Ts
|
||||
|
||||
1. **Don't bypass barrel exports**
|
||||
```dart
|
||||
// ❌ Bypasses barrel export
|
||||
import 'package:retail/features/products/data/models/product_model.dart';
|
||||
|
||||
// ✅ Use barrel export
|
||||
import 'package:retail/features/products/data/models/models.dart';
|
||||
```
|
||||
|
||||
2. **Don't violate layer dependencies**
|
||||
```dart
|
||||
// In domain layer
|
||||
// ❌ Domain depends on outer layers
|
||||
import 'package:retail/features/products/data/data.dart';
|
||||
import 'package:retail/features/products/presentation/presentation.dart';
|
||||
```
|
||||
|
||||
3. **Don't import entire feature when you need one layer**
|
||||
```dart
|
||||
// ❌ Over-importing
|
||||
import 'package:retail/features/products/products.dart'; // Imports all layers
|
||||
// When you only need:
|
||||
import 'package:retail/features/products/domain/entities/entities.dart';
|
||||
```
|
||||
|
||||
## Benefits Summary
|
||||
|
||||
### 1. Clean Imports
|
||||
Before:
|
||||
```dart
|
||||
import 'package:retail/features/products/data/models/product_model.dart';
|
||||
import 'package:retail/features/products/domain/entities/product.dart';
|
||||
import 'package:retail/features/products/domain/repositories/product_repository.dart';
|
||||
import 'package:retail/features/products/presentation/pages/products_page.dart';
|
||||
import 'package:retail/features/products/presentation/widgets/product_card.dart';
|
||||
import 'package:retail/features/products/presentation/widgets/product_grid.dart';
|
||||
```
|
||||
|
||||
After:
|
||||
```dart
|
||||
import 'package:retail/features/products/products.dart';
|
||||
```
|
||||
|
||||
### 2. Layer Isolation
|
||||
- Domain layer never imports from data/presentation
|
||||
- Each layer has clear boundaries
|
||||
- Enforces dependency inversion
|
||||
|
||||
### 3. Easy Refactoring
|
||||
- Change internal structure without breaking imports
|
||||
- Move files within a layer without updating imports
|
||||
- Rename files without affecting external code
|
||||
|
||||
### 4. Better IDE Support
|
||||
- Autocomplete shows only exported items
|
||||
- Easier to navigate code structure
|
||||
- Clear module boundaries
|
||||
|
||||
### 5. Documentation
|
||||
- Export files serve as documentation
|
||||
- Shows what's public vs private
|
||||
- Makes architecture explicit
|
||||
|
||||
## Migration Guide
|
||||
|
||||
If you have existing imports, migrate them gradually:
|
||||
|
||||
### Step 1: Update feature-level imports
|
||||
```dart
|
||||
// Old
|
||||
import 'package:retail/features/products/presentation/pages/products_page.dart';
|
||||
|
||||
// New
|
||||
import 'package:retail/features/products/presentation/pages/pages.dart';
|
||||
```
|
||||
|
||||
### Step 2: Consolidate layer imports
|
||||
```dart
|
||||
// Old
|
||||
import 'package:retail/features/products/presentation/pages/pages.dart';
|
||||
import 'package:retail/features/products/presentation/widgets/widgets.dart';
|
||||
import 'package:retail/features/products/presentation/providers/providers.dart';
|
||||
|
||||
// New
|
||||
import 'package:retail/features/products/presentation/presentation.dart';
|
||||
```
|
||||
|
||||
### Step 3: Use top-level feature import when appropriate
|
||||
```dart
|
||||
// If you need multiple layers
|
||||
import 'package:retail/features/products/products.dart';
|
||||
```
|
||||
|
||||
## Complete File List
|
||||
|
||||
Total export files created: **54 files**
|
||||
|
||||
### Core Module (10 files)
|
||||
1. `/Users/ssg/project/retail/lib/core/core.dart`
|
||||
2. `/Users/ssg/project/retail/lib/core/config/config.dart`
|
||||
3. `/Users/ssg/project/retail/lib/core/constants/constants.dart`
|
||||
4. `/Users/ssg/project/retail/lib/core/database/database.dart`
|
||||
5. `/Users/ssg/project/retail/lib/core/di/di.dart`
|
||||
6. `/Users/ssg/project/retail/lib/core/errors/errors.dart`
|
||||
7. `/Users/ssg/project/retail/lib/core/network/network.dart`
|
||||
8. `/Users/ssg/project/retail/lib/core/storage/storage.dart`
|
||||
9. `/Users/ssg/project/retail/lib/core/theme/theme.dart`
|
||||
10. `/Users/ssg/project/retail/lib/core/utils/utils.dart`
|
||||
|
||||
### Auth Feature (8 files)
|
||||
11. `/Users/ssg/project/retail/lib/features/auth/auth.dart`
|
||||
12. `/Users/ssg/project/retail/lib/features/auth/data/data.dart`
|
||||
13. `/Users/ssg/project/retail/lib/features/auth/data/models/models.dart`
|
||||
14. `/Users/ssg/project/retail/lib/features/auth/domain/domain.dart`
|
||||
15. `/Users/ssg/project/retail/lib/features/auth/domain/entities/entities.dart`
|
||||
16. `/Users/ssg/project/retail/lib/features/auth/presentation/presentation.dart`
|
||||
17. `/Users/ssg/project/retail/lib/features/auth/presentation/pages/pages.dart`
|
||||
18. `/Users/ssg/project/retail/lib/features/auth/presentation/widgets/widgets.dart` *(updated by flutter expert)*
|
||||
|
||||
### Products Feature (10 files)
|
||||
19. `/Users/ssg/project/retail/lib/features/products/products.dart`
|
||||
20. `/Users/ssg/project/retail/lib/features/products/data/data.dart`
|
||||
21. `/Users/ssg/project/retail/lib/features/products/data/datasources/datasources.dart`
|
||||
22. `/Users/ssg/project/retail/lib/features/products/data/models/models.dart`
|
||||
23. `/Users/ssg/project/retail/lib/features/products/domain/domain.dart`
|
||||
24. `/Users/ssg/project/retail/lib/features/products/domain/entities/entities.dart`
|
||||
25. `/Users/ssg/project/retail/lib/features/products/domain/usecases/usecases.dart`
|
||||
26. `/Users/ssg/project/retail/lib/features/products/presentation/presentation.dart`
|
||||
27. `/Users/ssg/project/retail/lib/features/products/presentation/pages/pages.dart`
|
||||
28. `/Users/ssg/project/retail/lib/features/products/presentation/providers/providers.dart`
|
||||
|
||||
### Categories Feature (10 files)
|
||||
29. `/Users/ssg/project/retail/lib/features/categories/categories.dart`
|
||||
30. `/Users/ssg/project/retail/lib/features/categories/data/data.dart`
|
||||
31. `/Users/ssg/project/retail/lib/features/categories/data/datasources/datasources.dart`
|
||||
32. `/Users/ssg/project/retail/lib/features/categories/data/models/models.dart`
|
||||
33. `/Users/ssg/project/retail/lib/features/categories/domain/domain.dart`
|
||||
34. `/Users/ssg/project/retail/lib/features/categories/domain/entities/entities.dart`
|
||||
35. `/Users/ssg/project/retail/lib/features/categories/domain/usecases/usecases.dart`
|
||||
36. `/Users/ssg/project/retail/lib/features/categories/presentation/presentation.dart`
|
||||
37. `/Users/ssg/project/retail/lib/features/categories/presentation/pages/pages.dart`
|
||||
38. `/Users/ssg/project/retail/lib/features/categories/presentation/providers/providers.dart` *(already exists)*
|
||||
|
||||
### Home/Cart Feature (10 files)
|
||||
39. `/Users/ssg/project/retail/lib/features/home/home.dart`
|
||||
40. `/Users/ssg/project/retail/lib/features/home/data/data.dart`
|
||||
41. `/Users/ssg/project/retail/lib/features/home/data/datasources/datasources.dart`
|
||||
42. `/Users/ssg/project/retail/lib/features/home/data/models/models.dart`
|
||||
43. `/Users/ssg/project/retail/lib/features/home/domain/domain.dart`
|
||||
44. `/Users/ssg/project/retail/lib/features/home/domain/entities/entities.dart`
|
||||
45. `/Users/ssg/project/retail/lib/features/home/domain/usecases/usecases.dart`
|
||||
46. `/Users/ssg/project/retail/lib/features/home/presentation/presentation.dart`
|
||||
47. `/Users/ssg/project/retail/lib/features/home/presentation/pages/pages.dart`
|
||||
48. `/Users/ssg/project/retail/lib/features/home/presentation/providers/providers.dart` *(already exists)*
|
||||
|
||||
### Settings Feature (10 files)
|
||||
49. `/Users/ssg/project/retail/lib/features/settings/settings.dart`
|
||||
50. `/Users/ssg/project/retail/lib/features/settings/data/data.dart`
|
||||
51. `/Users/ssg/project/retail/lib/features/settings/data/datasources/datasources.dart`
|
||||
52. `/Users/ssg/project/retail/lib/features/settings/data/models/models.dart`
|
||||
53. `/Users/ssg/project/retail/lib/features/settings/domain/domain.dart`
|
||||
54. `/Users/ssg/project/retail/lib/features/settings/domain/entities/entities.dart`
|
||||
55. `/Users/ssg/project/retail/lib/features/settings/domain/usecases/usecases.dart`
|
||||
56. `/Users/ssg/project/retail/lib/features/settings/presentation/presentation.dart`
|
||||
57. `/Users/ssg/project/retail/lib/features/settings/presentation/pages/pages.dart`
|
||||
58. `/Users/ssg/project/retail/lib/features/settings/presentation/providers/providers.dart` *(already exists)*
|
||||
59. `/Users/ssg/project/retail/lib/features/settings/presentation/widgets/widgets.dart`
|
||||
|
||||
### Top-Level Exports (2 files)
|
||||
60. `/Users/ssg/project/retail/lib/features/features.dart`
|
||||
61. `/Users/ssg/project/retail/lib/shared/shared.dart`
|
||||
|
||||
### Documentation (1 file)
|
||||
62. `/Users/ssg/project/retail/lib/EXPORTS_DOCUMENTATION.md`
|
||||
|
||||
---
|
||||
|
||||
## Maintenance
|
||||
|
||||
When adding new files to the project:
|
||||
|
||||
1. **New file in existing module**: Update the appropriate barrel export
|
||||
2. **New module**: Create new barrel exports following the pattern
|
||||
3. **Removing files**: Update barrel exports to remove deleted exports
|
||||
4. **Renaming files**: Update barrel exports to reflect new names
|
||||
|
||||
## Support
|
||||
|
||||
For questions or issues with the export structure, refer to:
|
||||
- This documentation
|
||||
- Clean Architecture principles
|
||||
- Feature-first organization patterns
|
||||
Reference in New Issue
Block a user