Main UI Component - Streamlit Email/Attachment Indexer and Viewer¶
Overview¶
The main UI component is a Streamlit application that serves as a fast, smart indexer for all backed up emails and attachments. Its primary purpose is to provide quick access and search capabilities across archived Gmail data, overcoming the semantic loss from UUID-based naming in backups. The component will index .eml and .json files regardless of storage structure (timestamp dirs, sender subdirs, etc.) and provide separate indexing for attachments.
Architecture¶
- Backend Indexer: Scans backup directories recursively to build searchable indexes of emails and attachments
- Frontend Viewer: Streamlit interface for search, browsing, and media visualization
- Modular Design: Separate concerns for email indexing, attachment indexing, and media viewing
TODO List¶
Phase 1: Core Indexing Infrastructure¶
- [x] Implement recursive backup directory scanner that finds all .eml and .json files
- [x] Create email metadata extractor from .json files (subject, from, date, body snippet, labels)
- [x] Build in-memory index structure for fast search (using dictionaries/lists for MVP)
- [x] Add basic email list view with pagination (50 items per page)
- [x] Implement simple text search across subject, from, and body fields
Phase 2: Attachment Indexing¶
- [ ] Extract attachment metadata from .eml files (filename, size, MIME type)
- [ ] Create separate attachment index with links to parent emails
- [ ] Add attachment viewer with download links
- [ ] Implement attachment search by filename and type
- [ ] Add attachment size statistics and filtering
Phase 3: Advanced Search Features¶
- [ ] Add date range filtering (from/to date pickers)
- [ ] Implement sender-based filtering and autocomplete
- [ ] Add label/folder filtering based on Gmail labels
- [ ] Support keyword search with AND/OR logic
- [ ] Add sorting options (date, sender, subject)
Phase 4: Media Visualization¶
- [ ] Implement image viewer using st.image for common formats (jpg, png, gif)
- [ ] Add PDF viewer using iframe or external viewer
- [ ] Support text file viewing (txt, md, etc.) with syntax highlighting
- [ ] Add audio/video preview capabilities (using HTML5 players)
- [ ] Implement document viewer for Word/Excel/PPT (download or basic preview)
Phase 5: Performance and Scalability¶
- [ ] Optimize index loading with lazy loading for large backup sets
- [ ] Add index caching to disk to avoid rescanning on every startup
- [ ] Implement incremental index updates for new backups
- [ ] Add progress indicators for long-running index operations
- [ ] Support parallel processing for large directory scans
Phase 6: User Experience Enhancements¶
- [ ] Add email detail view with full content display
- [ ] Implement breadcrumb navigation for folder hierarchies
- [ ] Add export functionality (CSV of search results, selected emails)
- [ ] Create dashboard with backup statistics (total emails, attachments, size by date)
- [ ] Add keyboard shortcuts for power users
Phase 7: Future Extensions Preparation¶
- [ ] Design extensible architecture for Drive/Photos integration
- [ ] Add placeholder components for future media types
- [ ] Implement configuration system for custom file type handlers
- [ ] Add API endpoints for potential REST integration
- [ ] Prepare for multi-user scenarios (if needed)
Phase 8: Testing and Deployment¶
- [ ] Create unit tests for indexing functions
- [ ] Add integration tests with sample backup data
- [ ] Implement error handling for corrupted files
- [ ] Add logging and monitoring for index operations
- [ ] Create deployment script for easy startup
Technical Considerations¶
- File Parsing: Use email library for .eml parsing, json for metadata
- Search: Start with simple string matching, consider full-text search later
- UI Framework: Streamlit for rapid development, with custom CSS if needed
- Data Structures: Use pandas DataFrames for efficient filtering/sorting
- Memory Management: Handle large indexes with chunking or database backend
- Security: Ensure no execution of malicious content in previews
Dependencies¶
- streamlit
- pandas (for data manipulation)
- email (built-in)
- json (built-in)
- os/pathlib (built-in)
- Optional: PyPDF2 for PDF text extraction, pillow for image processing
Success Criteria¶
- Index 10,000+ emails in under 30 seconds
- Search results return in under 1 second
- Support viewing of all major attachment types
- Intuitive interface for non-technical users
- Reliable operation with corrupted or missing files