Skip to content

BARCELONA | Oct2025-1 | June Monton| Decomposition | Sprint 2 | Chat App - #112

Closed
juneMonton wants to merge 9 commits into
CodeYourFuture:mainfrom
juneMonton:world-chat
Closed

BARCELONA | Oct2025-1 | June Monton| Decomposition | Sprint 2 | Chat App#112
juneMonton wants to merge 9 commits into
CodeYourFuture:mainfrom
juneMonton:world-chat

Conversation

@juneMonton

Copy link
Copy Markdown

Description

Built and deployed a real-time chat application using Express and Socket.IO. Users can send messages, view chat history, and receive new messages instantly without refreshing the page. The frontend and backend are deployed separately and communicate over a WebSocket connection.

Changelist

  • Created Express backend with Socket.IO support
  • Implemented real-time messaging between connected users
  • Added chat history for newly connected users
  • Added username persistence using localStorage
  • Added online user counter
  • Added join announcements for users entering the chat
  • Added message timestamps
  • Added Enter-to-send functionality, with Shift+Enter for a new line
  • Added auto-scroll to latest message
  • Added own-message highlighting to distinguish sent from received
  • Styled chat interface with responsive CSS
  • Configured CORS and Express middleware
  • Added a /health endpoint for deployment health checks
  • Capped chat history at 200 messages and message length at 500 characters
  • Re-sent the username on reconnect so messages keep the correct author
  • Moved the backend URL into config.js so the frontend can be hosted separately
  • Added .gitignore and removed node_modules from version control
  • Added netlify.toml and render.yaml to configure both deployments
  • Deployed the frontend on Netlify and the backend on Render

Deployed Links

Deployed FrontEnd - https://june-chat-app.netlify.app
Deployed BackEnd - https://world-chat-backend-zlha.onrender.com

Notes

  • Messages are stored in memory, so the chat history resets when the backend restarts.
  • The backend sleeps after 15 minutes of inactivity on the free hosting tier, so the first load can take up to a minute to wake it.

Express + Socket.IO backend with an in-memory message history, and a
vanilla JS frontend. Supports the three required behaviours plus an
online-user count and join announcements.

Notable choices:
- Message history and individual messages are both capped so a small
  free-tier host cannot be pushed out of memory.
- The client re-sends its username on every connect, not just the first,
  because hosts drop idle sockets and the server keys users by socket id.
- The chat box is cleared before replaying history, so a reconnect does
  not render the backlog twice.
Netlify serves the static frontend; the Socket.IO backend needs a
long-lived process with WebSocket support, which Netlify does not
provide, so it goes to Render instead.
Render assigns the backend URL when the service is created, so it cannot
be committed ahead of the first deploy. A Netlify build step now writes
front-end/config.js from the BACKEND_URL environment variable, which
keeps the deployed URL in Netlify's UI and out of source.

The script strips a trailing slash and fails the build on a value with
no scheme, so a typo surfaces as a red build rather than a site that
loads but never connects. With no variable set it emits an empty value,
which is exactly what local development needs, and reproduces the
committed config.js byte for byte.
The URL moved to a build-time environment variable, so the old message
sent anyone debugging a dead chat to the wrong place.
A build that cannot see the BACKEND_URL variable was blanking the
address, which is indistinguishable from a build that never ran. The
committed value now stands unless the variable overrides it.
@github-actions

Copy link
Copy Markdown

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Wrong number of parts separated by |s

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@juneMonton juneMonton closed this Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant