A full-stack basketball chatbot powered by Ollama and React, featuring real-time streaming responses and a modern chat interface.
- Basketball-Focused AI: Powered by local Ollama LLM with custom basketball personality
- Real-Time Streaming: Live token-by-token response streaming
- Modern Chat UI: Responsive design with smooth animations
- Comprehensive Testing: 80%+ test coverage with Jest and Vitest
- Clean Architecture: Following software engineering best practices
- Layered Architecture: Clear separation of concerns
- Ollama Integration: Local LLM with streaming responses
- RESTful API: Clean endpoints with proper error handling
- Comprehensive Testing: Jest test suite with mocking
- Component-Based Design: Reusable, testable components
- Modern React Patterns: Hooks, controlled components, event handling
- Responsive Design: Mobile-first approach
- Vitest Testing: Component and integration tests
- Node.js 18+
- Ollama installed and running
- Model pulled:
ollama pull llama3
1. Clone and setup
git clone <repository>
cd Hooper2. Setup Backend
cd server
npm install
npm run dev3. Setup Frontend (in new terminal)
cd client
npm install
npm run dev4. Start Ollama
ollama serve
ollama pull llama35. Open Application
- Frontend: http://localhost:3000
- Backend: http://localhost:3001
- Health Check: http://localhost:3001/health
cd server
npm test # Run all tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage reportcd client
npm test # Run all tests
npm run test:ui # UI test runner
npm run test:coverage # Coverage report/Hooper
βββ server/ # Backend (Express.js)
β βββ services/ # Business logic
β βββ utils/ # Utility functions
β βββ tests/ # Jest test suite
β βββ index.js # Main server file
βββ client/ # Frontend (React + Vite)
β βββ src/
β β βββ components/ # React components
β β βββ hooks/ # Custom hooks
β βββ tests/ # Vitest test suite
β βββ vite.config.js # Vite configuration
βββ README.md # This file
- Use Good Names: Clear, descriptive variable and function names
- Make Data Meaningful: Proper data structures and types
- One Method/One Job: Single responsibility principle
- Don't Repeat Yourself: DRY principle with reusable functions
- Don't Hardcode: Configuration over hardcoded values
- Demand-Pull: Client requests data when needed
- Data-Push: Server streams responses in real-time
- Callback Pattern: Event-driven component communication
- Typed Events: Type-safe message passing
- Layered Architecture: Clear separation of concerns
- RESTful Communication: HTTP/REST for API endpoints
- Component Composition: Reusable React components
- Error Handling: Graceful failure management
# server/.env
PORT=3001
OLLAMA_URL=http://localhost:11434
MODEL_NAME=llama3
CLIENT_URL=http://localhost:3000# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# Start Ollama service
ollama serve
# Pull the model
ollama pull llama3GET /health- Health checkPOST /chat- Chat with Hooper (streaming response)GET /ollama/status- Ollama service status
// Chat with Hooper
const response = await fetch('/api/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message: 'Who is the best basketball player?' })
});
// Stream response
const reader = response.body.getReader();
// Handle streaming data...- Unit Tests: Individual functions and methods
- Integration Tests: API endpoints with Supertest
- Mock Testing: External dependencies properly mocked
- Coverage: 80%+ for all business logic
- Component Tests: React components with user interactions
- Integration Tests: Component communication
- User Interaction Tests: Form handling, event simulation
- Coverage: 80%+ for all components
# Backend
cd server && npm run dev
# Frontend
cd client && npm run dev# Build frontend
cd client && npm run build
# Start backend
cd server && npm start