MCPSERV.CLUB
Anchr

Anchr

Self-Hosted

Your personal web toolbox for bookmarks, links, and encrypted images

Active(81)
351stars
0views
Updated 24 days ago

Overview

Discover what makes Anchr powerful

Anchr is a lightweight, self‑hosted toolbox that bundles three core web utilities—link shortening, bookmark management, and encrypted image hosting—into a single Express‑based service. At its heart, Anchr exposes a RESTful API that mirrors the UI experience: endpoints for creating short links (`POST /api/shorten`), managing collections of bookmarks (`GET/POST /api/bookmarks`), and uploading images (`POST /api/images`). Each resource is persisted in a PostgreSQL database, accessed through the `knex` query builder. The application’s front‑end is a single‑page React app built with Vite, which communicates with the API via Axios. The server also serves static assets from a `/public` directory and injects an OAuth 2 client configuration that supports Google, Facebook, and generic OpenID Connect providers.

Short Links

Bookmarks

Image Uploads

Safe Browsing

Overview

Anchr is a lightweight, self‑hosted toolbox that bundles three core web utilities—link shortening, bookmark management, and encrypted image hosting—into a single Express‑based service. At its heart, Anchr exposes a RESTful API that mirrors the UI experience: endpoints for creating short links (POST /api/shorten), managing collections of bookmarks (GET/POST /api/bookmarks), and uploading images (POST /api/images). Each resource is persisted in a PostgreSQL database, accessed through the knex query builder. The application’s front‑end is a single‑page React app built with Vite, which communicates with the API via Axios. The server also serves static assets from a /public directory and injects an OAuth 2 client configuration that supports Google, Facebook, and generic OpenID Connect providers.

Technical Stack

LayerTechnologyRationale
RuntimeNode.js 21.x + ExpressMature ecosystem, async I/O suited for HTTP APIs
DatabasePostgreSQL (via Knex)ACID compliance, JSONB support for flexible metadata
Front‑endReact + ViteFast build, modern component model, easy integration with browser extensions
EncryptionCryptoJS (client‑side)Zero‑trust uploads: image data is encrypted before leaving the browser
SecuritySafe Browsing API, Helmet, CSP headersPrevent phishing, enforce strict security policies
MetricsPrometheus endpoint (/metrics)Exposes request latency, error rates for ops teams
ExtensionsChrome/Firefox WebExtension (webext)Seamless “Save to Anchr” or “Shorten link” from the browser context menu
CI/CDGitHub Actions (not shown)Automated tests, Docker image builds

Anchr’s codebase is intentionally small—under 5 kB of source after minification—making it trivial to audit and modify. The server follows a classic MVC pattern: routers → controllers → services → repositories, with dependency injection via simple factory functions. All secrets (DB password, OAuth client IDs) are read from environment variables, and the Dockerfile exposes only a single port (3000), ready for deployment behind a reverse proxy.

Core Capabilities & APIs

  • Short LinksPOST /api/shorten accepts a long URL and optional custom slug; returns a short URL that redirects via a catch‑all route. Internally, URLs are stored with a hash field (generated by crypto.randomBytes(4).toString('hex')) and a visits counter. A background job (node‑cron) updates visit statistics and purges stale links.
  • Bookmarks – CRUD endpoints (/api/bookmarks) support tagging, description, and categorization into collections. The API returns a full bookmark tree on GET /api/bookmarks, enabling instant UI rendering.
  • Image UploadsPOST /api/images accepts multipart form data. The server streams the file to disk, stores metadata (size, MIME type, upload timestamp), and returns a signed URL that the client can use to download. If the client sends an encryption key, the image is stored encrypted; decryption occurs on the fly when the file is served.
  • Safe Browsing – Every link creation triggers an async lookup against Google’s Safe Browsing API; malicious URLs are rejected with a 400 status code.
  • OAuth – The /auth routes use passport.js strategies for Google, Facebook, and generic OIDC. Tokens are stored in the database and refreshed automatically.

Deployment & Infrastructure

Anchr is container‑first. The official Docker image (muety/anchr) pulls the latest Node.js LTS, installs dependencies, and starts the Express server. The image exposes only port 3000, so a lightweight reverse proxy (NGINX, Caddy) can add TLS termination and HTTP/2. For scaling, the stateless nature of the API means you can run multiple replicas behind a load balancer; PostgreSQL is the only shared state, so standard replication or Patroni setups work out of the box. The Prometheus endpoint allows you to monitor latency, request counts, and error rates; Grafana dashboards can be built from the exported metrics.

Integration & Extensibility

  • Browser Extensions – The Chrome/Firefox extension ships as a separate package (webext) that communicates with the API via chrome.runtime.sendMessage. It can be embedded into any web page as a bookmarklet, providing “Save to Anchr” functionality without leaving the current tab.
  • ShareX Integration – ShareX’s “Custom Uploaders” can point to the /api/images endpoint, automatically encrypting images client‑side before upload.
  • Telegram Bot – The @AnchrBot forwards messages to the API; developers can hook into bot commands (e.g., /shorten, /bookmark) to automate workflows.
  • Webhook Support – While not yet fully documented, the API can be extended to emit events (link created, image uploaded) via webhooks. A simple POST /api/webhook endpoint can be added to trigger downstream services.
  • Plugin System – Currently minimal, but the architecture allows adding new routes or middleware without touching core code. For example, a custom analytics plugin could hook into the request lifecycle.

Developer Experience

Anchr ships with comprehensive TypeScript type definitions for both client and server, making it easy to integrate

Open SourceReady to get started?

Join the community and start self-hosting Anchr today