Chat Application — Sprint 2
A minimal chat app with an Express backend and a plain HTML/JS frontend.
chat_app/
├── backend/
│ ├── server.js # Express REST API (GET/POST messages, in-memory store)
│ ├── websocket.js # Standalone WebSocket server (broadcasts messages to clients)
│ └── package.json
├── front/
│ ├── script.js # Polls the REST API and renders/sends messages
│ ├── web.js # WebSocket client (connects to ws://<host>)
│ └── style.css
├── index.html # Entry page, loads front/script.js
└── Dockerfile # Builds and runs the backend (server.js)
The REST API (backend/server.js) exposes:
GET /get/messages— returns all stored messagesPOST /post/messages— appends a{ user, message }payload to the in-memory store
Messages are not persisted — they reset whenever the server restarts.
cd backend
npm install
npm startThe server listens on http://localhost:3000.
There is also a separate WebSocket server (backend/websocket.js) that broadcasts
incoming messages to all connected clients on port 3000. It is not started together
with server.js — run it directly with node backend/websocket.js if you want the
WebSocket-based flow (paired with front/web.js) instead of the REST polling flow.
Open index.html in a browser (or serve it with any static file server). It loads
front/script.js, which fetches and posts messages against the API URL configured at
the top of that file. Update that URL to point at your own backend deployment.
Build and run just the backend:
docker build -t chat-app-backend .
docker run -p 3000:3000 chat-app-backend