How fergana-labs/stash works
1. This is a multi-surface product, not a single app. The repo contains the core backend, an authenticated web app, a public marketing site, a Python CLI, agent plugins, a browser extension, a collab service, and a separate PowerPoint export service. The main architectural idea is “agent memory + content store + integrations.”
2. The central backend is the system of record. The backend/ Python service owns users, workspaces/content, sessions, files, pages, tables, shares, comments, skills, sources, integrations, and audit/security features. Its structure is split into routers/ for HTTP endpoints, services/ for business logic, models.py, and migrations/ for schema evolution.
3. Persistence is relational, with explicit schema history. The long Alembic migration chain shows the backend’s data model has evolved around entities like sessions, files, pages, share links, integrations, permissions, embeddings, trash, and skills. The architecture is clearly database-centric, with migrations capturing product evolution and reserved fields for future workflows.
4. Async background work is a major subsystem. backend/celery_app.py, backend/tasks/, and backend/workers/ handle delayed jobs such as extraction, embeddings, source sync, session title generation, visualization updates, and other heavy processing. This keeps ingestion and indexing off the request path.
5. Ingestion flows from agents into the backend through hooks and uploads. The stashai/plugin/ package and the multiple plugins/* directories adapt to Claude, Cursor, Codex, OpenCode, Gemini, Openclaw, and others. These plugins capture prompts, tool use, session start/end, and transcript events, then upload session data back to the backend. The README’s “sessions stream in automatically” path is the core data flow.
6. The CLI is an operational client, not just a thin wrapper. cli/ exposes sign-in, repo connection, VFS browsing, importing history, sharing/upload helpers, and MCP-server integration. It acts as the agent/operator interface for reading and writing Stash content locally and remotely.
7. Search, “ask,” and filesystem-style access sit on top of the content store. The backend has services for embeddings, file search, memory, session browsing, user knowledge, and tool-loop/ask flows. The product behavior is to let agents query Stash like a persistent filesystem, with semantic and keyword retrieval spanning sessions, files, pages, and tables.
8. Integrations are a separate adapter layer with providers, indexers, and importers. backend/integrations/ is organized by source system: GitHub, Slack, Gmail, Google, Notion, Jira, Linear, Gong, Asana, Granola, Telegram, Twitter, and more. Each integration typically has a provider, an indexer, and sometimes importers/exporters or sync helpers, which means external data is normalized before it lands in the core store.
9. Content rendering and export are their own subsystem. backend/exports/ contains HTML/canvas and native PowerPoint generation logic, including PPTX builders, layout probing, rasterization, and Playwright/network helpers. There is also a separate powerpoint-mcp/ service, indicating that slide generation is packaged as a specialized export/runtime boundary rather than embedded in the main app.
10. The authenticated UI and the public site are separate frontends. frontend/ is the app for signed-in users: files, folders, sessions, skills, integrations, tables, memory, trash, settings, and onboarding. www/ is the marketing/docs site with landing pages, blog, docs, public page rendering, contact flows, and lightweight public APIs for pages/comments/track. They share branding and some auth overlay logic, but they serve different audiences and routes.
11. Collaboration and sharing are first-class product boundaries. The backend includes permissions, shares, invite tokens, public/private publish state, comments, pinning/recents, and trash. The collab/ service and frontend comment/editing components indicate live collaboration or document coordination is handled alongside the main content model rather than as an afterthought.
12. Auth and secrets are layered around the core app. There is a normal self-hosted path plus a “managed” Auth0 overlay in both backend and frontend. OAuth tokens for integrations are encrypted server-side, and the README emphasizes optional LLM usage, opt-in transcript uploads, and private-by-default visibility.
13. Deployment is containerized and proxy-fronted. Docker Compose is the primary self-host story, with a Caddy reverse proxy for public HTTPS deployments. GitHub Actions handle testing, publishing, and versioning, so the operational diagram should include build/test/release automation around the runtime services.
Main entry points: main.py API app · services Domain services · (app) App UI · docker-compose.yml Docker stack
Components 21
Core platform
Backend system of record, async processing, integrations, and export services.
- API app · Main backend entrypoint and application wiring.
backend/main.py - HTTP routers · Endpoint surface for files, sessions, shares, skills, integrations, tasks, and more.
backend/routers - Domain services · Core workflows for memory, search, permissions, ask, sessions, files, comments, and sharing.
backend/services - Data models · Relational model definitions for the product’s content and account data.
backend/models.py - Schema history · Evolution of the database schema over product generations.
backend/migrations/versions - Job runner · Background queue and worker setup for heavy processing and delayed work.
backend/celery_app.py - Async tasks · Embeddings, extraction, source sync, titles, and visualization jobs.
backend/tasks - Integrations · Provider/indexer/importer adapters for external systems such as GitHub, Slack, Gmail, Notion, Jira, Linear, and others.
backend/integrations - Export engine · HTML, canvas, PDF, and native PowerPoint generation pipeline.
backend/exports - PPT runtime · Separate service boundary for specialized slide generation and session management.
powerpoint-mcp/src
Client surfaces
Authenticated web app, public site, CLI, browser extension, and plugins.
- App UI · Authenticated product surface for files, sessions, skills, integrations, memory, and settings.
frontend/src/app/(app) - UI components · Shared editor, browser, collaboration, sharing, export, and visualization components.
frontend/src/components - Public site · Marketing, docs, blog, public pages, and lightweight public APIs.
www/app - CLI client · Local command-line interface for sign-in, VFS browsing, imports, sharing, and MCP integration.
cli - Plugin runtime · Shared agent hook and upload runtime used by plugins and agent adapters.
stashai/plugin - Agent plugins · Claude, Cursor, Codex, Gemini, OpenCode, OpenClaw, and related adapters.
plugins - Browser extension · In-browser capture and sync surface for agent/chat sessions.
chrome_extension - Collab service · Dedicated collaboration/runtime boundary for shared editing and coordination.
collab/src/server.ts
Operations
Container, proxy, release, and deployment automation.
- Docker stack · Local and production container orchestration and proxy setup.
docker-compose.yml - Edge proxy · Public HTTPS reverse proxy and routing layer.
Caddyfile - Release CI · Test, publish, and versioning workflows for the repository.
.github/workflows
Connections 26
- API app → HTTP routers: mounts · App wires all HTTP surfaces through routers.
- API app → Domain services: uses · Request handlers delegate to domain services.
- HTTP routers → Domain services: calls · Routers translate API requests into service workflows.
- Domain services → Data models: persists · Services operate on relational records and content objects.
- Data models → Schema history: evolves via · Schema changes are tracked through Alembic history.
- Domain services → Async tasks: enqueues · Heavy work is pushed to asynchronous jobs.
- Job runner → Async tasks: runs · Celery worker/process orchestration executes task modules.
- Integrations → Domain services: ingests to · External data is normalized before landing in core storage.
- Integrations → Async tasks: syncs via · Integration sync and indexing use background jobs.
- Export engine → PPT runtime: delegates · Specialized slide generation can be handled by a separate runtime.
- App UI → API app: reads/writes · Authenticated UI talks to the backend API.
- UI components → App UI: compose · Reusable UI pieces power the app surface.
- Public site → API app: public api · Public pages, comments, and tracking coordinate with backend services.
- CLI client → API app: syncs · CLI authenticates and exchanges content with the backend.
- CLI client → Plugin runtime: shares client flows · CLI and plugin ecosystems overlap on uploads and agent tooling.
- Plugin runtime → API app: uploads · Captured sessions and transcripts stream into the backend.
- Agent plugins → Plugin runtime: use · Individual agent adapters reuse the shared hook/upload runtime.
- Browser extension → API app: syncs · Extension captures browser-side agent activity and uploads it.
- Collab service → App UI: supports · Collaboration features surface through the authenticated UI.
- Docker stack → API app: orchestrates · Compose stack deploys the backend and adjacent services.
- Docker stack → App UI: orchestrates · Compose stack deploys the app frontend.
- Docker stack → Public site: orchestrates · Compose stack deploys the public site.
- Edge proxy → Public site: fronts · Reverse proxy terminates HTTPS and routes public traffic.
- Edge proxy → App UI: fronts · Reverse proxy also serves the authenticated frontend.
- Release CI → Docker stack: builds · CI publishes and validates containerized deployments.
- Release CI → Agent plugins: publishes · Workflows bump and release plugin packages.