← All projects

Full-stack · Personal project

Full-stack Chat App

A full-stack chat app where registered users find each other and message one another. I built it to learn a modern JavaScript stack end to end.

  • React
  • Vite
  • Node.js
  • Express
  • Mongoose
  • MongoDB Atlas
  • JWT

Overview

The React front end (built with Vite, React Router and React Bootstrap) talks to a Node.js/Express REST API for accounts, chats and messages, with app-wide state held in React context. Users, chats and messages live in a MongoDB Atlas cloud database via Mongoose models.

The hardest part was the start: working out how to structure a project with a separate client and server. After that it came together like any other full-stack build, and it gave me hands-on experience with a document database alongside the SQL databases I'd used before.

Security

  • Password hashing: bcrypt with a per-user salt.
  • Stateless authentication: the server signs a JSON Web Token on login that expires after three days.
  • Server-side validation: email format and password strength checked with validator.js before an account is created.
  • Configuration: the database connection string and JWT signing key are read from environment variables.

What I'd improve next

  • Keep the session token in an httpOnly, SameSite cookie instead of localStorage, so an XSS bug can't steal it.
  • Push new messages instantly over WebSockets (Socket.IO), authenticated with the same token, instead of fetching them over REST.
  • Require the token on every API route and rate-limit the login endpoint.