The Erudite frontend is built with Next.js 14, featuring a modern, responsive interface for knowledge graph exploration and agent interaction. It provides real-time streaming capabilities, interactive visualizations, and a seamless user experience.
ui/
├── src/
│ ├── app/ # Next.js app router pages
│ │ ├── agent/ # Agent interaction pages
│ │ ├── graph/ # Knowledge graph pages
│ │ └── api/ # API route handlers
│ ├── components/ # Reusable components
│ │ ├── agent-thoughts/ # Agent streaming components
│ │ ├── graph/ # Graph visualization components
│ │ └── ui/ # Common UI components
│ ├── hooks/ # Custom React hooks
│ ├── lib/ # Utility functions
│ ├── styles/ # Global styles
│ └── types/ # TypeScript definitions
├── public/ # Static assets
└── tests/ # Frontend tests
-
Real-time Agent Interaction
- Streaming thought process visualization
- Interactive agent commands
- Multi-type message display
-
Knowledge Graph Visualization
- Interactive graph exploration
- Node expansion and navigation
- Custom graph layouts
-
Modern UI Components
- Radix UI integration
- Dark/light theme support
- Responsive design
-
Performance Optimizations
- Server-side rendering
- Incremental static regeneration
- Optimized asset loading
- Node.js 18+
- npm or yarn
- Backend server running
- Install dependencies:
npm install
# or
yarn install
- Configure environment:
cp .env.example .env.local
# Edit .env.local with your settings
- Run development server:
npm run dev
# or
yarn dev
- Build for production:
npm run build
npm start
# or
yarn build
yarn start
Create .env.local
with:
# API Configuration
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_WS_URL=ws://localhost:8000
# Authentication
NEXT_PUBLIC_AUTH_DOMAIN=your-auth-domain
NEXT_PUBLIC_AUTH_CLIENT_ID=your-client-id
# Feature Flags
NEXT_PUBLIC_ENABLE_ANALYTICS=true
NEXT_PUBLIC_ENABLE_DARK_MODE=true
# Performance
NEXT_PUBLIC_ISR_REVALIDATE_TIME=3600
The AgentThoughts
component handles real-time streaming of agent responses:
<AgentThoughts
initialPrompt="Your research query"
onThoughtReceived={(thought) => {}}
onComplete={() => {}}
/>
The GraphViewer
component renders interactive knowledge graphs:
<GraphViewer
graphData={data}
onNodeClick={(node) => {}}
layout="force"
/>
-
Theme System
- Use Radix UI theme tokens
- Support dark/light modes
- Maintain consistent spacing
-
CSS Modules
- Local scope for components
- Reusable utility classes
- Responsive design patterns
-
Animation Guidelines
- Use CSS transitions
- Implement reduced motion
- Optimize performance
-
React Context
- Theme context
- Auth context
- Agent state context
-
Local Storage
- User preferences
- Cache management
- Session data
- Mobile-first approach
- Breakpoint system
- Flexible layouts
-
Authentication
- JWT handling
- Secure storage
- Route protection
-
Data Safety
- Input sanitization
- XSS prevention
- CSRF protection
-
Code Splitting
- Dynamic imports
- Route-based splitting
- Component lazy loading
-
Asset Optimization
- Image optimization
- Font loading
- Bundle analysis
- Enable debug mode in
.env.local
:
NEXT_PUBLIC_DEBUG=true
-
Use React Developer Tools
-
Check browser console
-
Usage Tracking
- Page views
- User interactions
- Performance metrics
-
Error Tracking
- Error boundaries
- Error logging
- Performance monitoring
-
GitHub Actions
- Automated testing
- Lint checking
- Build verification
-
Deployment
- Vercel integration
- Environment management
- Release automation
- Implement real-time collaboration
- Add more graph layouts
- Enhance mobile experience
- Improve accessibility
- Add more visualization options
- Fork the repository
- Create feature branch
- Commit changes
- Push to branch
- Create Pull Request
-
Code Style
- ESLint configuration
- Prettier formatting
- TypeScript strict mode
-
Component Structure
- Atomic design principles
- Composition patterns
- Props documentation
-
Performance
- Memoization
- Virtual scrolling
- Image optimization