How faraday-fm/faraday works
Project type and purpose
• This is a monorepo for a single-page web application (“Faraday File Manager”) delivered via apps/faraday-fm.github.io.
• It uses a plugin/extension architecture: core UI (packages/web-ui), a browser-based in-memory file system (packages/memory-fs), a Web Worker–based extension host (packages/extension-host), command infrastructure (packages/commands), and shared SDK utilities (packages/sdk).
• The README describes an interactive, dual-pane file manager with file previews, custom themes, keyboard shortcuts, and built-in tools.
File structure
• Top-level “apps” holds the deployed SPA; “extensions” holds example viewer plugins (code, image, text); “packages” holds internal libraries.
• Key packages:
• web-ui: React components, contexts, feature hooks
• commands: command palette, keyboard shortcuts, provider/registry
• extension-host: worker entrypoint, message protocols, extension loading
• memory-fs: in-browser virtual file system
• sdk: file system API wrappers, error types, event types
• Config files: pnpm-workspace.yaml, turbo.json for monorepo orchestration; tsconfig and build configs for each package.
README for additional insights
• Faraday is purely client-side, no separate backend. The memory-fs simulates a file system entirely in browser memory or via WebSocket (wsfs.ts).
• Extensions live inside a virtual “.faraday” directory and are loaded into the extension host at runtime.
• The UI interacts with file system services and commands, and offloads extension code execution to a Web Worker.
a. Main components
• Browser / Client
• Faraday SPA (apps/faraday-fm.github.io)
• Web-UI component library (packages/web-ui)
• FS Service (src/services/fs.ts) + optional WSFS Service (wsfs.ts)
• Commands Provider (packages/commands)
• Extension Manager (feature hooks in web-ui)
• Extension Host (Web Worker) (packages/extension-host)
• In-Memory File System (packages/memory-fs)
• SDK Utilities (packages/sdk)
• Extensions (extensions/code-viewer, image-viewer, text-viewer)
b. Relationships & interactions
• SPA imports web-ui and commands libraries, mounts React root.
• FS Service calls into memory-fs API to read/write files; optionally uses WebSocket to a remote FS.
• Commands Provider registers keyboard shortcuts and exposes a command palette to UI.
• On demand, the SPA spins up a Web Worker running extension-host; communicates via postMessage.
• Extension-host loads extensions from the virtual FS, initializes them using sdk, and responds to messages (e.g., “render preview”).
• The SPA receives extension-host messages and renders output in appropriate viewer components.
c. Architectural patterns & principles
• Plugin architecture via extension host in a Web Worker.
• Command pattern for keyboard shortcuts and actions.
• React context providers for global state (file system, theme, settings).
• Monorepo with shared TypeScript configs and build scripts for efficiency.
• Separation of concerns: UI vs. file system vs. extension execution.
d. Key technologies & frameworks
• React + TypeScript + Vite (apps/faraday-fm.github.io)
• Lit-Contexts (web-ui) for lightweight context management
• Web Worker for isolation of untrusted extension code
• pnpm & TurboRepo for monorepo orchestration
• tsup/Rollup for bundling libraries
Detail without clutter
• Break the system into: Client App, UI Library, FS Subsystem, Extension Host, Extensions.
• Interface/interaction: React→Context→Command Registry→Worker.
• Don’t forget build/dev tools (pnpm, turbo.json, tsconfig) as an ancillary layer if desired.