How avdpro/ai2apps works
Project type and purpose
• From the README and file tree, this is a full-stack, PC-side AI Agent infrastructure (“AI2Apps”) that combines an Electron-style desktop UI, a Node.js/Express backend, a plugin-style agent engine, pluggable agent definitions, and RPA scripts. Its goal is to let users develop, serve, and share autonomous AI “agents” on the PC, avoiding cloud-only silos.
File structure
• Top-level entry points:
• app.js / start.js / main.mjs – bootstraps the Express server (and possibly Electron)
• AgentNodeMain.mjs – CLI entry for running headless agents
• Frontend/UI:
• ebrowser/ – Electron-style browser window (HTML/CSS/JS + preload)
• public/ + views/ – static assets and Pug templates served by Express
• Backend/API:
• routes/ – Express routers (APIChatAI, APIFiles, APIRag, APIUtils, index, ws)
• util/ – configuration, token management, user utilities, locking
• Agent Core Frameworks:
• aaee/ – core agent classes (AgentNode, AABot, AADataBase, tasks, file libs, web bots)
• agenthub/ – multi-agent orchestration, interactive terminal (AgentNodeTerm, AhSession, AhSystem, ChatSession)
• Agent Definitions (plugins):
• agents/AgentBuilder – generator agents for scaffolding new agents/projects
• agents/DrawSD, WebRpa, tabos, wechat – specialized agent kits (each with agent.json + code)
• RPA and Scripts:
• rpa/ – custom RPA flows (WebRpa.mjs, aiquery, pptstart)
• apiproxy/ – HTTP proxies to external services (e.g. OpenAI, Yahoo Finance)
• Database layer:
• aaee/AADataBaseMDB.mjs – MongoDB adapter
• aaee/AADataBaseMem.mjs – in-memory storage
• Packaging & Deployment:
• .env, package.json, my-node/ – embedded Node runtime, build scripts
• cfg/version.json – versioning
README for additional insights
• The architecture is “distributed PC-side”: desktop app ↔ local server ↔ agent engine ↔ external APIs.
• End-to-end lifecycle: development (AgentBuilder), serving (runtime & UI), sharing (agent.json modules).
Main components & interactions
a. Components
1. Desktop Client (Electron / Browser)
• ebrowser/ + public/ + views/
2. Node.js Server (Express)
• app.js, routes/
3. Agent Engine Core
• aaee/ (AgentNode, AABot, FileLib, Task, DataBase)
• agenthub/ (multi-agent orchestration, terminal UI)
4. Agent Plugins Repository
• agents/ (AgentBuilder, DrawSD, WebRpa, tabos, wechat, …)
5. RPA Scripts & Flows
• rpa/ (WebRpa, aiquery, pptstart)
6. API Proxy Layer
• apiproxy/ (ApiProxy, FetchProxy, ProxyYahooFinance)
7. Database Layer
• MongoDB or in-memory (aaee/AADataBaseMDB, AADataBaseMem)
8. Utility Layer
• util/ (SysConfig, TokenUtils, UserUtils, locker)
9. External Services
• OpenAI / LLM APIs, Web search, Finance APIs, etc.
10. CLI Entrypoints
• AgentNodeMain.mjs, start.js, main.mjs
b. Relationships & Data Flows
• Desktop Client ↔ HTTP/WebSocket ↔ Node.js Server
• Server uses util/ for config/auth
• Server invokes Agent Engine Core (aaee + agenthub) to spin up agents
• Agent Engine loads Agent Plugins from agents/ folder (via agent.json)
• Agents call RPA scripts (rpa/) and API Proxy (apiproxy/) as needed
• Agent Engine persists session or state in Database Layer
• Agents call out to External Services (OpenAI, search, finance) through the proxy
• CLI entrypoints start headless AgentNodes directly
c. Architectural patterns & design principles
• Plugin architecture for agent definitions (dynamic loading via agent.json)
• Layered design: UI / API / Engine / Plugins / Data / External Services
• Separation of concerns: AgentBuilder vs. Agent Runtime vs. Runtime Orchestration
• Use of adapters: AADataBaseMDB vs. AADataBaseMem, Apiproxy adapters
d. Key technologies & frameworks
• Node.js / Express (backend)
• Electron (desktop client)
• Pug (server-side templates)
• MongoDB (optional)
• WebSocket (real-time chat sessions)
• Python (some RPA flows)
• JavaScript modules (ESM .mjs)