Real-time, turn-based chat game that pairs you with either another user or an LLM bot. After the conversation ends, both sides submit a guess: Human or AI.
If this is still up, it's hosted on https://bot-or-human-cse-312.onrender.com/
- Real-time messaging over Socket.io with pairing + disconnect handling
- Turn-based chat flow with timers and per-session limits
- AI opponent powered by Google Gemini (Gemma) via an Express API
- Prompt templating + randomized “personality” presets
- Post-chat identity guess collection
- Frontend: Vite + React + TypeScript,
socket.io-client - Backend: Node.js + Express + Socket.io
- AI: Google Gemini API (Gemma model)
- Node.js (recommended: 18+)
All app code lives in root/.
- Install dependencies
cd root
npm install- Configure environment variables
Create root/.env (or copy from root/.env.example) and set:
GEMINI_API_KEY=YOUR_KEY_HERETerminal 1 (Socket.io + Express API on port 3001):
cd root
node server.jsTerminal 2 (Vite dev server on port 5173):
cd root
npm run devOpen the app at the URL printed by Vite (typically http://localhost:5173).
cd root
npm run buildThen run the server in production mode so it serves dist/:
cd root
set NODE_ENV=production
node server.jsThe server listens on PORT (defaults to 3001).
- The frontend initiates a session when you click Start Chat.
- For human vs. human sessions, the Socket.io server matches two waiting clients and emits pairing metadata.
- For human vs. AI sessions, the client generates bot responses by calling
POST /api/gemini. - The AI prompt is assembled from:
root/src/assets/prompt.txt(template)root/src/assets/personalities.txt(randomized personality blocks)
Client → Server
choose role— identifies the client role for masking/partner metadatajoin chat— enter the matchmaking queuechat message— send a message (server relays and echoes)submit guess— submit identity guess after the chat
Server → Client
waiting— queued for a matchpaired— matched with a partner (includes who goes first)chat message— delivered messages (including echo)partner guess— partner’s submitted guesspartner disconnected— partner dropped mid-chat
- Vite proxies
/api/*to the backend server during development (seeroot/vite.config.ts). - Chat limits/timers are implemented as constants in
root/src/App.tsx.