It's a chat project that was created using Create React App, Node.js, WebSocket and Firebase. The project contains the following components:
- Login page
- Authorization page
- Chat page
- Profile menu
- Contacts add/delete modal window
- Go to the directory
chat-app/server
and run the commandnpm install
- Go to the directory
chat-app
and also run the commandnpm install
- After this go to the directory
chat-app/server
and start the server (port 4200) with the commandnode app.js
- And then go to the directory
chat-app
and start the client (port 3000) with the commandnpm start
- The project will be available at
http://localhost:3000/
- Database operations are implemented on the client using Firebase (see directory
src/services
) - WebSocket is used to send messages and update the chat. There are different types of WebSocket messages (see file
server/services/handleClients.js
):type: '__COMMON__'
is used for chat messaging between the user and his friendtype: '__INIT__'
is used to remember the user's client on the servertype: '__UPDATE__'
is used to notify other clients of user's changes (edit profile and add/delete contacts)
- Receiving and sending WebSocket messages is implemented in the component
Main
. DifferentuseEffect()
hooks react to state changes caused by WebSocket messages - Almost all database operations require user's id. After successful Authorization the received id from Firebase is saved in
localStorage
- Every two seconds the client polls the server to determine a current status of each contact (online/offline)
- Form validation is implemented using the lib
react-hook-form
- Opening the modal window blocks clicking on the outside zone with using the underlay (component
Substrate
) - The username has two parts (for example Randy Marsh). So the filter by name first tries to check for a complete match with filter's text and if it fails it searches for a match by parts of the username
- The user notification system is implemented using the component
Alert
- An example of the database structure can be found in the directory
database-example
(json file)