3.7 KiB
3.7 KiB
Plan: Set Up React Frontend for Hive
Context
The feat/open-hive branch has a complete backend HTTP API (aiohttp on port 8787) with CRUD, execution control, sessions, SSE streaming, and more. The server already has SPA static-file serving built in — it looks for frontend/dist/index.html and serves it with a catch-all fallback. No frontend exists yet. The user has a Lovable.dev design they'll paste pages from later, so the scaffold must be Lovable-compatible (React 18, Vite, Tailwind, shadcn/ui, React Router).
The goal: create a deployable frontend shell with a typed API client layer, so the user can immediately start dropping in Lovable pages.
Key Decisions
| Decision | Choice | Why |
|---|---|---|
| Location | core/frontend/ |
Keeps frontend co-located with the Python framework inside core/. Requires a small tweak to app.py to add core/frontend/dist as a lookup candidate. |
| Build tool | Vite | SPA output, Lovable uses Vite, CRA deprecated, Next.js is overkill for SPA |
| Package manager | npm | Root package.json declares npm@10.2.0 — stay consistent |
| Styling | Tailwind CSS v4 + shadcn/ui | Lovable generates these; shadcn copies source into project |
| Routing | React Router | Lovable uses it; SPA client-side routing matches backend catch-all |
| Dev proxy | Vite server.proxy → :8787 |
Avoids CORS issues, SSE EventSource works through proxy |
Files to Create
core/frontend/
├── package.json
├── vite.config.ts
├── tsconfig.json
├── tsconfig.node.json
├── index.html
├── components.json # shadcn config (via npx shadcn@latest init)
├── src/
│ ├── main.tsx # React entry point
│ ├── App.tsx # Router shell
│ ├── index.css # Tailwind imports
│ ├── vite-env.d.ts # Vite type declarations
│ ├── lib/
│ │ └── utils.ts # shadcn cn() utility
│ ├── api/
│ │ ├── client.ts # Base fetch wrapper (/api prefix)
│ │ ├── types.ts # All TS types matching backend responses
│ │ ├── agents.ts # Agent CRUD endpoints
│ │ ├── execution.ts # Trigger, chat, inject, stop, resume
│ │ ├── sessions.ts # Sessions & checkpoints
│ │ ├── graphs.ts # Graph/node inspection
│ │ └── logs.ts # Log retrieval
│ ├── hooks/
│ │ └── use-sse.ts # SSE EventSource hook
│ └── pages/
│ └── index.tsx # Placeholder landing page
Files to Modify
core/framework/server/app.py— addcore/frontend/distas a static-file lookup candidatepackage.json— addfrontend:devandfrontend:buildconvenience scriptsMakefile— addfrontend-devandfrontend-buildtargets
Lovable Compatibility
When pasting Lovable pages later:
- Imports like
@/components/ui/buttonwork via the@alias - Run
npx shadcn@latest add <component>for each UI component a page needs - Add routes to
App.tsx— Lovable pages export default React components - If pages use
@tanstack/react-query, install it:npm install @tanstack/react-query - Tailwind classes work out of the box
Verification
cd core/frontend && npm run buildsucceeds and producescore/frontend/dist/index.html- Start backend:
cd core && uv run python -m framework.runner.cli serve— logs "Serving frontend from ..." - Open
http://localhost:8787— placeholder page renders - Dev mode:
cd core/frontend && npm run devon:5173, API calls proxy to:8787