OpenManus is built with a modern web architecture that combines React for the frontend and Node.js/Python for the backend, using WebSocket for real-time communication.
graph TD
%% Frontend Components
A[src/app/page.tsx] --> B[src/components/prompt-form.tsx]
A --> C[src/components/chat-panel.tsx]
A --> D[src/components/header.tsx]
A --> E[src/components/footer.tsx]
%% Frontend Dependencies
B --> F[src/hooks/useSocket.ts]
B --> G[src/components/ui/button.tsx]
B --> H[src/components/ui/textarea.tsx]
B --> I[src/components/ui/label.tsx]
B --> J[src/components/ui/select.tsx]
B --> K[src/components/ui/switch.tsx]
%% Socket Connection
F --> L[src/lib/socket.ts]
L --> M[src/server/index.ts]
%% Backend Flow
M --> N[src/server/browser-service.ts]
N --> O[Python Browser Automation]
%% Event Flow
B -- prompt:submit --> M
M -- automation:log --> C
M -- automation:complete --> C
M -- automation:error --> C
N -- log events --> M
O -- output --> N
page.tsx
├── prompt-form.tsx
│ ├── button.tsx
│ ├── textarea.tsx
│ ├── label.tsx
│ ├── select.tsx
│ └── switch.tsx
├── chat-panel.tsx
├── header.tsx
└── footer.tsx
prompt-form.tsx
├── useSocket.ts
│ └── socket.ts
└── socket.io-client
server/index.ts
├── socket.io
├── browser-service.ts
│ ├── child_process (spawn)
│ └── events (EventEmitter)
└── utils/logger.ts
User Input
└── prompt-form.tsx
└── Socket Event (prompt:submit)
└── server/index.ts
└── browser-service.ts
└── Python Process
└── Browser Automation
└── Results
└── Socket Events
└── chat-panel.tsx
- User enters prompt in prompt-form.tsx
- Configures options (model, headless, etc.)
- Clicks submit button
- prompt-form.tsx validates input
- Emits 'prompt:submit' event with options
- Updates UI loading state
- server/index.ts receives event
- Creates/uses BrowserUseService instance
- Passes configuration to automation
- browser-service.ts spawns Python process
- Monitors process output
- Emits progress events
Server emits events:
- automation:log (progress updates)
- automation:complete (success)
- automation:error (failures) Frontend components update based on events
- chat-panel.tsx displays messages
- prompt-form.tsx updates loading state
- Error handling shows notifications
Dependencies between components are managed through:
- Props for React components
- Socket events for client-server communication
- EventEmitter for backend service communication
- File system for Python process interaction
This architecture provides:
- Decoupled frontend and backend
- Real-time updates through WebSocket
- Extensible automation options
- Robust error handling
- Clear separation of concerns
src/app/page.tsx
: Main application pagesrc/components/prompt-form.tsx
: Form for user input and configurationsrc/components/chat-panel.tsx
: Displays automation progresssrc/hooks/useSocket.ts
: WebSocket connection management
src/server/index.ts
: WebSocket server and request handlingsrc/server/browser-service.ts
: Browser automation servicesrc/server/utils/logger.ts
: Logging utilities
The application configuration flows through multiple layers:
- Frontend form inputs
- WebSocket event payload
- Backend service configuration
- Python process arguments
Each layer validates and processes the configuration appropriately, ensuring type safety and proper defaults.