How iheytang/openmanus works
Project type and purpose
• This is a full-stack, multi-tenant AI assistant platform (“OpenManus”) comprising:
• A Python “Core” service (app/…, run_api.py) that hosts REST APIs, orchestrates AI agents, manages long-running tasks, sandboxes, and LLM calls.
• A Next.js “App” (web/) providing user authentication, the UI, and Prisma-backed persistence to PostgreSQL.
File structure
• Top level:
• app/ → Python modules: agent, flow, prompt, sandbox, apis (routes + services), mcp, container, llm interface, memory, logger, schema.
• run_api.py / main.py → Entry points for Python service using FastAPI or equivalent.
• web/ → Next.js (React) with App Router, serverless routes under web/src/app/api, Prisma schema, UI components, i18n.
• config/, Dockerfile(s), docker-compose.yml → Deployment.
• Tests target sandbox client/manager and core logic.
Extract README insights
• Two-part install: “Core” (Python) and “App” (Node/Next.js).
• PostgreSQL for persistence.
• Prisma used in web/.
• LLM integrations pluggable via config files.
• Docker Compose brings up core, web, and DB.
Main components
a. User Interface (Next.js Frontend)
b. Web API Layer (Next.js serverless routes + Prisma ORM)
c. Core API Service (Python FastAPI)
d. Task & Agent Orchestrator (Python modules: flow, agent, prompt)
e. Sandbox / Container Manager (app/sandbox + Docker engine)
f. Data Store (PostgreSQL)
g. External Services (LLM providers, Playwright browsers)
Component interactions
• UI → Web API (HTTP/REST) for login, tasks, workspace browsing.
• Web API → PostgreSQL (Prisma queries) for user, workspace, task metadata.
• Web API → Core API (HTTP/REST or RPC) to launch new tasks or query status.
• Core API → Sandbox Manager (via Docker SDK or local calls) to run code/tools securely.
• Core API → LLM Interface → External APIs (OpenAI, Anthropic, Azure, Google) for model calls.
• Core API services (file_monitor, task_manager, workspace) persist state back to PostgreSQL (if used by Python) or signal Web API.
Architectural patterns & design principles
• Layered architecture in Python:
• API layer (FastAPI routes)
• Service layer (task_manager, file_monitor, workspace)
• Domain layer (agent, flow, prompt)
• Infrastructure layer (sandbox, container, llm)
• Next.js App Router for co‐located UI + server‐side routes.
• “Separation of concerns” between Core (AI orchestration) and App (user management, UI).
• Docker Compose to decouple services and enable reproducible environments.
Technologies & frameworks to annotate
• Python 3.12, FastAPI (presumed), uv for package management
• Docker, Docker Compose
• Next.js (React), TypeScript, Prisma ORM
• PostgreSQL
• Playwright for browser automation
• LLM SDKs (OpenAI, Anthropic, etc.)
• i18n (yaml/json translations)
• uvicorn/gunicorn for Python service
• Pre-commit, GitHub Actions for CI
• Components above.
• Data flows with arrowheads and labels.
• Frameworks (FastAPI, Next.js, Prisma).
• Detail the Docker Compose orchestration (three containers).
• Don’t omit the sandbox subsystem (core to safety).