AI chatbot with React frontend and FastAPI backend powered by local Ollama.
- Node.js (v14+)
- Python 3.11
- Ollama installed locally
# Install Ollama (macOS/Linux)
curl -fsSL https://ollama.ai/install.sh | sh
# Pull Qwen model
ollama pull qwen2.5:3b
# Start Ollama server
ollama servecd backend
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000cd frontend
npm install
npm startVisit http://localhost:3000
ConvoAI/
├── backend/ # FastAPI server
│ ├── app/
│ │ ├── main.py # API endpoints
│ │ ├── ollama_service.py # Ollama LLM wrapper
│ │ └── __init__.py
│ ├── requirements.txt
│ ├── Dockerfile
│ └── runtime.txt
├── frontend/ # React app
│ ├── src/
│ │ ├── App.js
│ │ ├── App.css
│ │ └── index.js
│ ├── public/
│ ├── Dockerfile
│ └── package.json
├── docker-compose.yml
├── knowledge/ # Optional RAG documents
└── .env.example
Create .env file:
# Backend Configuration
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=qwen2.5:3b
OLLAMA_TIMEOUT=60
PORT=8000
FRONTEND_ORIGIN=*
# Optional RAG Configuration
ENABLE_RAG=0
# Frontend Configuration
REACT_APP_API_URL=http://localhost:8000POST /api/chat- Send message, get AI responsePOST /api/chat/stream- Streaming chat responseGET /api/health- Health check
Example:
curl -X POST "http://localhost:8000/api/chat" \
-H "Content-Type: application/json" \
-d '{"message": "Hello"}'- Ensure Ollama is running on host:
ollama serve- Start application:
docker-compose up --buildBackend:
cd backend
docker build -t convoai-backend .
docker run -p 8000:8000 convoai-backendFrontend:
cd frontend
docker build -t convoai-frontend .
docker run -p 3000:3000 convoai-frontendcd backend
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000cd frontend
npm install
npm startcd frontend
npm run build- "Ollama not available": Make sure
ollama serveis running - "Model not found": Run
ollama pull qwen2.5:3b - "Port already in use":
lsof -ti:8000 | xargs kill -9 - Build fails:
rm -rf node_modules package-lock.json && npm install
To enable knowledge base:
- Add documents to
knowledge/folder - Set
ENABLE_RAG=1in.env - Restart backend
MIT