# Product Context: hosts

## Why This Project Exists

Managing the `/etc/hosts` file is a common task for developers, system administrators, and power users, but it's traditionally done through manual text editing. This approach has several pain points:

- **Error-prone**: Manual editing can introduce syntax errors or accidentally break existing entries
- **Inefficient**: No quick way to activate/deactivate entries for testing different configurations
- **Poor organization**: Large hosts files become difficult to navigate and maintain
- **No validation**: Easy to introduce invalid IP addresses or malformed entries
- **Limited functionality**: No built-in DNS resolution or IP comparison features

## Problems It Solves

1. **Safe Editing**: Provides validation and structured editing to prevent hosts file corruption
2. **Quick Testing**: Easy activation/deactivation of entries for testing different network configurations
3. **Organization**: Visual interface for sorting, reordering, and categorizing entries
4. **DNS Integration**: Automatic IP resolution and comparison for CNAME-like functionality
5. **User Experience**: Modern TUI interface that's faster and more intuitive than text editing

## How It Should Work

### Core User Experience
- **Two-pane interface**: Left pane shows all entries, right pane shows details of selected entry
- **Visual indicators**: Clear distinction between active/inactive entries
- **Keyboard-driven**: Efficient navigation and editing without mouse dependency
- **Safe operations**: All changes validated before writing to system files

### Key Workflows

1. **Viewing Mode (Default)**:
   - Read-only access to `/etc/hosts`
   - Browse and inspect entries safely
   - No system permissions required

2. **Edit Mode**:
   - Activated explicitly by user
   - Requests sudo permissions when enabled
   - Maintains permissions until edit mode is exited
   - All modification operations available

3. **Entry Management**:
   - Toggle entries active/inactive with simple keypress
   - Reorder entries by dragging or keyboard shortcuts
   - Sort by IP address, hostname, or comments
   - Add/edit comments for documentation

4. **DNS Operations**:
   - Store DNS names alongside IP addresses
   - Resolve DNS names to current IP addresses
   - Compare resolved IPs with stored IPs
   - User choice when IPs differ

## User Experience Goals

- **Immediate productivity**: Users should be able to accomplish common tasks within seconds
- **Error prevention**: Interface should make it difficult to create invalid configurations
- **Confidence**: Users should feel safe making changes without fear of breaking their system
- **Efficiency**: Common operations should require minimal keystrokes
- **Clarity**: Current state and available actions should always be obvious
- **Flexibility**: Support both quick edits and complex reorganization tasks

## Success Metrics

- Users can activate/deactivate entries faster than manual editing
- Zero corrupted hosts files due to application usage
- Users prefer the TUI over manual editing for hosts management
- DNS resolution features save time in dynamic IP environments
