Tech=>Node.js
Database=>MySql
ORM =>Sequelize
Database_backup_file_name=>db_backup_chat_app.sql
Front_end=>src/view
Creation of chat application applying socket.io including private chat and broadcast which is administered by passport login moreover Sequelize ORM along with migration integration beside MySql database with proper MVC structure in nodejs.
link of socket.io : https://socket.io/get-started/private-messaging-part-1/
link of migrations : https://sequelize.org/master/manual/migrations.html
- login system with passport to store user info in session
- user can share both private and broadcast message
- store every message in db with the help of sequilize
- retrive chat data from db and display it
- chat stays as it even on page refresh because of sessionStorage
- list of available users and also remove the user from list if user disconnects
- proper comments for understandings
bcrypt @5.0.1
connect-flash @0.1.1
dotenv @10.0.0
ejs @3.1.6
express @4.17.1
express-session @1.17.2
mysql2 @2.2.5
passport @0.4.1
passport-local @1.0.0
sequelize @6.6.2
socket.io @4.1.2
To install the Sequelize CLI:
npm install sequelize-cli
To create an empty project you will need to execute init command
npx sequelize-cli init
To create a model named User
npx sequelize-cli model:generate --name User --attributes firstName:string,lastName:string,email:string
type the following command to run to migration
npx sequelize-cli db:migrate
You can revert to old state by just running a command.
npx sequelize-cli db:migrate:undo:all
create a seed file which will add a demo user to our User table.
npx sequelize-cli seed:generate --name demo-user
To insert demo user inserted into User table type the following command.
npx sequelize-cli db:seed:all
All the Seeders can be undone if they are using any storage.
npx sequelize-cli db:seed:undo:all
Open the directory and install all the required modules by typing the following command
npm i
to create migration with database also insert data as seeds type following command
npm run migrate
After module installation just simply typewrite the following code to start the node server
npm start
to empty the all table data type the following command
npm run clear_data
to remove all tables type the following command
npm run clear_table
Paste this in browser:-http://127.0.0.1:8081/