Tzelem Development Assistant
Expert assistant for developing the Tzelem multi-agent orchestration platform - a dynamic AI team builder that assembles specialized agents to deliver real work with enterprise-grade control, real-time observability, and spend guardrails.
Project Context
Tzelem is a monorepo-based platform where users define objectives with budgets, and the system assembles specialized AI agents that coordinate workflows and deliver results. The platform provides real-time monitoring, auditability, and budget controls.
Repository Structure
`frontend/app/` - Main React application (Vite + TypeScript)`backend/` - Backend services (currently minimal, frontend-focused development)`infra/` - Infrastructure configuration`scripts/` - Development scripts and documentationTech Stack
**Frontend:**
**Framework**: Vite + React 19 + TypeScript**UI**: ShadCN/UI + Radix UI primitives + Tailwind CSS**Flow Builder**: React Flow (@xyflow/react)**Voice**: PipeCat Client JS (@pipecat-ai/client-js) with WebRTC**State**: Zustand + React Context**HTTP**: Axios with SSE for real-time updates**Testing**: Vitest + React Testing Library + Playwright**Design System:**
Monochromatic white/gray with blue accent (#0066ff)Inter font familyBuilt on ShadCN/UI and Radix primitivesDevelopment Workflow
Step 1: Navigate to Frontend Directory
Always start by navigating to the frontend application directory:
```bash
cd frontend/app
```
Step 2: Understand the Task
Before making changes:
Review the feature-based architecture in `src/features/`Check existing components in `src/components/`Review type definitions in `src/lib/types/`Consult `scripts/mega_frontend_prompt.md` for detailed specificationsStep 3: Development Commands
**Essential commands to use:**
`npm run dev` - Start development server`npm run type-check` - Run TypeScript type checking (required before commits)`npm run lint` - Check for linting issues (required before commits)`npm run lint:fix` - Auto-fix ESLint issues`npm run test` - Run unit tests with Vitest`npm run test:ui` - Run tests with UI interface`npm run test:coverage` - Generate coverage report`npm run format` - Format code with Prettier`npm run format:check` - Check formatting`npm run build` - Build for production`npm run preview` - Preview production buildStep 4: Code Organization
**Feature-based structure:**
```
src/
├── components/
│ ├── ui/ # ShadCN base components (Button, Input, etc.)
│ ├── layout/ # Header, Navigation, Layout wrappers
│ └── common/ # Shared components (LoadingSpinner, ErrorBoundary, etc.)
├── features/
│ ├── flow/ # Flow Builder (React Flow nodes, edges, canvas)
│ ├── run/ # Run Console & Execution monitoring (SSE integration)
│ ├── voice/ # Voice Interface (PipeCat WebRTC)
│ └── secrets/ # Secrets Management (server-side handling)
├── lib/
│ ├── api.ts # API client & endpoints
│ ├── utils.ts # Utility functions
│ └── types/ # Global TypeScript types
├── hooks/ # Custom React hooks
└── contexts/ # React Context providers
```
**When creating new features:**
1. Add feature directory under `src/features/[feature-name]/`
2. Create feature-specific components, hooks, and types within that directory
3. Export public API from `index.ts`
4. Add shared components to `src/components/common/` if reusable
5. Update type definitions in `src/lib/types/` for global types
Step 5: API Integration
**Configuration:**
Base URL: Set via `VITE_API_BASE_URL` environment variableReal-time: SSE endpoints at `/api/runs/:id/events`Voice: WebRTC room management endpointsSecrets: Server-side only (frontend stores labels, not values)**API client usage:**
```typescript
import { api } from '@/lib/api';
// Example API call
const response = await api.get('/runs');
```
Step 6: Flow Export Schema
Flows are exported as JSON with version 0.1.0 schema:
**Paradigms**: Agentic or Sequential**Agent Types**: MasterAgent, ExecutionAgent, RoutingAgent, and more**Features**: Real-time voice, pricing/budget controls**Validation**: TypeScript types ensure schema complianceStep 7: Testing Requirements
**Before committing code:**
1. Run `npm run type-check` - Must pass with zero errors
2. Run `npm run lint` - Must pass or auto-fix with `npm run lint:fix`
3. Run `npm run test` - All tests must pass
4. Run `npm run format:check` - Code must be properly formatted
**Writing tests:**
Unit tests: Vitest + React Testing Library in `*.test.tsx` filesE2E tests: Playwright for critical user flowsPlace tests adjacent to components: `Component.tsx` → `Component.test.tsx`Step 8: Security & Best Practices
**Critical rules:**
Never expose secrets in frontend codeAll credential handling must be server-sideFrontend only stores secret labels/referencesUse proper TypeScript types (avoid `any`)Follow React 19 best practices (use hooks properly)Maintain accessibility (proper ARIA labels, keyboard nav)Step 9: Git Workflow
**Branches:**
`main` - Main branch (use for PRs)`frontend-dev` - Current development branch**Commit checklist:**
1. Type checking passes (`npm run type-check`)
2. Linting passes (`npm run lint`)
3. Tests pass (`npm run test`)
4. Code is formatted (`npm run format`)
5. Commit message follows conventional commits format
Step 10: Voice Integration
**PipeCat Integration:**
Use `@pipecat-ai/client-js` for WebRTC connectionsVoice features located in `src/features/voice/`Room management via backend APIReal-time audio streaming with proper error handlingKey Features Implementation Guide
Flow Builder
Uses React Flow for visual workflow designCustom node types in `src/features/flow/nodes/`Edge configuration in `src/features/flow/edges/`Canvas controls in `src/features/flow/canvas/`Run Console
Real-time execution monitoring via SSEEvent streaming from `/api/runs/:id/events`Live logs and status updatesBudget tracking and spend visualizationVoice Interface
WebRTC connection via PipeCatRoom lifecycle managementAudio device selectionReal-time transcription displaySecrets Manager
Server-side credential storageFrontend label-only displaySecure API key managementIntegration with agent configurationsCommon Tasks
**Add a new UI component:**
1. Check if ShadCN/UI component exists (`npx shadcn-ui add [component]`)
2. If custom, create in `src/components/common/`
3. Use Tailwind CSS for styling
4. Ensure TypeScript types are defined
5. Add tests in adjacent `.test.tsx` file
**Add a new feature:**
1. Create directory in `src/features/[feature-name]/`
2. Add components, hooks, types, and tests
3. Export public API from `index.ts`
4. Update routing if needed
5. Add API endpoints to `src/lib/api.ts`
**Debug SSE connection:**
1. Check `VITE_API_BASE_URL` in `.env`
2. Verify endpoint format: `/api/runs/:id/events`
3. Inspect Network tab for EventSource connections
4. Check backend logs for SSE errors
**Style with design system:**
Use Tailwind utility classesFollow monochromatic palette (white/gray + blue accent)Use Inter font familyReference existing components for consistencyImportant Notes
Development focus is frontend-first (backend is minimal)Consult `scripts/mega_frontend_prompt.md` for detailed feature specificationsAll secrets must be handled server-side for securityVoice features require proper WebRTC setup and PipeCat integrationAlways maintain TypeScript strict mode complianceThe platform targets enterprise use cases with audit trails and compliance featuresTroubleshooting
**Type errors:**
Run `npm run type-check` to identify issuesCheck `src/lib/types/` for type definitionsEnsure imports use correct paths (`@/` alias for `src/`)**Build failures:**
Clear `node_modules` and reinstall: `rm -rf node_modules && npm install`Check Vite config in `vite.config.ts`Verify all environment variables are set**Test failures:**
Run `npm run test:ui` for interactive debuggingCheck test setup in `vitest.config.ts`Ensure mocks are properly configured**SSE connection issues:**
Verify backend is running and accessibleCheck CORS configurationInspect browser console for connection errorsValidate event stream format