Coder Social home page Coder Social logo

kjuliapoot / chat-app-mern Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vo-huy-khoa/chat-app-mern

0.0 0.0 0.0 1.07 MB

A real-time chat application built using the MERN stack and Socket.io

Home Page: https://chatapp-vo-huy-khoa.vercel.app

JavaScript 30.08% TypeScript 64.96% CSS 3.19% HTML 1.77%

chat-app-mern's Introduction

Typescript React Node.js Express.js MongoDB Socket.io

Chat App MERN

The Real Time Chat Application is a messaging platform that enables users to communicate with each other in real-time. It is built using Typescript, React, Express, Mongoose, and Socket.io, which are all modern technologies for developing web applications.

Index

Demo

Desktop:

chat app

Smart Phone:

chat app


Features

  • Use Express to build the backend.
  • Use React to build the frontend.
  • Authenticates via email and password.
  • Real-time communication between a client and a server using Socket.io.
  • Uses MongoDB, Mongoose for storing and querying data.

Installation

Running Locally

Make sure you have Node.js and npm installed.

  1. Clone repository:

    $ git clone https://github.com/Vo-Huy-Khoa/chat-app-mern.git
    $ cd chat-app-mern
    

    Run Backend:

    cd backend
    npm i
    npm run dev

    Run Frontend:

    cd frontend
    npm i
    npm run start

How It Works

MongoDB

You need to create a database on MongoDB, then create a database user, get the MongoDB URI, and assign it to dbURI.

Database

Mongoose is used to interact with a MongoDB.

Schemas

There are two schemas; users and rooms.

Each user has a username, password,and picture. If the user is logged via username and password, and the if logged in via a social account, then the password will be null.

Models

Each model wraps Mongoose Model object, overrides and provides some methods.

Sockets

Having an active connection opened between the client and the server so client can send and receive data. This allows real-time communication using sockets. This is made possible by Socket.io.

The client starts by connecting to the server through a socket (maybe also assigned to a specific namespace) . Once connections is successful, client and server can emit and listen to events.

Structure of the project:

BackEnd

src
|
├── configs
|   └── db.ts
├── controllers
|   └── UserController.ts
│   └── MessageController.ts
├── middleware
|   └── auth.ts
│   └── token.ts
├── models
|   └── User.ts
|   └──Message.ts
├── routes
|   └── index.ts
└── server.ts

FrontEnd

src
├── components
│   └── Account.tsx
│   └── Image.tsx
│   └── index.ts
├── hooks
│   └── useDebounce
│   └── index
├── layouts
│   └── auth.tsx
│   └── dashboard.tsx
│   └── index.ts
├── pages
│   └── auth
│       └── sign-in.tsx
│       └── sign-up.tsx
│       └── index.ts
│   └── dashboard
│       └── home.tsx
│       └── notification.tsx
│       └── sidebar.tsx
│       └── index.ts
├── redux
│   └── actions
│       └── sign-in.tsx
│       └── index.ts
│   └── reducers
│       └── visibility.ts
│       └── rootReducer.ts
│   └── initState.ts
│   └── store.ts
├── services
│   └── auth.ts
│   └── dashboard.ts
│   └── index.ts
├── socket.tsx
├── route.tsx
├── App.tsx
└── index.tsx

chat-app-mern's People

Contributors

vo-huy-khoa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.