# iOS App Clone Prompt for Django Links Application

Please create an iOS app called Heygo(in Chinese 黑狗) that replicates the functionality of my Django-based link management system. Here are the core features and functionalities to implement:

## Core Link Management Features

### 1. Link Model & Data Structure
- Links with unique aliases (alphanumeric slugs)
- Original URLs (supports template parameters like `{param,default=value}`)
- Link types: Regular Links and Custom Pages (with Markdown content), links with templates become Template type, so all the types are(Link, Custom, Template)
- Click tracking with timestamps
- Tags for categorization, optional
- Creation and update timestamps
- Description field, optional

### 2. Main Views & Functionality

#### Link List / Home page View
- Display all links in a list with sorting options (alias, type, URL, clicks, date)
- Search and quick go functionality, when typing in the search bar, it filters out on the existing links with fuzz search, when press enter, then open browser with the original url

#### Link Creation/Editing
- Form to create new links with alias validation
- Support for both regular URLs and custom markdown content
- Template URL support with parameter placeholders
- One more more Tags assignment, when user typing tags, it should auto complete based on existing tag list, auto create new tag on saving Link
- Duplicate alias prevention
- Real-time alias availability checking

#### Link Detail View
- Comprehensive link information display
- Click analytics with charts (daily/weekly/monthly views)
- Time period selection (3 months, 6 months, 1 year, all time)
- Change history log
- For custom links: rendered markdown content

### 3. URL Redirection System
- Short URL redirection (`/alias` → original URL)
- Template parameter support (`/alias/param` for parameterized URLs)
- Click logging for analytics
- Error handling for non-existent aliases

### 4. Analytics & Tracking
- Click count tracking per link
- Detailed click logs with timestamps
- Visual charts showing click trends over time
- Change history tracking

### 5. Additional Features
- Database backup capabilities to icloud
- Search across links and aliases
- Tag-based filtering
- Custom markdown pages with full rendering
- Help documentation

### 6. Technical Requirements
- Core Data for local storage
- Charts framework for analytics visualization
- Markdown rendering for custom content
- Network requests for URL validation
- Share extensions for adding links from other apps
- Dark mode support
- Accessibility features
- i18n multi language support, now supports Chinese and English

### 7. UI/UX Considerations
- Clean, modern interface similar to link management tools
- Quick access to popular links
- Intuitive navigation between list, detail, and creation views
- Visual feedback for user actions
- Offline functionality where possible
- Pull-to-refresh for data updates

### 8. Advanced Features to Include
- Backup and sync capabilities
- Batch operations (multi-select delete/edit)

## Implementation Details

### Core Data Model Structure
```swift
// Link Entity
class Link: NSManagedObject {
    @NSManaged var alias: String
    @NSManaged var originalURL: String?
    @NSManaged var text: String?
    @NSManaged var linkType: String // "LINK" or "CUSTOM"
    @NSManaged var clickCount: Int32
    @NSManaged var createdAt: Date
    @NSManaged var updatedAt: Date
    @NSManaged var linkDescription: String?
    @NSManaged var tags: NSSet?
    @NSManaged var clickLogs: NSSet?
    @NSManaged var changeLogs: NSSet?
}

// ClickLog Entity
class ClickLog: NSManagedObject {
    @NSManaged var clickedAt: Date
    @NSManaged var link: Link
}

// Tag Entity
class Tag: NSManagedObject {
    @NSManaged var name: String
    @NSManaged var slug: String
    @NSManaged var tagDescription: String?
    @NSManaged var createdAt: Date
    @NSManaged var links: NSSet?
}
```

### Key Features to Replicate

#### Template URL Processing
- Parse URLs with parameters like `{query,default=search}`
- Extract parameter names and default values
- Allow dynamic URL generation with user input
- Handle missing parameters gracefully

#### Analytics Dashboard
- Implement charts using Charts framework
- Support multiple time periods (3m, 6m, 1y, all time)
- Calculate intervals (daily, weekly, monthly) based on date range
- Real-time click tracking

#### Import/Export System
- JSON format compatibility with Django backend
- Validation of imported data
- Conflict resolution for duplicate aliases
- Progress indication for large imports

#### Search & Filtering
- Real-time search across aliases and URLs
- Tag-based filtering
- Sort by multiple criteria (clicks, date, alphabetical)
- Search history and suggestions

## Architecture Requirements

Please structure the app with proper MVC architecture, implement proper error handling, and ensure good performance with large numbers of links. Include comprehensive test coverage and follow iOS Human Interface Guidelines.

### Recommended Architecture
- **MVVM** pattern with Combine framework
- **Core Data** for persistent storage
- **SwiftUI** for modern UI development
- **Charts** framework for analytics
- **Network** layer for URL validation and TTS integration

### Performance Considerations
- Lazy loading for large link collections
- Efficient Core Data queries with proper indexing
- Background processing for analytics calculations
- Memory management for image and data caching

### Testing Strategy
- Unit tests for business logic
- UI tests for critical user flows
- Performance tests for large datasets
- Accessibility tests for VoiceOver support

This comprehensive iOS app should provide all the functionality of the Django web application while taking advantage of iOS-specific features and following platform conventions.
