$ show usememos/memos
Memos is a self-hosted, full-stack memo/note-taking application with a Go backend and React/TypeScript frontend. It provides rich features including markdown editing with inline images and math, attachment management (images, video, audio, motion photos), spaces for collaboration, calendar and map views, AI-powered audio transcription, webhooks, SSO/OAuth2 identity providers, and a CEL-based filter engine for advanced querying. The architecture is layered with enforced import rules: internal utilities, provider interfaces (AI, storage, IDP), core business logic, a store layer with driver abstraction supporting SQLite, MySQL, and PostgreSQL, and a server layer exposing ConnectRPC/gRPC and HTTP APIs. The frontend uses CodeMirror 6 for the editor, TanStack Query for data fetching, and extensive custom hooks and UI primitives. The codebase is well-tested with unit, integration, and benchmark tests across both backend and frontend. Notable engineering highlights include a custom Common Expression Language (CEL) engine that compiles user-defined filters to SQL, a sliding window rate limiter, a thread-safe in-memory cache with TTL, and a protocol abstraction layer that transparently handles gRPC and ConnectRPC headers.
The LLM identified 5 files worth highlighting for reuse:
Compiles user-defined CEL (Common Expression Language) expressions into SQL WHERE clauses for memo filtering. Supports functions like `now()`, `duration()`, `size()`, `sets.contains()`, and `exists_one()`. The engine is self-contained, implements a recursive descent parser, and can be extracted for any project needing safe, user-facing query compilation with custom function support.
Provides a unified `HeaderCarrier` that abstracts gRPC metadata and HTTP headers, allowing ConnectRPC service methods to work identically under both protocols without importing gRPC or HTTP packages directly. A small, self-contained pattern that eliminates dual-protocol boilerplate.
Implements a sliding window rate limiter with per-key buckets, concurrency safety via mutex, and capacity-based eviction. Exposes a clean interface (`Allow(key) bool`) with configurable window duration and max requests. Reusable as a standalone package for any Go service needing server-side rate limiting.
A thread-safe, generic in-memory cache with TTL support, maximum item limit, and optional eviction callback. Uses a map of linked list nodes for O(1) operations and a periodic cleanup goroutine. The interface is minimal (`Get`, `Set`, `Delete`, `Clear`), making it easily extractable for any Go application needing caching.
Provides `searchMatch` for case-folded substring matching with a tie-breaking algorithm that prefers matches closer to the start of the string, and `highlightHTML` that returns an array of `[offset, length]` ranges for use with the CSS Custom Highlight API. Pure TypeScript, no dependencies, reusable in any frontend project requiring client-side search highlighting.