This project is a real-time video and audio communication application that allows multiple users to join a call. It allows to share their webcam, screen and interact via chat. It leverages WebRTC to handle peer-to-peer streaming, ensuring low-latency and high-quality audio and video transmission.
The application provides an user interface built with React and enhanced using Shadcn components.
-
WebRTC: for peer-to-peer audio and video streaming.
-
ExpressJS: for the API's and for handling signaling between peers.
-
React: a powerful JavaScript library for building user interfaces using a component-based architecture.
-
Shadcn: for reusable UI components and consistent styling.
This project uses ngrok for the development, since WebRTC requires https and it's a quick solution.
To expose both back-end and front-end via ngrok, use the following configuration file:
version: "3"
agent:
authtoken: <your_token>
tunnels:
back-end:
addr: <port 1> # e.g., 3000
proto: http
front-end:
addr: <port 2> # e.g., 5173
proto: httpngrok config editngrok start --all-
Copy
.env.templateto.env.developmentfor the development environment variables, and setVITE_SERVER_URLto the ngrok domain of the back-end, for example:VITE_SERVER_URL=https://f43daf222de4.ngrok-free.appThis file will be used when
npm run devis executed. -
Copy
.env.templateto.env.productionfor the production environment variables, and setVITE_SERVER_URLto empty (since the front-end will be served by the back-end server in production):VITE_SERVER_URL=This file will be used when
npm run buildis executed.
-
Copy
.env.templateto.env: -
Set the following environment variables:
PORT=<your_backend_port> # e.g., 3000 SECRET_TOKEN=<your_secret_token> # used for JWT
Run the following in both the front-end and back-end directories:
npm installIn both front-end and back-end folders, run the following command:
npm run devYou can now access the app using the ngrok front-end URL.
-
In both
front-endandback-endfolders, run the following command:npm run build
This will create a
distdirectory in bothfront-endandback-end. -
Create a folder named
clientin the back-end. This folder will contain the production code of the front-end. -
Move the
distdirectory created in the front-end into theclientdirectory of the back-end. In this way, there will be a folderclient/distinside the root folder of the back-end.
You only have to start the back-end server:
npm startNow the back-end server is serving both the API's and the front-end app.
It's done! π