A full-stack conversational AI application built with React, FastAPI, Groq API, and Redis. Includes a companion chatbot frontend and an admin dashboard to view all user conversations and metadata.
- Frontend: freetalk.imranansari.in
- API Docs: api.freetalk.imranansari.in/docs
- π¬ Real-time chat with Groq API-powered LLM
- π Multi-language support β Hindi, English, Hinglish
- π₯ Dynamic companion persona β Priya (for male users) / Imran (for female users)
- π± Device detection β tracks device name per user
- πΎ Full chat history β stored in Redis, persists across sessions
- π§ Configurable AI model β model specified via
.env(default: Groq's open-source 120B) - π¨ Beautiful dark UI β rose/purple accent theme
- π‘οΈ Secure login β HTTP Basic Auth with credentials from
.env - π₯ User management β browse all users with metadata
- π¬ Full chat history β view complete conversation for any user
- π User metadata β device name, gender, message count, first/last seen timestamps
- π Search & filter β find users by ID, device, or gender
freetalk-v2/
βββ backend/ # FastAPI server
β βββ main.py # Core API + admin routes
β βββ requirements.txt
β βββ .env.example
βββ frontend/ # User chat app (React + Vite)
β βββ src/
β β βββ App.jsx # Main app logic
β β βββ components/ # Chat, header, input, welcome
β β βββ utils/api.js # API client
β β βββ App.css # Dark theme styles
β βββ index.html
β βββ package.json
β βββ vite.config.js
βββ admin/ # Admin dashboard (React + Vite)
βββ src/
β βββ App.jsx # Auth + dashboard router
β βββ Login.jsx # Login page
β βββ Dashboard.jsx # Main admin UI
β βββ UserList.jsx # User list sidebar
β βββ ChatView.jsx # Chat history viewer
β βββ admin.css
β βββ main.jsx
βββ index.html
βββ package.json
βββ vite.config.js
- Groq API key (get one from console.groq.com)
- Redis running on
localhost:6379 - Node.js 16+ and Python 3.8+
cd backend
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
# Install dependencies
pip install -r requirements.txt
# Copy and edit .env
cp .env.example .env
# Set ADMIN_USERNAME, ADMIN_PASSWORD, GROQ_API_KEY, and GROQ_DEFAULT_MODEL
# Run server
uvicorn main:app --reload --port 8000Backend will be live at: http://localhost:8000
cd frontend
# Install dependencies
npm install
# Run dev server
npm run devFrontend will be live at: http://localhost:5173
cd admin
# Install dependencies
npm install
# Run dev server (runs on port 5174)
npm run devAdmin dashboard will be live at: http://localhost:5174
REDIS_HOST=localhost
REDIS_PORT=6379
ADMIN_USERNAME=admin
ADMIN_PASSWORD=your_strong_password_here
GROQ_API_BASE_URL=https://api.groq.com/openai
GROQ_API_KEY=your_groq_api_key_here
GROQ_DEFAULT_MODEL=openai/gpt-oss-120b
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5174REDIS_HOSTβ Redis hostname (default:localhost)REDIS_PORTβ Redis port (default:6379)ADMIN_USERNAMEβ Admin login usernameADMIN_PASSWORDβ Admin login passwordGROQ_API_BASE_URLβ Groq API base URL (default:https://api.groq.com/openai)GROQ_API_KEYβ Your Groq API key (required)GROQ_DEFAULT_MODELβ Model to use for chat (default:openai/gpt-oss-120b)ALLOWED_ORIGINSβ Comma-separated CORS origins
- First visit β User generates unique ID (stored in localStorage)
- Send message β App detects device name automatically
- Gender detection β API extracts gender from first messages
- Persona assignment:
- Male user β Companion name shows as "Priya"
- Female user β Companion name shows as "Imran"
- Other β Shows "FreeTalk"
- Full history stored β All messages saved in Redis with 30-day TTL
- Clear chat β Removes local data + generates new user ID (no API call)
- Login β HTTP Basic Auth with credentials from
.env - See all users β Lists users with metadata (device, gender, message count)
- View history β Click any user to see full chat conversation
- Filter/search β Search by user ID, device name, or gender
POST /chat/{user_id}β Send message (with device_name in body)GET /history/{user_id}β Fetch chat historyDELETE /history/{user_id}β Clear history (API kept, but frontend doesn't call it)GET /modelsβ List available models
GET /admin/usersβ List all users with metadataGET /admin/users/{user_id}/historyβ Get full chat history for a user
GET /healthβ Check API, Redis, and Groq connectivity
chat:history:{user_id} β [messages...] (TTL: 30 days)
chat:meta:{user_id} β {device_name, first_seen, last_seen, ...}
gender:{user_id} β "male" | "female" | "other"
freetalk:users β Set of all user_ids
Both apps use a dark theme with rose/purple accents:
Color Variables:
- Background:
#0f0f13 - Surface:
#1a1a24 - Accent (Priya):
#c2678a(rose) - Accent (Arjun):
#7c6af7(purple) - Text:
#e8e8f0
Fully responsive β works on desktop, tablet, mobile.
Backend uses Groq API models. The model is configured via GROQ_DEFAULT_MODEL in .env:
Recommended models:
openai/gpt-oss-120bβ Powerful open-source model (default)mixtral-8x7b-32768β Fast and efficientllama2-70b-4096β High quality responses
View all available Groq models at console.groq.com.
- Admin login β HTTP Basic Auth (use HTTPS in production!)
- User IDs β Random, non-sequential
- No passwords stored β Credentials in
.envonly - Conversation privacy β Full history in Redis, admin-only access
For production:
- Use HTTPS/TLS
- Add rate limiting
- Implement JWT or OAuth for admin
- Use environment variables from a secrets manager
When user clicks "Clear":
- β Removes all localStorage data
- β Generates new user ID
- β Does NOT call delete API (history remains in Redis for admin)
- β Starts fresh conversation
- Sort by last seen (most recent first)
- See device type (iPhone, Android, Windows PC, Mac, etc.)
- Message count per user
- First and last seen timestamps
- Gender indicator
- Full conversation history
- Timestamps for each message (if available)
- User vs bot messages clearly marked
- User metadata (device, gender, first/last seen)
- Verify
GROQ_API_KEYis set correctly in.env - Check your Groq API key has not expired on console.groq.com
- Ensure
GROQ_DEFAULT_MODELexists and is available in your Groq account - Check backend logs for connectivity errors
# Check Redis is running
redis-cli ping
# Should return: PONG
# If not installed:
sudo systemctl start redis # Linux
brew services start redis # macOS- Verify
ADMIN_USERNAMEandADMIN_PASSWORDin.env - Check backend is running on port 8000
- Clear browser auth cache (open dev tools β Network tab)
- Check backend runs on
http://localhost:8000 - Verify CORS is enabled (should be by default)
- Check
.envin frontend/admin for correctVITE_API_URL
- Chat history is never deleted from Redis, only when admin explicitly uses DELETE API
- User IDs are persistent β same ID = same user across sessions
- Model is set via
GROQ_DEFAULT_MODELin.envat startup (not dynamically changeable) - Admin dashboard is separate app on port 5174 to keep concerns clean
- Previously used Ollama for local model inference, but switched to Groq API for better performance and reliability
This project demonstrates:
- Full-stack development (React + FastAPI)
- Real-time streaming (SSE)
- Multi-language NLP prompt engineering
- Redis for session management
- Admin authentication and authorization
- Responsive UI design
MIT β Free to use and modify.
Built with β€οΈ using React, FastAPI, Groq API, and Redis