This project is a real-time data visualization application built using Express.js for the API and WebSocket for communication. It sends random data from the server to the frontend every 5 seconds, which is then displayed as a dynamic bar chart. This allows users to see live updates of the data without needing to refresh the page.
- Create an API using Express.js and WebSocket with TypeScript sharing the same port.
- Send random data from the server to the frontend every 5 seconds using WebSockets with "ws" dependency.
- Display the data as a dynamic bar chart.
- Obtain data from http endpoint and display it in the frontend.
To set up the project, follow these steps:
- Clone the repository:
git clone https://github.com/emisasal/express-websocket.git
- Navigate to the project directory:
cd express-websocket
- Install dependencies in
/backend
and/frontend
withnpm install
- Create a
.env
file and set up the backend port - Start the server with
npm run dev
in/backend
, and the frontend withnpm run dev
in/frontend
- TypeScript
Backend:
- Node.js
- Express.js
- ws (WebSocket)
Frontend:
- React (Vite)
- Recharts (Chart)
- Axios