← Home System Overview Architecture Data Pipeline Health System Usage System Workflows MCP Tools

System Overview — ManyAI Desktop

Blueprint · Last updated 2026-05-03

Purpose

ManyAI Desktop is an Electron-based desktop application providing a unified, multi-tab AI chat interface that routes user requests to multiple free and paid AI providers based on task type, provider health, and user configuration. It extends the ManyAI mobile concept with a richer workflow system, integrated built-in modules (IRC, terminal, RSS, programming), smart routing with health-aware scoring, MCP client integration for external tool servers, and SQLite-backed persistence for chat history and audit logs.

Tech Stack

ComponentTechnology
RuntimeElectron
UI FrameworkReact 18 + TypeScript
Build systemelectron-vite (Vite-based HMR)
Packagingelectron-builder
Internationalizationi18next (27 locales)
Local databasebetter-sqlite3 (WAL mode) — chat history, routing log, agent audit
MCP client@modelcontextprotocol/sdk@1.29.0

Application Architecture (3 Layers)

Layer 1: Main Process (src/main/)

Node.js / Electron process with full OS access.

IPC modules in src/main/ipc/:

ModuleHandles
fileIpc.tsFile system read/write/list/rename/delete operations
imageIpc.tsImage fetching and local image reading (CORS bypass + base64 encode)
ircIpc.tsIRC client connection, channel join, message send/receive
terminalIpc.tsTerminal command execution
dbIpc.tsSQLite operations — messages, routing log, agent audit (7 channels)
mcpIpc.tsMCP server management — list/add/remove/reconnect/list-tools/call-tool (6 channels)
index.tsregisterAllIpc() — calls all module register functions

Layer 2: Preload (src/preload/)

Secure bridge using contextBridge — raw ipcRenderer is never exposed to the renderer. Exposes window.api:

API GroupModulePurpose
file opsapi/files.tsFile CRUD, rename, delete, directory list
image opsapi/images.tsImage fetching (CORS-safe via main) + local image reading
IRCapi/irc.tsIRC client actions
terminalapi/terminal.tsTerminal commands
databaseapi/db.tsSQLite — addMessage, getMessages, clearMessages, logRouting, getRoutingStats, logAgent, getAgentLog
MCPapi/mcp.tsMCP server management — listServers, addServer, removeServer, reconnect, listTools, callTool
configindex.tsDurable config file (workingDir etc.) via api.getConfig() / api.setConfig()

TypeScript definitions in src/preload/index.d.ts. Shared MCP types in src/preload/types/mcp.ts.

Layer 3: Renderer (src/renderer/src/)

React application. No direct Node/Electron access — all system calls go through window.api. Feature modules in features/:

FeatureDescription
chat/ChatScreen.tsxMain chat interface, multi-provider routing, file attachment, SQLite message persistence
chat/fileHandler.tsFile drag-drop and attachment logic
editor/SavedScreen.tsxSaved responses viewer and editor
irc/IrcScreen.tsxIRC client UI (built-in module, loaded via Settings → Built-in)
rss/RssScreen.tsxRSS feed reader (built-in module)
terminal/TerminalScreen.tsxIntegrated terminal (built-in module)
programming/ProgrammingScreen.tsxAutonomous coding agent with file tree, Browse + Refresh buttons (built-in module)
settings/SettingsScreen.tsxSettings hub — tabs: General / Providers / Built-in / MCP / Workflows / Smart Routing / Health / Backup / About
settings/McpScreen.tsxMCP server config UI — add/edit/remove/reconnect, tool list viewer

Provider Registry

Providers defined in providers/*.json (one file per provider): anthropic, cerebras, cloudflare, cohere, fireworks, gemini, groq, huggingface, laptop (local Ollama), mistral, openai, openrouter, pollinations, sambanova.

Each provider JSON defines: name, baseUrl, models (each with id, name, capabilities[]), apiFormat, and systemPromptStyle. capabilities drives workflow routing. systemPromptStyle declares how system prompts are sent to the provider's API:

ValueBehaviorProviders
system-rolePrepend { role: "system", content } to messages array (default)OpenAI, Groq, Mistral, etc.
system-fieldTop-level system string field in request bodyAnthropic
system-instructionTop-level systemInstruction: { parts: [{ text }] } in request bodyGemini

The application is a generic executor — it reads systemPromptStyle from JSON and applies the correct API shape. All provider-specific behaviour is declared in the JSON file, not hardcoded by provider name. The add/edit provider form exposes this field as a dropdown.

Built-in Modules (4) — opt-in via Settings → Built-in tab

IRC, RSS, Terminal, and Programming are modular built-ins. They are not workflow-picker items. Each has a checkbox in Settings → Built-in; checking it opens a tab, unchecking closes all tabs of that type. Toggle state is derived from tabs.some(t => t.workflowType === type) — no separate enabled flag.

TypeLabelUse case
ircIRC 💬IRC client — raw TCP via main process, publishes to workflowBus
rssRSS 📰RSS feed reader — publishes to workflowBus
terminalTerminal 🖥️SSH/Telnet/SFTP/FTP client — xterm.js + ssh2 + basic-ftp
programmingProgramming ⚙️Autonomous coding agent — agentLoop with 9 native tools + dynamic MCP tools; file tree with Browse + Refresh

Workflow System (6 file-backed)

File-backed workflows are seeded to {workingDir}/workflows/*.json on first run and user-editable. They appear in the New Tab picker (enabledUserWorkflows() excludes built-in types).

TypeLabelUse case
imageImageImage generation
codingCodeCode generation and explanation
reasoningReasoningDeep analysis and logic
creativeCreativeWriting, brainstorming
summarizationSummarizeLong text compression
translationTranslateLanguage translation

MCP Subsystem

McpClientManager (singleton in main process) manages connections to external MCP servers. Configs persisted to userData/mcp-servers.json. All servers reconnect on app start. Tools are discovered dynamically at agent run time and merged into the tool list sent to the model. See MCP Tools blueprint for full details.

Routing System

Manual routing (default): Per-workflow RouteEntry chain (provider + model + enabled + instanceId). Built-in routes stored in localStorage. Custom workflow routes stored in their JSON files.

Smart Routing (opt-in): Scores providers 0–1 using success rate, speed, and health penalty. Three modes: best-first, serial, parallel.

Health System

lib/healthCheck.ts polls provider endpoints on a configurable interval. Records uptime percentage and average latency per provider. getPenalty(provider) returns a 0–1 penalty used by smartRouter.scoreProvider(). Continuous monitoring runs on a timer in App.tsx re-reading config each tick so interval changes take effect without restart.

Persistence

StorageContents
localStorageTabs, active tab, continuous mode, routing prefs, smart routing config+log, provider order, enabled state, selected models, theme, zoom, font
localStorage (encrypted via safeStorage)API keys
userData/manyai.db (SQLite)Chat messages per tab, routing log, agent audit log
userData/window-state.jsonWindow position and size
userData/config.jsonworkingDir and other durable settings
userData/mcp-servers.jsonMCP server configurations
providers/*.jsonProvider + model registry (in repo)
{workingDir}/workflows/*.jsonCustom workflow definitions + routes

Internationalization

27 locale files in src/renderer/src/i18n/locales/. Includes RTL locales (Arabic, Hebrew). scripts/gen-translations.py generates/updates locale files.

Tab System