$ show liketrek/TREK
TREK is a full-featured, self-hosted travel planning application built with NestJS (server) and React (client). It enables users to create trips, manage day-by-day itineraries, add places and reservations, track budgets, maintain packing lists, collaborate via real-time chat/notes/polls, and journal memories. The architecture is a monorepo with client, server, shared schemas, and a plugin SDK. Key capabilities include offline-first support via IndexedDB with a mutation queue, real-time WebSocket collaboration, MCP (Model Context Protocol) integration for AI tools, a plugin system with sandboxed RPC host, OAuth 2.1, OIDC SSO, passkeys, and a storage abstraction layer supporting local and S3 backends. The application is production-ready with extensive test coverage (Vitest, Playwright E2E, MSW mocks) and internationalization across 23 locales. The codebase demonstrates strong engineering practices: modular NestJS domains, Zod schema-first validation shared between client and server, idempotent mutation handling, and a well-designed plugin SDK with permission gating and digital signatures.
The LLM identified 6 files worth highlighting for reuse:
Provides idempotency guarantees for mutation endpoints by storing response keys and returning cached results for duplicate requests. Uses configurable storage backend (e.g., Map, Redis) and a cleanup job. Extracted and reusable in any NestJS API that requires idempotent mutation handling.
Manages a queue of offline mutations (create, update, delete) that are applied when connectivity is restored. Supports conflict detection via `_rev` timestamps, retry with exponential backoff, and rollback on failure. Isolated pattern suitable for any offline-first application with synchronous local cache and async server sync.
Encapsulates file storage behind a common interface with drivers for local filesystem, S3-compatible object stores, and a mirror driver. Handles key validation, path prefixing, content-type detection, and streaming. Testable via contract tests that run against any driver. Can be extracted as a standalone storage library.
Generates SVG markup for Lucide icons without requiring React or jsdom, enabling server-side or client-side rendering of icon sprites. Maintains byte-identical output to react-dom/server for all icons via parity tests. Useful for any project needing lightweight icon serialization outside the React render tree.
Sets up a Dexie IndexedDB database with typed tables for storing trip data locally. Includes schema versioning, composite indexes for efficient queries, and lifecycle management. Extracted as a single file that can be used in any offline-capable web app requiring local persistence.
Manages concurrent file uploads with a configurable concurrency limit, retry logic for transient failures, progress tracking, and cancellation via AbortController. Handles non-retryable errors (e.g., 413, 403) by failing immediately. Reusable in any web app that needs robust client-side file upload with backpressure.