CoffeeAtHome/docs/CSV_CRUD_Guide.md
2026-03-29 08:13:38 -07:00

53 lines
1.5 KiB
Markdown

# CSV Data Management Guide
1. **Master Catalog** (CSV files) - Coffee beans, machines, and recipes that come with the app
2. **User Collections** - Your personal saved items from the catalog
## For Users
### Adding Items to Your Collection
1. Open any screen (Beans, Machines, or Recipes)
2. Tap the "+" button to browse the catalog
3. Select items you want to add to your personal collection
### Managing Your Collection
- **View**: See only your saved items on each screen
- **Remove**: Swipe to delete items from your collection
- **Edit**: Tap to modify details (only for custom items you create)
## For Developers
### Adding New Catalog Items
Use the Python script to safely add items to the master catalog:
```bash
# Add a new bean to the catalog
python scripts/csv_manager.py add_bean '{"id":"bean_new","name":"New Bean","origin":"Colombia","varietal":"Arabica","roastLevel":"Medium"}'
# Backup CSV files before making changes
python scripts/csv_manager.py backup
# Check if CSV files are valid
python scripts/csv_manager.py validate
```
### Code Usage
```dart
// Get user's collection
final userBeans = await storageService.getUserBeans();
// Browse full catalog
final catalogBeans = await storageService.getCatalogBeans();
// Add to user collection
await storageService.saveUserBean(selectedBean);
```
## File Locations
- **CSV Files**: `lib/database/Coffee_Beans.csv`, etc.
- **Management Script**: `scripts/csv_manager.py`
- **Backups**: Created in `csv_backups/` folder
This setup with automatically manage data and storage.