# LinkSyncServer - Implementation Tasks ## Phase 1: Project Setup ### Setup Tasks - [x] Initialize git repository - [x] Configure git remote (gitea.blabber1565.com) - [x] Create directory structure - [x] Write README.md - [x] Write TODOs.txt - [x] Write design.md - [x] Write tasks.md - [x] Write AGENTS.md - [x] Create docker-compose.yml - [x] Create Dockerfile - [x] Create requirements.txt - [x] Create pyproject.toml - [x] Create .env.example ## Phase 2: Core Application ### App Configuration - [x] Create app.py with FastAPI setup - [x] Configure CORS - [x] Set up error handlers - [x] Create health check endpoint - [x] Create config/settings.py ### Database Setup - [x] Create models/base.py - [x] Create models/user.py - [x] Create models/link.py - [x] Create models/collection.py - [x] Create models/tag.py - [x] Create models/audit_log.py - [x] Configure SQLAlchemy engine - [x] Create schema.sql - [x] Set up Alembic migrations ### Authentication - [x] Create models for users/roles - [x] Implement password hashing (bcrypt) - [x] Create JWT token utilities - [x] Implement login endpoint - [x] Implement register endpoint - [x] Implement logout endpoint - [x] Create API key model and endpoints - [x] Set up session management ## Phase 3: API Endpoints ### Auth Endpoints - [x] POST /api/auth/register/ - [x] POST /api/auth/login/ - [x] POST /api/auth/logout/ - [x] POST /api/auth/api-key/ - [x] DELETE /api/auth/api-key/{key_id}/ ### Link Endpoints - [x] GET /api/links/ - list with pagination and filters - [x] GET /api/links/{id}/ - single link details - [x] POST /api/links/ - create link - [x] PUT /api/links/{id}/ - update link - [x] DELETE /api/links/{id}/ - delete link - [x] POST /api/links/{id}/tags/ - add tags - [x] DELETE /api/links/{id}/tags/ - remove tags ### Collection Endpoints - [x] GET /api/collections/ - list collections - [x] GET /api/collections/{id}/ - collection details - [x] POST /api/collections/ - create collection - [x] PUT /api/collections/{id}/ - update collection - [x] DELETE /api/collections/{id}/ - delete collection - [x] POST /api/collections/{id}/refresh/ - refresh dynamic collection - [x] POST /api/collections/{id}/add-links - add links to static collection - [x] DELETE /api/collections/{id}/remove-links - remove links from collection ### Query Endpoints - [x] POST /api/queries/parse/ - parse and validate query - [x] POST /api/queries/execute/ - execute query and return results - [x] GET /api/queries/{id}/ - get saved query ### Sync Endpoint - [x] POST /api/sync/ - sync with browser extension - [x] Implement sync mode logic - [x] Handle conflict resolution - [x] Process deletions ### Admin Endpoints - [x] GET /api/admin/users/ - list all users - [x] POST /api/admin/users/ - create user - [x] PUT /api/admin/users/{id}/ - update user - [x] DELETE /api/admin/users/{id}/ - delete user - [x] GET /api/admin/stats/ - system statistics - [x] GET /api/admin/audit/ - audit log ## Phase 4: Query Engine ### Parser - [x] Create tokenization logic - [x] Implement AST node classes - [x] Build parser with precedence rules - [x] Validate AST - [x] Serialize AST to JSON ### Executor - [x] Implement TermSet executor - [x] Implement TagFilter executor - [x] Implement FieldFilter executor - [x] Implement AND/OR/XOR operators - [x] Build SQL from AST - [x] Execute queries with full-text search ## Phase 5: Web Interface ### Layout - [x] Create templates/base.html - [x] Create templates/index.html - [x] Create navigation component - [x] Create CSS main.css ### Static Files - [x] Create static/css/main.css - [x] Create static/js/main.js ## Phase 6: Testing ### Unit Tests - [x] tests/test_auth.py - [x] tests/test_links.py - [x] tests/test_collections.py - [x] tests/test_queries.py ### Integration Tests - [x] Setup test database - [x] Test full registration flow - [x] Test CRUD operations - [x] Test sync endpoint - [x] Test query execution ## Phase 7: Docker & Deployment ### Docker - [x] Create optimized Dockerfile - [x] Configure health checks - [x] Test container build - [x] Test container run - [x] Test docker-compose ## Phase 8: Documentation - [x] API reference (via OpenAPI/Swagger) - [x] User guide (README.md) - [x] Query syntax guide (README.md) - [x] Deployment guide (README.md) ## Phase 9: Web Interface Enhancements ### Session Management - [x] Token expiry detection on page load - [x] 401 interceptor for all API calls - [x] Session expiry warning banner (<2 minutes) - [x] Graceful redirect to login on expiry - [x] Session expired message on login page ### Dashboard - [x] Stats display with numbers (never `-`) - [x] Quick actions grid - [x] Admin section visibility toggle - [x] Resilient stats loading (allSettled pattern) ### Links Page - [x] Simple search mode (keyword across all fields) - [x] Query mode toggle (set operations) - [x] Multi-word AND search - [x] Tag search inclusion - [x] Save as Collection feature (static and dynamic) - [x] Query preview with result count ### Collections Page - [x] Query builder UI for dynamic collections - [x] Query preview button - [x] Result count display - [x] Query expression display on cards - [x] Type selector toggles query section ### API Keys Page - [x] Create API key modal - [x] Delete API key confirmation ### Admin Page - [x] User CRUD interface - [x] Role assignment - [x] System statistics - [x] Audit log viewer ## Phase 10: Testing ### E2E Tests (Playwright) - [x] Install Playwright and pytest-playwright - [x] Auth flow tests (login, dashboard, logout, expiry) - [x] Link CRUD tests - [x] Search tests (simple, multi-word, by tag, query mode) - [x] Collection tests (static, dynamic with query, delete) - [x] Save as Collection tests (static and dynamic) - [x] API Key tests (create, delete) - [x] Admin tests (user management)