How johnconnor-sec/fabric works
Project type and purpose
• This is a full-stack, open-source AI-augmentation framework (“fabric”) written in Go, with:
• A command-line interface (CLI) for invoking “Patterns” (prompt templates)
• A plugin system for AI providers, databases, and template engines
• A REST API server that exposes pattern execution over HTTP
• A Svelte-based web GUI
• A Streamlit UI for rapid prototyping
File structure
• Root contains Dockerfile, docker-compose.yml, main.go, and version.go → the entrypoint for both CLI and API server.
• /cli → Go code for command parsing, flags, and CLI commands.
• /common → Shared domain types and utilities.
• /core → Core engine: “chatter” orchestrates pattern execution; plugin_registry loads AI, DB, template plugins.
• /plugins → Four subpackages:
• ai → adapters for OpenAI, Anthropic, Gemini, etc.
• db → file-system DB (fsdb) for contexts, patterns, sessions.
• template → text/template extensions and custom functions.
• tools → helper apps (e.g., to_pdf).
• /restapi → HTTP handlers for chat, patterns, sessions, storage and exposes “fabric --serve”.
• /patterns → Markdown-based pattern definitions (system.md, user.md) organized by pattern name.
• /web → Svelte front-end:
• /src/lib/api → REST client wrappers
• /src/lib/components → UI components (Chat, Patterns, Posts, Settings)
• /src/lib/services and /src/lib/store → state management and business logic
• /routes → page endpoints served by SvelteKit
• streamlit.py → Python Streamlit UI alternative
Extract insights from README
• Patterns are central: loaded from disk via the DB plugin, executed by core.chatter → plugin_registry → AI plugins → returns structured Markdown.
• The web GUI uses fabric --serve (REST API) to power chat and pattern browsing/editing.
• CLI, Web UI, and Streamlit share the same core engine and plugin system.
Main components
A. Clients
• CLI executable (fabric)
• REST API consumers (Svelte web GUI, Streamlit UI, external HTTP clients)
• Helper binaries (to_pdf, other tools)
B. Core Engine
• main.go → initializes CLI or API server
• core.chatter → orchestrates pattern execution
• plugin_registry → dynamically discovers and loads plugins
C. Plugins
• AI providers (OpenAI, Anthropic, Gemini, etc.)
• DB plugin (fsdb) for storing patterns, contexts, sessions
• Template plugin for text transformations
• Tools plugin for command-line utilities
D. Patterns Storage
• /patterns directory (built-in)
• User patterns in ~/.config/fabric/patterns
E. Data Stores
• File system (via fsdb)
F. External Services
• LLM APIs (OpenAI, Azure, Anthropic…)
• YouTube API (for transcripts)
• Obsidian or other MD vaults (optional)
Relationships & data flow
1. User invokes CLI or Web/Streamlit → passes pattern name + input
2. main.go routes to core.chatter
3. core.chatter loads the pattern from fsdb via plugin_registry
4. core.chatter calls AI plugin(s) to execute the prompt
5. AI plugin communicates with external LLM service
6. Response flows back through core → CLI writes to stdout / file OR REST API returns JSON
7. Web GUI/Streamlit consumes REST endpoints to display and manage sessions
8. Tools plugin (e.g., to_pdf) can be chained on CLI output
Architectural patterns & design principles
• Plugin Architecture: decouples core engine from AI, database, template, and tool implementations
• Modular layering:
• Presentation layer (CLI, REST API, Web, Streamlit)
• Application layer (core.chatter, plugin_registry)
• Infrastructure layer (plugins for AI, DB, templates)
• Configuration-as-code: patterns are Markdown files, discovered at runtime
• Single-codebase polyglot front-end: SvelteKit for web, Python for Streamlit, Go for core
Relevant technologies & frameworks
• Go: CLI, core engine, REST server
• fsdb (Go-based file-system DB)
• SvelteKit + TypeScript + Tailwind: web GUI
• Python + Streamlit: alternate UI
• Docker/Nix: containerization & reproducible builds