2.9 KiB
2.9 KiB
AGENTS.md - LinkSyncServer
Project Overview
LinkSyncServer is a self-hosted bookmark server with advanced collection and query capabilities. It provides a RESTful API and web interface for managing bookmarks (links), collections (static or dynamic sets), and supports synchronization with browser extensions.
Setup & Build Commands
- Build:
docker-compose up -d --build - Test:
pytest tests/ -v - Lint:
ruff check .&&mypy app.py models/ - Dev:
docker-compose up web - Migrate:
alembic upgrade head
Architecture Notes
Core Components
- Authentication Layer: JWT-based auth with admin/regular user roles
- Link Management: CRUD for links with all Firefox bookmark fields
- Collection Engine: Static and dynamic collections with query support
- Query Parser: Expression parser supporting AND/OR/XOR set operations
- Sync Protocol: Extension sync endpoint with conflict resolution
Data Models
- User: Authentication and authorization
- Link: Bookmark with all Firefox fields
- Collection: Static or dynamic set of links
- Tag: Optional categorization
- AuditLog: Track changes
Query Engine
Query syntax: ('term1', 'term2') OR tagA AND tagB XOR url:example.com
- Precedence:
()> XOR > AND > OR - Left-to-right evaluation otherwise
- Full-text search via PostgreSQL tsvector
Testing Protocol
- All tests must pass before committing
- Run
pytest tests/ -vfor full test suite - Coverage target: >80%
- E2E tests cover critical user flows
Conventions
File Naming
- Models:
{entity}.pyinmodels/directory - Endpoints:
endpoints/{resource}.py - Queries:
queries/{operation}.py
Error Handling
- Use HTTP status codes appropriately
- Return structured error responses
- Log errors with stack traces in debug mode
API Design
- RESTful conventions
- JSON responses with Content-Type
- Paginated lists with limit/offset
- OpenAPI documentation via
@openapi
Database
- UUID primary keys
- Timestamps on all records
- Foreign keys with cascade delete where appropriate
- Full-text search indexes on searchable fields
Known Issues / Technical Debt
- None at initialization
- Query engine performance to be optimized
- Caching layer to be implemented
Project-Specific Tools
- Query Parser:
queries/parser.py - Query Executor:
queries/executor.py - Sync Logic:
api/endpoints/sync.py
Related Files
README.md- Overview and quick startdesign.md- Architecture and API detailstasks.md- Implementation checklistdocker-compose.yml- Deployment configuration
Admin User Creation
Admin user is created from environment variables:
ADMIN_USERNAMEADMIN_PASSWORDSECRET_KEY(generate securely)
Admin can create:
- Regular users
- Admin users
- API keys
- System settings
Security Notes
- Never commit
.envfiles - Use strong passwords
- Rotate SECRET_KEY periodically
- Enable HTTPS in production