# Agents Guide - URL Manager This guide is designed to help AI coding agents understand and work with the URL Manager project effectively. ## Project Overview **URL Manager** (also known as "Heygo" / 黑狗) is a comprehensive link management system built with Django and available as both a web application and native iOS app. The system provides short link creation, bookmark management with automatic metadata extraction, template URLs with parameters, collections, and advanced search capabilities. ### Tech Stack - **Backend**: Django 5.1, Django REST Framework, APScheduler - **Frontend**: Tailwind CSS, AlpineJS (minimal JS) - **Database**: SQLite (default, configurable) - **Task Queue**: APScheduler (in-process background scheduler) - **Storage**: Local filesystem or AWS S3/Cloudflare R2 - **Web Automation**: Selenium with Chromium (for screenshots and scraping) - **Mobile**: SwiftUI iOS app with Core Data - **Deployment**: Kubernetes (k8s manifests included) ## Architecture ### Core Components ``` ┌─────────────────────────────────────────────────────────────┐ │ Web Interface │ │ (Django Templates + Tailwind CSS) │ └──────────────────┬──────────────────────────────────────────┘ │ ┌──────────────────┴──────────────────────────────────────────┐ │ Django Application │ │ ┌──────────────┬──────────────┬──────────────────────┐ │ │ │ Links Module │ Pages Module │ Collections Module │ │ │ │ │ │ (Images, Posts) │ │ │ └──────────────┴──────────────┴──────────────────────┘ │ │ ┌────────────────────────────────────────────────────┐ │ │ │ REST API (DRF ViewSets) │ │ │ └────────────────────────────────────────────────────┘ │ └──────────────────┬──────────────────────────────────────────┘ │ ┌──────────────────┴──────────────────────────────────────────┐ │ Background Tasks (APScheduler + Threading) │ │ - Screenshot capture (background threads) │ │ - Page metadata extraction (background threads) │ │ - Periodic task scheduling (APScheduler) │ └─────────────────────────────────────────────────────────────┘ │ ┌──────────────────┴──────────────────────────────────────────┐ │ Storage Layer │ │ - Local filesystem (default) │ │ - Cloudflare R2 / AWS S3 (optional) │ └─────────────────────────────────────────────────────────────┘ ``` ## Data Models ### Core Models (links/models.py) #### Link The central model for URL management: - **alias**: Unique slug identifier for the short link - **original_url**: Target URL (supports templates with `{param,default=value}`) - **text**: Markdown content (for custom pages) - **link_type**: LINK (regular URL) or CUSTOM (markdown content) - **click_count**: Usage analytics - **tags**: Many-to-many relationship with Tag model - **description**: Optional description **Template URL Feature**: URLs can contain parameters like `https://example.com/{query,default=test}` that are resolved at access time. #### Page Bookmarked pages with auto-extracted metadata: - **url**: Original page URL - **title**: Auto-extracted or manual - **summary**: Auto-extracted description - **content**: Full page content (optional) - **screenshot**: Associated Screenshot model - **tags**: Many-to-many with Tag - **processing_status**: PENDING, PROCESSING, COMPLETED, FAILED - **priority**: For async processing queue #### Tag Hierarchical tagging system: #### Bookmark Archived social-media posts (originally x.com / Twitter bookmarks), each saved with full preview data so a viewer page renders offline without further x.com API calls: - **tweet_id**: Source post id (unique, indexed) - **url**: Canonical x.com post URL - **author_screen_name / author_name / author_profile_image_url**: Denormalised author - **text**: Full post text (searchable) - **summary**: Optional human/agent-written summary (writable via API `PATCH`) - **tweet_created_at / bookmark_created_at**: Parsed source dates (indexed) - **view_count / favorite_count / retweet_count / reply_count / bookmark_count / quote_count**: Engagement counters - **has_video / has_photo / has_card / is_quote / is_retweet**: Indexed boolean flags for fast filter pages - **media**: JSON list of media objects (photo URL variants; video/animated_gif with `poster`, `best_mp4`, `duration_ms`, `variants[]`) - **card_data**: JSON link-preview card (title/description/site/image/url) - **quoted_data**: JSON nested quoted post (recursive shape) - **data**: The complete original normalised export object (kept for round-tripping / the offline viewer) - UI: `/ui/bookmarks/` (list, `BookmarkListView`) + `/ui/bookmarks//` (detail). Top-menu item "Bookmarks" in `templates/base.html`. - Import: `python manage.py import_x_bookmarks [--clear]` (loads `x-bookmarks-exporter` JSON) or `POST /api/bookmarks/import`. - **No `