it is a realtime chat application where users can chat with each other. It is created using Node.js, Express, MongoDB, Socket.io, Bcrypt, Jsonwebtoken, and Cookie-parser.
- express: To initialize express server
- socket.io: To create real time chat application
- nodemon: To restart server automatically
- dotenv: To use environment variables
- bcrypt: To hash password
- jsonwebtoken: To create token for authentication
- mongoose: To connect to MongoDB
- cookie-parser: To parse cookies passsed to req.body
- jwt are used to create token for authentication
- To generate a secure random number as your jwt secret key, use your bash and type: openssl rand -base64 32'
Backend is created using Node.js and Express. MongoDB is used as database. Socket.io is used to create real time chat application. Bcrypt is used to hash password. Jsonwebtoken is used to create token for authentication. Cookie-parser is used to parse cookies.
We used postman api to test our backend routes.
Backend files and folders:
- routes folder: contains auth.routes.js where we define our authentication routes(signup, login and logout) to be used in server.js
messages.routes.js where we define our message routes (api/messages/send/id)to be used in server.js
user.routes.js where we define our user routes to be used in server.js - controllers folder: contains auth.controller.js where we define our authentication controller function(login, signup and logout) to be used in auth.routes.js
messages.controller.js where we define our {sendMessage and getMessage} functions to be used in messages.routes.js
user.controller.js where we define our {getUserForSidebar} functions to be used in user.routes.js - db folder: contains connectToMongoDB.js where we connect to MongoDB database
- server.js: contains all the backend routes
-
models folder: contains user.model.js where we define our user schema
message model.js where we define our message schema
conversation.model.js where we define our conversation schema - middleware folder: contains protectRoute.js, this file protects the routes from unauthorized access
- utils folder: contains generateToken.js where the token used for authentication and security is generated