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.
Prerequisites: Node.js 18+ and a free Groq API key.
# 1. Clone and enter the project
git clone <your-repo-url>cd agent-runtime
# 2. Install dependencies
npm install
# 3. Configure environment
cp .env.example .env
# then open .env and set GROQ_API_KEY=your_key_here# 4. Run the app (React UI + backend together)
npm run allOpen http://localhost:3000. The backend (API + WebSocket sync) runs on port 5000.
That's it for local use. For production and public deployment, see
Deployment and SECURITY.md (set ALLOWED_ORIGINS
and review the proxy hardening options before exposing it).
- 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.
The /groq endpoint is a proxy for the Groq API. Before deploying publicly, read SECURITY.md — by default the proxy will use your server-side GROQ_API_KEY, so you should set ALLOWED_ORIGINS and consider enabling PROXY_AUTH_TOKEN to prevent unauthorized use of your key.