How we0-dev/we0 works
Project type and purpose
• This is a monorepo full-stack application that provides:
• A cross-platform desktop client (Electron + React) with built-in IDE, chat, D2C (design-to-code), WeChat mini-program preview, and webcontainer/nodecontainer debugging
• A Next.js server (we-dev-next) offering REST/stream endpoints for chat, code generation, deployment, enhanced prompting, and model configuration
• A static/docs site under the same Next.js codebase
File structure
• Top level: monorepo with apps/we-dev-client (Electron + React) and apps/we-dev-next (Next.js server + docs)
• Client
• Electron main processes (electron/*.ts)
• React renderer (src/…): UI components (AiChat, WeIde, WeAPI, Settings, etc.), WebContainer/NodeContainer services, hooks, stores
• Build/config files: package.json, electron-builder.*, vite.config.ts, tailwind, .env.example
• Server (we-dev-next)
• Next.js App Router API routes: src/app/api/chat, /deploy, /enhancedPrompt, /model
• Utilities: file processors, diff generators, token handlers, streaming helpers
• i18n, middleware, Tailwind, docs under content/docs
• Shared/devops: Dockerfile, scripts/wedev-build.sh, pnpm, .npmrc
README for additional insights
• Monorepo with pnpm workspaces
• Electron desktop + webcontainer debugging, design restoration, existing project import, WeChat Tool integration
• Next.js backend calls third-party LLM API (OpenAI or others) via environment-driven URL & key
• Monolithic serverless functions pattern (multiple handlers under /api)
1) Desktop Client
• Electron Main
• React Renderer
• WebContainer Service
• NodeContainer Service
• Local MCP Server (Electron-spawned TCP)
• Local File System Access
2) Web Client
• React UI served by Vite or static CDN
3) Next.js Server (we-dev-next)
• API Routes: Chat, Deploy, EnhancedPrompt, Model
• Middleware & Cache
4) External Services
• Third-party LLM API (OpenAI, etc.)
• WeChat Mini-Program Developer Tools
5) Persistence (if any)
• In-memory or file-based cache (no explicit DB in code)
b. Relationships and interactions:
• Electron Renderer → Electron Main via IPC (startup, configuration)
• Renderer → Local WebContainer/NodeContainer (embedded terminal APIs)
• Renderer → MCP Server (TCP) for plugin/tool orchestration
• Renderer & Web Client → Next.js Server via HTTP/Fetch (API calls: chat, deploy, etc.)
• Next.js Server → Third-party LLM API (streaming or JSON)
• Next.js Server → internal cache (token counts, conversation history)
• Electron Main → spawn WeChat Developer Tools (CLI)
c. Architectural patterns & design principles:
• Monorepo with pnpm workspaces
• Electron multi-process architecture (main/renderer)
• Micro-handlers in Next.js App Router (serverless-style)
• Service abstraction for WebContainer/NodeContainer
• Stream-based chat response (Switchable-stream)
• i18n and feature flags via environment
d. Key technologies/frameworks:
• Electron, Vite, React, Zustand/Redux slices
• webcontainer & @webcontainer/api, nodecontainer
• Next.js App Router (Edge/Node), TypeScript
• Tailwind CSS, PostCSS, Zod for input validation
• pnpm, Docker