AgentHub is a collaborative AI dashboard that combines real-time CRDT-based state synchronization, offline-first persistence, and secure backend proxying for AI model calls. It is designed for robust local development and seamless production deployment, supporting multi-user collaboration and local data durability.
- Offline-first: All state is persisted locally using IndexedDB, ensuring the app works even without a network connection.
- Real-time collaboration: Uses Yjs CRDTs and y-websocket for conflict-free, multi-user state sync.
- Single-domain deployment: The Node.js backend serves the React app, API, and WebSocket endpoint from one server for maximum compatibility.
- Secure AI proxy: All Groq API calls are proxied through the backend, keeping API keys safe and off the client.
- Sync status indicators: The UI displays network and sync status for transparency and debugging.
- Frontend: React 18, Tailwind CSS, lucide-react
- Sync: Yjs, y-websocket, y-indexeddb
- Backend: Node.js, Express, ws (WebSocket), node-fetch, dotenv
- Dev Tools: concurrently, react-scripts
- Deployment: Railway, Vercel, Fly.io, or any Node-compatible host
src/– React UI and sync logicApp.js– Main dashboard UI and sync status overlayagent/useAgentStore.js– App state, hydration, sync wiring, CRDT mergeagent/yjsAgent.js– Yjs doc and WebSocket provider bootstrapagent/groq.js– Groq API client (uses backend proxy)
server.js– Express API, WebSocket upgrade handler, static build hostingpublic/– Static assets and HTML templatebuild/– Production build output (created bynpm run build)
Copy .env.example to .env and fill in the required values:
cp .env.example .envCore variables:
PORT– Backend server port (default:5000)GROQ_API_KEY– Groq API key (server-side only)GROQ_MODEL– Groq model ID (e.g.,llama-3.1-8b-instant)YJS_WS_PATH– WebSocket path (default:/yjs)REACT_APP_YJS_WS_URL– (optional) Explicit WebSocket URL for the client (e.g.,wss://your-domain/yjs)REACT_APP_GROQ_PROXY_URL– (optional) Explicit Groq proxy URL for the client (e.g.,https://your-domain/groq)
Install all dependencies:
npm installThis will start both the React development server and the Node backend:
npm run allWhat this does:
- React app at http://localhost:3000
- Node server at http://localhost:5000
- WebSocket endpoint at
ws://localhost:5000/yjs
npm run dev– React dev server onlynpm run proxy– Node backend onlynpm run sync– Standalone y-websocket server on port 1234 (optional/legacy)
Build the frontend:
npm run buildRun the backend server (serves the built frontend, API, and WebSocket):
npm run proxyEndpoints in production:
- Static React build from
/build - API endpoint:
POST /groq - Health endpoint:
GET /sync-health - Yjs WebSocket endpoint:
wss://<your-domain>/yjs/<room>
For best reliability, deploy as a single service (same domain for UI, API, and WebSocket):
- Build the frontend:
npm run build - Deploy the Node server (
server.js) with thebuild/directory included - Use
wss://<your-domain>/yjsas the sync endpoint in production
Supported platforms: Railway, Vercel (with Node backend), Fly.io, Render, or any Node-compatible host that supports WebSocket upgrades.
- App initializes a local Yjs document
- IndexedDB restores prior local state immediately
- WebSocket provider joins the room
agent-crdt-state-v1 - CRDT updates merge conflict-free across all connected clients
- UI reflects network and sync state (
connected,syncing,disconnected)
- Check that the browser is connecting to
wss://<your-domain>/yjs/agent-crdt-state-v1 - Ensure the backend receives upgrade requests on
/yjs/* - Confirm the production build is up-to-date (clear cache/hard refresh)
- Make sure your hosting platform supports WebSocket upgrades end-to-end
- Use browser guards (
typeof window !== 'undefined') in any client modules that may be imported during SSR or Node execution
This project is licensed under the MIT License. See the LICENSE file for details.
This starts:
- React app at
http://localhost:3000 - Node server at
http://localhost:5000 - WebSocket upgrade endpoint at
ws://localhost:5000/yjs
npm run dev– React dev server onlynpm run proxy– Node server onlynpm run sync– standalone y-websocket server on1234(optional/legacy)
Build the frontend:
npm run buildRun the backend server:
npm run proxyIn production, server.js serves:
- Static React build from
build/ - API endpoint:
POST /groq - Health endpoint:
GET /sync-health - Yjs WS endpoint:
wss://<domain>/yjs/<room>
For best reliability, deploy as a single service (same domain for UI + API + WebSocket).
Recommended flow:
- Build frontend (
npm run build) - Deploy Node server (
server.js) withbuild/included - Use
wss://<your-domain>/yjsas sync endpoint
- App initializes local Yjs doc
- IndexedDB restores prior local state immediately
- WebSocket provider joins room
agent-crdt-state-v1 - CRDT updates merge conflict-free across clients
- UI reflects network + sync state (
connected,syncing,disconnected)
- Verify browser WS URL is
wss://<domain>/yjs/agent-crdt-state-v1 - Ensure backend receives upgrade requests on
/yjs/* - Confirm production build is fresh (clear cache/hard refresh)
- Ensure platform supports WebSocket upgrades end-to-end
- Use browser guards (
typeof window !== 'undefined') in client modules used during build/runtime boundaries.