ChitChat- Real Time Messaging System
Table of Contents
- Introduction
- Used Technologies
- Core Features
- Live Demo
-
Source Code - github.com/hunter-420/ChitChat
-
Building Process Step By Step
Introduction
ChitChat empowers users to create custom usernames and
facilitates easy search functionalities, allowing users to
initiate conversations effortlessly. The platform supports both
private and group chats.
The project utilizes a modern tech stack, including NextJS,
Apollo GraphQL, Chakra UI, Node.js, MongoDB, and Prisma, to
build a scalable and responsive application. Each technology has
been carefully selected to ensure high performance and a
seamless user experience. The implementation process follows a
structured approach, guiding users from setting up the project
to deploying a fully functional messaging system.
Used Technologies
- NextJS
- Appllo GraphQL
- Chakra UI
- NodeJs
- Mongo DB
- Prisma
Core Features
- Users can create custom username
- Users can search for users to create conversation
- Private One-on-One conversations
- Group conversationi with many people as they like
- Dot indication for which message is opened or which not
- Users can both leave conversation as well as delete
-
Able to edit user Participants in a particularconversation
either add or remove users
Building Process
-
Setup
NextJS
Project &
Folder Structure ✅
-
NextAuth
and
Google Cloud Console✅
-
NextAuth
Prisma Adapter
setup (Creating a prisma schema)✅
-
Creating
MongoDB Database
(Prisma/Mongo, Mongo Compass GUI)✅
-
Creating Users (NextAuth Google Provider & useSession hook✅
-
Chakra UI
setup (Chakra Provider & themes)✅
-
Creating Custom Usernames (SSR w/ getServerSideProps,
session type declaration, Authentication React Components)✅
-
Apollo GraphQL
-
Creating the Backend (NodeJs, Apollo server setup, Apollo
server Express)
-
Creating
GraphQL Schema’s , Type Definitions, and Resolvers
- Apollo’s Query & Mutation React hooks
- Create Username Mutation 1 (Writing Mutation Strings)
- Apollo React Hooks w/ TypeScript
-
Create Username Mutation 2 (Trigger Mutation, Hitting the
API, CORS)
- Resolver Arguments & Server Context (GraphQL Context)
-
Backend Prisma Setup (Prisma Client, Schema & MongoDB
Connection)
- createUsername Resolver Function
- NextAuth Session Callback (custom session properties)
-
Complete Create Username Feature (Error Handling &React Hot
Toast Notifications)
-
React Component Architecture (Conversation & Feed Wrapers)
-
Create Conversation Model (Chakra Modal,Flex,Stack
Components & Media Queries)
- Search Users React Components
-
Search Users Query (SearchUsers Query String, useLazyQuery
Apollo Hook)
-
Search Users Backend (searchUsers Resolver, Database Search
w/Prisma)
- User Search List Component
- Selecting Conversation Participants
-
Create Conversation 1 (Create Button, Conversation typeDefs
& resolvers)
-
Create Conversations 2 (createConversation Query String &
Mutation Call)
- Database Modelling & Prisma Schema
-
createConversation Resolver (Prisma Create & Prisma
Validator)
- Storing Conversations & Participants
- Redirecting Users w/ Next.JS Router
-
Conversations Query 1 (conversations Resolver definition,
ConversationFields typeDefs)
-
Conversations Query 2 (conversations useQuery, Prisma
TypeScript Types)
-
Conversations Query 3 (conversations Resolver completion,
fetch conversations)
- ConversationItem Component Creation
-
Subscriptions & WebSockets w/ Apollo Client (graphql-ws,
wsLink, splitLink)
-
Subscriptions & WebSockets w/ Apollo Server (WebSocket
Server, Subscription endpoint & Context)
-
conversationCreated Subscription Backend (Publish/Subscribe
Pattern, PubSub Class)
-
conversationCreated Subscription Frontend (subscribeToMore
function, updateQuery)
- Testing the conversationCreated Subscription
-
conversationCreated Subscription Troubleshooting (fixing
typeDefs)
- Filtering Subscription Events (withFilter function)
- ConversationItem & FeedHeader Components
- Apollo v4 Migration
- Frontend Package Upgrade (Next.js 13 Migration)
- Sending Messages 1 (sendMessage mutation)
-
Sending Messages 2 (messageSent subscription & Conversation
Messages query backend)
-
Sending Messages 3 (Conversation Messages query frontend)
- Sending Messages 4 (onSendMessage function invocation)
-
Sending Messages 5 (subscribeToMoreMessages subscription
invocation)
- Message Feed (MessageItem component)
-
New Message Optimistic UI Rendering (Apollo Cache
reads/writes)
- Mark Conversations as Read
-
Real-time Conversation Updates (conversationUpdated
subscription)
- Deleting Conversations