Loading repository data…
Loading repository data…
RishiKumar1917 / repository
Real-time chat demo built with a simple HTML/CSS/JavaScript frontend and an Express.js backend. Realtime replies are delivered via WebSockets and the bot uses a locally-run TinyOllama (or compatible Ollama-like) model for generating responses. Postman can be used to test the REST API endpoints. This repository demonstrates a lightweight real-time
A small real-time chat demo built with a simple HTML/CSS/JavaScript frontend and an Express.js backend. Realtime replies are delivered via WebSockets and the bot uses a locally-run TinyOllama (or compatible Ollama-like) model for generating responses. Postman can be used to test the REST API endpoints.
This repository demonstrates a lightweight real-time chat architecture suitable for local experimentation with small LLMs and websockets.
Your repository may look similar to:
Adjust paths below to match this repo layout if different.
http://localhost:11434/api/generate — your setup may differ).In this project you will provide that URL to the backend through environment variables (example below).
Create a .env file in the backend folder (or project root) with values like:
PORT=3000
WS_PORT=3000 # if same as HTTP server, websockets are mounted there
TINY_OLLAMA_API_URL=http://localhost:11434/api/generate
TINY_OLLAMA_MODEL=my-model # optional, if your local server needs a model name
API_KEY= # optional, if your local runtime needs auth
Adjust names and values to match your setup.
Change to the backend folder (if present):
cd backend
or root if server is at repo root.
Install dependencies:
npm install
Start the server:
npm run start
or for development with live reload:
npm run dev
Typical server responsibilities:
POST /api/reply for non-realtime message/response exchange/ws or using ws / socket.io) to push streaming/realtime replies to connected clientsIf the Express server serves static files, open your browser at:
http://localhost:3000
If the frontend is just static files in /public, you can also open index.html directly (if you use WebSocket to ws://localhost:3000 make sure CORS/WS host matches).
Example WebSocket client snippet (frontend JavaScript):
const socket = new WebSocket('ws://localhost:3000'); // or ws://localhost:3000/ws
socket.addEventListener('open', () => {
console.log('WS connected');
});
socket.addEventListener('message', event => {
const data = JSON.parse(event.data);
// handle partial/streamed responses or full reply messages
console.log('message from server:', data);
});
// send a message to the server
function sendMessage(text) {
const payload = { type: 'message', text };
socket.send(JSON.stringify(payload));
}
The UI is built with plain HTML/CSS/JS: a message input, a send button, and a message list. The frontend listens for websocket messages and appends replies in real time.
A simple REST endpoint can be used for debugging or non-realtime clients.
Example: POST /api/reply
http://localhost:3000/api/replyPOST{
"message": "Hello, bot!"
}
{
"reply": "Hi — this is the bot response..."
}
Use Postman to send a request to the endpoint above to inspect server-to-model behavior and returned replies.
TINY_OLLAMA_API_URL environment variable is correct.Contributions welcome. Create an issue or open a PR with small, focused changes. If you add features, update the README with new commands or environment variables.
Add license text here (e.g., MIT) or create a LICENSE file in the repo.
If you want, I can:
Tell me which one you'd like next and I’ll generate it.