-
Notifications
You must be signed in to change notification settings - Fork 0
Frontend Architecture
OpenWP's frontend is built with React 18, Tailwind CSS 3.4, and Radix UI primitives. It consists of three webpack entry points.
entry: {
index: './src/admin/index.js', // Admin dashboard SPA
'ai-content-generator-block': './src/editor/index.js', // Gutenberg block
'sitewide-chatbot': './src/sitewide-chatbot/index.js', // Frontend chatbot widget
}npm run start # Dev build with hot reload
npm run build # Production build
npm run lint:js # Lint JavaScript
npm run lint:css # Lint CSS
npm run format # Format source filesjsconfig.json maps src/* to ./src/* for clean imports.
| Library | Version | Purpose |
|---|---|---|
| React | ^18.3.1 | UI framework |
| Tailwind CSS | ^3.4.17 | Utility-first CSS |
| Radix UI | Various | Accessible primitives |
| Lucide React | ^0.575.0 | Icons |
| Sonner | ^2.0.7 | Toast notifications |
| CVA | ^0.7.1 | Component variant styling |
| clsx + tailwind-merge | Latest | Conditional class names |
| @wordpress/scripts | ^30.0.0 | Build tooling |
| @wordpress/api-fetch | Bundled | REST API client |
Custom design tokens in tailwind.config.js:
| Token | Value | Usage |
|---|---|---|
primary |
#0057ff |
Primary brand color |
accent |
#ff7d1f |
Accent color |
ink |
Custom | Text color |
muted |
Custom | Muted text |
line |
Custom | Borders |
surface |
Custom | Card backgrounds |
bg |
Custom | Page backgrounds |
success |
Custom | Success states |
warning |
Custom | Warning states |
danger |
Custom | Error states |
Font: Archivo Preflight: Disabled (for WordPress admin compatibility)
The main app component manages all state via React hooks (no external state library). It handles:
- Tab navigation (hash-based routing)
- Settings management
- Provider configuration
- Onboarding flow
| Screen | File | Description |
|---|---|---|
| Dashboard | screens/dashboard/index.jsx |
Stats, quick actions, recommended plugins |
| Console | screens/console/index.jsx |
Chat-style AI agent interface |
| Approvals | screens/approvals/index.jsx |
Pending action approval queue |
| Settings | screens/settings/index.jsx |
Plugin configuration |
| Actions | screens/actions/index.jsx |
Action catalog and policy management |
| Memory | screens/memory/index.jsx |
Agent memory viewer/editor |
| Logs | screens/logs/index.jsx |
Audit log browser |
| Backups | screens/backups/index.jsx |
Backup management and restore |
| Onboarding | screens/onboarding/index.jsx |
First-run setup wizard |
-
Welcome (
steps/welcome.jsx) - Introduction -
Provider (
steps/provider.jsx) - API key setup -
Guardrails (
steps/guardrails.jsx) - Risk/approval settings -
Test Command (
steps/test-command.jsx) - Verify setup -
Done (
steps/done.jsx) - Completion
shadcn-style primitives built on Radix UI:
-
Button,Dialog,Select,Table,Input,Textarea -
Switch,Badge,Alert,Card,Tooltip -
Accordion,NavigationMenu,Progress,Skeleton -
Label,RadioGroup,Separator,Sonner(toasts)
Custom components:
-
Header- Page header with navigation -
SideNav- Sidebar navigation -
NavBar- Top navigation bar -
Panel- Content panel wrapper -
StatCard- Dashboard statistics -
Pill- Status badges -
SmartResult- AI response renderer -
JsonBox- JSON viewer
-
use-hash-tab.js- Hash-based tab routing (#console,#settings, etc.)
Registered in src/editor/blocks/ai-content-generator/:
-
index.js- Block registration -
edit.jsx- Block edit component
-
ai-block-toolbar.jsx- Block toolbar actions -
prompt-box.jsx- Prompt input with send button -
generation-preview.jsx- Live content preview -
generation-progress.jsx- Progress indicator -
ai-modify-popover.jsx- Modify/refine popover -
badge-selector.jsx- Content type/tone selector -
global-modal.jsx- Modal dialog for AI operations
-
use-streaming-generation.js- SSE streaming hook for content generation
-
utils/recover-blocks.js- Handles block validation/recovery
Frontend chatbot widget for public-facing pages:
-
index.js- Entry point and initialization -
widget.jsx- Chat widget component
Three methods for REST API communication:
// Standard request (via @wordpress/api-fetch)
import { request } from 'src/shared/api';
const data = await request('/openwp/v1/bootstrap');
// SSE streaming request
import { streamRequest } from 'src/shared/api';
await streamRequest('/openwp/v1/agent/execute/stream', body, (event) => {
// Handle typed events
});
// File upload
import { uploadRequest } from 'src/shared/api';
const result = await uploadRequest('/openwp/v1/chatbot/upload', formData);The API client resolves configuration from multiple sources (in priority order):
-
options.runtime- Explicitly passed config -
window.openwpSiteChat- Sitewide chatbot config -
window.openwpAdmin- Admin page config (nonce, root URL, onboarding state, capabilities) -
window.wpApiSettings- WordPress default
Tab keys, onboarding route constants, OpenRouter model list.
OpenWP v0.1.4 | GitHub Repository | GPLv2+