Technical Documentation: nanbingxyz/5ire
βΉοΈ Provenance: Multi-Tier Ingestion Β· CodeWiki Reference
Overview (`README.md`)
OpenAI
/ Azure
/ Anthropic
/ Google
/ Mistral
/ Doubao
/ Grok
/ DeepSeek
/ Ollama
[Twitter](https://x.com/intent/follow?screen_name=1ronben)
Β·
[Releases](https://github.com/nanbingxyz/5ire/releases/latest)Before to activating tools feature, ensure the following components are installed:
- Python
- Node.js
- uv (Python package manager)
These components are required as they constitute the runtime environment for the MCP Server. If you don't anticipate using the tools feature immediately, you may choose to skip this installation step and complete it later when the need arises.
For detailed installation instructions, please see our Installation Guide.
πͺ Getting involved
If you want to contribute code to 5ire or develop your own apps based on 5ire, start with the Development Setup Guide.
Visit Wiki for more details.
π To integrate 5ireβs one-click server installation into your website, see the One-Click Server Installation Integration Guide.
π¬ Community
Join the Discord, By joining, youβll get:
- Faster responses to your questions and issues
- Direct input on new features and improvements
- A place to share ideas, tips, and feedback with other 5ire users
- Opportunities to co-build and shape the future of 5ire together
Features
βοΈ Support Tools via MCP Servers
MCP is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications. Just as USB-C provides a standardized way to connect your devices to various peripherals and accessories, MCP provides a standardized way to connect AI models to different data sources and tools.
With tools, you can access the file system, obtain system information, interact with databases, access remote data, and more, rather than just having a simple conversation.
https://github.com/user-attachments/assets/5aa98f2b-c26d-435e-8196-73fa414066eb
We have created an open marketplace for MCP Servers. it empowers users to discover exceptional tools while offering a streamlined process for sharing their own MCP server creations.
https://github.com/user-attachments/assets/be66c30e-bb29-4dfe-9f25-8d396470ed60
π‘ Local Knowledge Base
We have integrated the bge-m3 as our local embedding model, which excels in multilingual vectorization. 5ire now supports parsing and vectorization of docx, xlsx, pptx, pdf, txt, and csv documents, enabling storage of these vectors to power robust Retrieval-Augmented Generation (RAG) capabilities locally.
π Usage Analytics
By keeping track of your API usage and spending, you can gain a better understanding of how much you're spending on the API and make informed decisions to optimize your use of the service.
β¨ Prompts Library
The prompt library provides an effective way to create and organize your own prompts. These prompts are highly versatile, thanks to their support for variables.
π Bookmarks
You can bookmark each conversation, and even if the original messages are deleted, the saved bookmarked content remains unaffected.
π Quick Search
You can perform keyword searches across all conversations, quickly pinpointing the information you need.
[!TIP]
Since 5ire uses native dependencies, it needs to be packaged on the corresponding platform. If it is on Mac OS, you may also need to configure APPLE_TEAM_ID, APPLE_ID, and APPLE_ID_PASS for notarization to avoid security alerts.
Discover Exceptional MCP Servers
MCPSvr, a community-driven directory of MCP servers, empowers developers to discover exceptional tools while offering a streamlined process for sharing their own MCP server creations.
ARCHITECTURE (`docs/ARCHITECTURE.md`)
Architecture
Technical architecture documentation for 5ire, an Electron-based AI assistant with MCP integration and local knowledge base capabilities.
High-Level Architecture
5ire is built on Electron's dual-process architecture, separating system-level operations from the user interface.
Process Model
Main Process (Node.js)
- Manages application lifecycle and native system APIs
- Handles file I/O, SQLite database operations, and document processing
- Runs MCP servers and manages their lifecycle
- Executes the embedding model for the knowledge base
- Processes IPC requests from the renderer
Renderer Process (Chromium + React)
- Runs the React/TypeScript UI application
- Manages application state with Zustand stores
- Communicates with the main process via IPC bridge
- Handles user interactions and real-time streaming responses
Preload Scripts
- Secure bridge between main and renderer processes
- Exposes controlled IPC channels to the renderer
- Prevents direct Node.js access from the renderer for security
Application Layers
βββββββββββββββββββββββββββββββββββββββ
β Presentation Layer (React) β
β Components, Pages, State Stores β
βββββββββββββββββββββββββββββββββββββββ
β IPC
βββββββββββββββββββββββββββββββββββββββ
β Service Layer (Main) β
β Chat Services, MCP Client, RAG β
βββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββ
β Data Layer β
β SQLite, File System, Vector Store β
βββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββ
β Integration Layer β
β AI Provider APIs, MCP Servers β
βββββββββββββββββββββββββββββββββββββββTechnology Stack
Frontend
- React 18 with TypeScript for type safety
- Fluent UI component library for consistent design
- SCSS for styling with CSS modules
- Zustand for lightweight state management
- i18next for internationalization
Backend (Main Process)
- Electron for cross-platform desktop capabilities
- Node.js runtime environment
- SQLite (better-sqlite3) for local data persistence
Key Dependencies
@modelcontextprotocol/sdk- MCP protocol implementationmammoth,xlsx,pdf-parse- Document parsing librariesmarkdown-it- Markdown rendering with custom pluginselectron-store- Persistent configuration storageelectron-updater- Auto-update functionality
Directory Structure
src/
βββ main/ # Electron main process
β βββ main.ts # Application entry point
β βββ mcp.ts # MCP server management
β βββ knowledge.ts # Knowledge base operations
β βββ embedder.ts # Embedding model interface
β βββ sqlite.ts # Database operations
β βββ docloader.ts # Document loading utilities
βββ renderer/ # React application
β βββ App.tsx # Root component
β βββ pages/ # Page components
β βββ components/ # Reusable UI components
β βββ stores/ # Zustand state stores
βββ intellichat/ # AI chat implementation
β βββ services/ # Provider-specific chat services
β βββ readers/ # Stream response readers
βββ providers/ # AI provider configurations
βββ types/ # TypeScript type definitions
βββ utils/ # Shared utilities
βββ hooks/ # React custom hooksCore Components
Chat System
The chat system uses an abstract service pattern to support multiple AI providers through a unified interface.
IChatService Interface
interface IChatService {
context: IChatContext;
provider: IServiceProvider;
apiSettings: { base: string; key: string; model: string };
chat({ message, onMessage, onComplete, onError }): void;
abort(): void;
isReady(): boolean;
}Each provider (OpenAI, Anthropic, Google, etc.) implements this interface with provider-specific logic for:
- Request formatting
- Streaming response handling
- Error management
- Token counting
Chat Readers
Stream readers parse provider-specific response formats (SSE, JSON streams) and normalize them into a consistent message format for the UI.
Context Management
- System prompts define AI behavior
- Conversation history maintains context
- Knowledge base integration injects relevant documents
- MCP tools provide additional capabilities
MCP Integration
The Model Context Protocol (MCP) enables standardized tool integration.
MCP Client (src/main/mcp.ts)
- Manages connections to multiple MCP servers
- Supports both local (stdio) and remote (HTTP/SSE) servers
- Handles server lifecycle (activation, deactivation, reconnection)
- Implements timeout and retry logic for reliability
Transport Types
StdioClientTransport- Local servers via stdin/stdoutSSEClientTransport- Remote servers via Server-Sent EventsStreamableHTTPClientTransport- Remote servers via HTTP streaming
Tool Discovery and Execution
- Client connects to MCP server on activation
- Server capabilities are queried (tools, prompts, resources)
- Tools are listed and made available to AI models
- AI requests tool execution during conversation
- Tool calls are validated against approval policy
- Results are returned to AI for continued processing
Configuration
MCP servers are configured in mcp.json with:
- Command and arguments for local servers
- URL and headers for remote servers
- Environment variables and proxy settings
- Activation state and capabilities
Knowledge Base (RAG)
The knowledge base implements Retrieval-Augmented Generation using local embeddings.
Document Processing Pipeline
- User selects documents (docx, xlsx, pptx, pdf, txt, csv)
- Documents are parsed into text chunks
- Chunks are embedded using local bge-m3 model
- Embeddings are stored in SQLite with metadata
- Documents are organized into collections
Embedding Service (src/main/embedder.ts)
- Runs local bge-m3 model via node subprocess
- Supports multilingual text (90+ languages)
- Generates 1024-dimensional embeddings
- Processes documents in batches for efficiency
Retrieval Process
- User message is embedded using same model
- Vector similarity search finds relevant chunks
- Top-k chunks are retrieved with metadata
- Context is injected into chat prompt
- AI generates response with retrieved knowledge
Storage
- Document metadata in SQLite
- Embeddings stored as binary blobs
- Collections organize related documents
- Chunk references maintain document structure
Provider System
The provider system abstracts differences between AI providers.
Provider Configuration
Each provider defines:
- API endpoints and authentication
- Supported models and capabilities
- Request/response formats
- Token limits and pricing
Capability Detection
- Vision support (image inputs)
- Tool calling (function execution)
- Streaming responses
- JSON mode
- System prompts
Model Management
- Users configure API keys per provider
- Models are selected per conversation
- Settings include temperature, max tokens, etc.
- Usage is tracked per provider and model
Data Flow
Chat Message Flow
User Input (Editor)
β
IPC: chat-message
β
Chat Service (Main Process)
β
Prepare Request:
- Load conversation context
- Inject knowledge if enabled
- Add available MCP tools
β
HTTP Request to AI Provider
β
Stream Response via Reader
β
IPC: stream-data events
β
UI Update (Real-time)
β
Save to SQLite
β
Update Usage StatisticsKnowledge Base Query Flow
User Message
β
Check if knowledge is enabled
β
Embed message (Node subprocess)
β
Vector similarity search (SQLite)
β
Retrieve top-k chunks
β
Format as context
β
Inject into system prompt
β
Send to AI provider
β
AI generates response with contextMCP Tool Execution Flow
AI requests tool execution
β
Parse tool call from response
β
Check approval policy
- Auto: execute immediately
- Manual: request user approval
β
IPC: mcp-call-tool
β
MCP Client routes to server
β
Server executes tool
β
Result returned to client
β
Result sent back to AI
β
AI continues with tool resultKey Subsystems
IPC Communication
Extensive IPC handlers in src/main/main.ts enable renderer-main communication:
request- Generic HTTP requests with proxy supportmcp-*- MCP server management and tool executionknowledge-*- Document import and searchencrypt/decrypt- Secure credential storageget-store/set-store- Persistent settings
Authentication & Sync
Optional Supabase integration provides:
- User account management
- Settings backup across devices
- OAuth authentication flow
- Offline-first design (works without an account)
Analytics
Usage tracking system monitors:
- API calls per provider and model
- Token consumption and costs
- Feature usage patterns
- Optional telemetry via Axiom
Settings Management
Electron-store persists user preferences:
- Appearance (theme, language)
- Provider API keys and models
- MCP server configurations
- Knowledge base settings
- Chat preferences
Architecture Decisions
Why Electron?
- Cross-platform desktop application (Windows, macOS, Linux)
- Access to native APIs (file system, system info)
- Ability to run local models for embeddings
- Rich UI with web technologies
- Offline-capable with local data storage
Why Local Embeddings?
- Privacy: Documents never leave the device
- Offline: No internet required for the knowledge base
- Cost: No API fees for embeddings
- Multilingual: bge-m3 supports 90+ languages
- Control: Full control over the embedding process
Why MCP?
- Standardization: Open protocol for tool integration
- Extensibility: Add tools without modifying core code
- Community: Growing ecosystem of MCP servers
- Security: Controlled execution with approval policies
- Flexibility: Support both local and remote tools
Why Multiple Providers?
- Choice: Users select preferred AI provider
- Fallback: Switch providers if one is unavailable
- Cost: Optimize spending across providers
- Capabilities: Access different model strengths (vision, reasoning, speed)
Why SQLite?
- Embedded: No separate database server required
- Fast: Efficient for local queries
- Reliable: ACID transactions
- Portable: Single file database
- Vector Support: Store embeddings as blobs
Security Considerations
- Preload scripts limit renderer access to Node.js APIs
- API keys encrypted at rest using system keychain
- External URLs validated before opening
- MCP tool execution requires approval policies
- Certificate validation for HTTPS requests
- Proxy support for corporate environments
Performance Optimizations
- Streaming responses for real-time feedback
- Batch embedding generation for documents
- SQLite indexes on frequently queried fields
- Lazy loading of UI components
- Debounced search and input handlers
- Connection pooling for MCP servers
--- METRICS ---
- Files Extracted: 2
- Estimated Token Budget: ~4473 tokens
- Canonical Reference: https://codewiki.google/github.com/nanbingxyz/5ire