CHAT Application Hard Bound
CHAT Application Hard Bound
Submitted By
Mohit Bisht (06717704423)
Rishabh Gupta (10017704423)
Affiliated to
(GURU GOBIND SINGH INDRAPRASTHA UNIVERSITY, DELHI)
Jan-April,2020
CERTIFICATE
This is to certify that this project entitled “Chat Application” submitted in partial fulfillment of the
1st semester of MCA to the VIPS, done by Mr. Mohit Bisht, Roll No. 06717704423 and Mr.
Rishabh Gupta (10017704423) is an authentic work carried out by him under my guidance.
“CHAT APPLICATION”
2. INTRODUCTION
The online chat application has been developed to override the problems prevailing in the
practicing manual system. This software is supported to eliminate and in some cases reduce
the hardship faced by this existing system. By this it will provide user friendly interaction to
user.
We use chat applications like Whatsapp, Telegram, Facebook Messenger, WeChat, Snapchat,
Discord, iMessage, etc in our daily lives, so why not create one ourselves?
We will can create an simple chat application using Django. The chat application can be a small
person-to-person message application.
4. OBJECTIVE
The main objective of online chat application is to manage the details of chat application,
online, chat, user chat History. It manages all the information about chat application, chat char
profile, chat history. The project is totally built at administrative end and thus only the
administrator is guaranteed the access, the purpose of the project is to build an application
program to reduce the manual work for managing the chat application.
Improve customer experience – Web chat allows visitors to make queries that can be
answered quicker than an email or phone call. When customers receive immediate solutions,
they have a better brand experience.
Deliver real time assistance – Easily connect with your customers in real time with online
web chat to provide faster sales or support assistance.
5. SCOPE
As there are many MNC companies are coming into the markets and these companies will
provide various types of facility to customers to maintain there market coverage.
It may help collection perfect management in details. In a very short time, the collection will
be obvious, simple and sensible. It will help a person to know the management of passed year
perfectly and vividly. It also helps in current all work relative to online chat application.
It will be also reduced the cost of collecting the management and collection procedure will go
on smoothly.
In computer system the person has to fill the various forms and number of copies of the form
can be easily generated at a time.
In computer system, it is not necessary to create the manifiest but we directly print it which
saves our time.
6. FUNCTIONALITY
• It allows real time communication between businesses and customers on the website.
• It brings chat features for the website and help address sales and support related queries
during the customer journey.
• Providing best solution for customer in real time connection.
• Increase the efficiency of online chat
• It deal with monitor the information and transaction of chat profile
7. TOOLS AND PLATFORM
Platform: Django
7.1 Requirement
(Minimum specs)
Hard Disk:500 GB
Processor:Intel core i3
RAM: 4GB
Django Framework
Python
8. METHODOLOGY
Model Used: Iterative Enhancement Model
In the Iterative model, iterative process starts with a simple implementation of a small set
of the software requirements and iteratively enhances the evolving versions until the
complete system is implemented and ready to be deployed.
SUMMARY OF PROJECT
Online Chat Application, as described above, can lead to error free, secure, reliable and fast
management system. It can assist the user to concentrate on their other activities rather to
concentrate on the record keeping. Thus it will help organization in better utilization of
resources. The organization can maintain computerized records without redundant entries. That
means that one need not be distracted by information that is not relevant, while being able to
reach the information.
The aim is to automate its existing manual system by the help of computerized equipments and
full-fledged computer software, fulfilling their requirements, so that their valuable
data/information can be stored for a longer period with easy accessing and manipulation of the
same. Basically the project describes how to manage for good performance and better services
for the clients.
9. CONCLUSION
Our project is only a humble venture to satisfy the needs to manage their project work. Several
user friendly coding have also adopted. This package shall prove to be a powerful package in
satisfying all the requirements of the school. The objective of software planning is to provide
a frame work that enables the manger to make reasonable estimates made within a limited time
frame at the beginning of the software project and should be updated regularly as the project
progresses.
10.FUTURE SCOPE
It can be summarized that the future scope of the project circles around maintaining
information regarding:
• We can add printer in future.
• We can give more advance software for Online Chat Application including more facilities
• We will host the platform on online servers to make it accessible worldwide
• Integrate multiple load balancers to distribute the loads of the system
• Create the master and slave database structure to reduce the overload of the database queries
• Implement the backup mechanism for taking backup of codebase and database on regular basis on
different servers
11. CONTRIBUTION FOR PROJECT MAKING
This project is made by the individual with the help of some resources like python, Django.
All the working of this project is totally defined by me.
Resources used:
1)Python
2)Django
3)Javascript
CHAPTER1: PROBLEM FORMULATION
1.1 Introduction about the Problem
Any opportunity that allows you to keep in touch with your family and your loved ones is
supposed to be grabbed with both hands. Having a cell phone is the only thing you need in
order to install a chat application and enjoy an easier way of sending and receiving
messages.
But the main problem is privacy and distance . Means if the any person want to meet with
another person , he/she has to go with physically and it will take lots of time.
Another factor that can affect is that timing that means it is not necessary that when you go
to meet a person, it will be available. So to provide flexibility and independency of
messaging we need to introduce the chat Application.
Another problem which make sense for introducing the chat application is that online
criteria, means person’s chat are private and remain hack free.
Right now the technology that we used for making this chat application
WSGI stands for Web Server Gateway Interface, which is a specification that describes
how a web server communicates with web applications and how web applications can
be chained together to process one request.
b) SERVER
1. Setup an infra that takes care of saving messages as they come/go
2. Load balancing on the server to manage scale when the number of connections
increase/decrease
3. Id management to know which connection to use between two Id, maintaining
the messaging logic
4. Setup topics to manage delivering messages as well as push notes
5. Database management
c) Django models
A Django model is a table in your database. Up until now in this tutorial, output has
been static data from Python or HTML templates. Now we will see how Django allows
us to work with data, without having to change or upload files in the process.
1.3 Need of computerization
• There is need for computerization for locally host the server for development stage.
• Here we also use the Django database for storing the messages
Technical Requirement: For making of this project, the resources that are required is
Software – python, Django, and Hardware- window OS or any other platform, 2GB of ram,
20GB of Hard disk.
python= www.python.org
*Objective: This chat application is basically build for communication like Whatsapp.
The main objective is to provide faster and reliable communication between the user. And
after some modification we can also integrate with some major ecommerce websites.
*Performance: The performance of this project is optimizing. This project require less
resources and able to perform whole operation effectively.
*Interface: The interface of this project is also very simple. After interacting with UI user
can easily navigate through the options.
*Reliability: This chat application some tokens can be used for sending and retrieving
messages like (CSRF token). All the data that being sending or retrieving are protected.
This can be possible that chats are not sending or retrieving , so in that case this situation
can also be easily handled by just restarting the server.
2.2 Methodology
There are various procedures that are being used in this project. Here we use HTML, CSS
and JAVA SCRIPT for handling the viewing of data in front end.
For integrating these web component with python Django the Django templating also used
in html files
{% extends 'core/base.html' %}
{% block title %}Welcome | {% endblock %}
{% block content %}
<div class="p-10 lg:p-20 text-center">
<h1 class="text-3xl lg:text-6xl text-white">Djangochat</h1>
</div>
{% endblock %}
In this code “{% extends "core/base.html" %}” , “{% block content %}” these all are
Django templating, Due to this the integration of python is become possible in Django.
def signup(request):
if request.method == 'POST':
form = SignUpForm(request.POST)
if form.is_valid():
user = form.save()
login(request, user)
return redirect('frontpage')
else:
form = SignUpForm()
return render(request, 'core/signup.html', {'form': form})
In this we are authenticate the data provided by user with the help of module
called login imported from django.contrib.auth.
5) For the security of data that are being send to one user to another we also used
CSRF token with the POST method.
<div class="mb-5">
<label class="text-white">Username</label>
<div class="mb-5">
<label class="text-white">Password</label>
{% if form.errors %}
{% for field in form %}
{% for error in field.errors %}
<div class="mb-5 p-4 rounded-xl bg-red-300 text-white">
<p>{{ error|escape }}</p>
</div>
{% endfor %}
{% endfor %}
{% endif %}
class Room(models.Model):
name = models.CharField(max_length=255)
slug = models.SlugField(unique=True)
class Message(models.Model):
room = models.ForeignKey(Room, related_name='messages',
on_delete=models.CASCADE)
user = models.ForeignKey(User, related_name='messages',
on_delete=models.CASCADE)
content = models.TextField()
date_added = models.DateTimeField(auto_now_add=True)
class Meta:
ordering = ('date_added',)
2.3 Choice of the Platform
2.3.1 Software Used
Framework : Django
RAM: 4 GB Minimum
Fig 1
This is a simple UI make the understanding better for user. All the color and design are kept simple
to make minimalistic and easy to navigate.
3.2 Model Design (Chat Storage Area)
In this project Django framework is used to make this chat application. So the chats that are stored
for retrieving and accessing the message are present in models. In Django there is no actual
database instead of this we have models which almost act like database.
The difference in actual database we use query to run but in Django we use python code to make
the structure.
class Room(models.Model):
name = models.CharField(max_length=255)
slug = models.SlugField(unique=True)
class Message(models.Model):
room = models.ForeignKey(Room, related_name='messages',
on_delete=models.CASCADE)
user = models.ForeignKey(User, related_name='messages',
on_delete=models.CASCADE)
content = models.TextField()
date_added = models.DateTimeField(auto_now_add=True)
class Meta:
ordering = ('date_added',)
Fig 2
In fig 2 This shows the basic structure of Chat application. This include “rooms” which has
messages that are hidden for security reasons.
Fig 3
In fig 3 , These all are messages that are stored according to room wise and all message are stored
without names so that no one can able to read properly.
3.3 Input Design
Fig 4
The approach that we use for design is Iterative Method approach. As the models that are used in
this project require continuous checking for data retrieving and at the same side we have to use it
for further representation. This same principle also followed by Frond End Designing also.
In this paper we proposed the Chat Application project using Django Framework of python. Here
we just given some feature like login, and Messages sending features. As the Instagram like
application also uses the Django framework and also even provide great security to the user’s data.
Besides having the other frameworks, Django framework can’t be ignore for backend work.
Having easiness in coding with python also increase the productivity for writing the robust code
for backend.
Hence we Django having the lots of powerful feature that can be used in authentication purpose.
Hardware
RAM: 2GB
Software
Platform: python
In this project we make the chat application , but there are some more features that we needed to
add in this project, like encryption for chat messages , timestamp for each messages that has been
send. Also we can add video calling feature to this project to make this more realistic.
So in future, these features will be implemented to make our project more robust.
CHAPTER 6: SYSTEM DEVELOPMENT (CODING)
Here in this project we have directory structure of two apps and main project
environment.
In this is project we have two app called “core” and “room” and we have main
project called “Djangochat”
Inside the Core App | “template/core”
Base.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}{% endblock %}Djangochat</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
.messages {
height: 400px;
overflow-y: auto;
}
</style>
</head>
<body class="bg-teal-600">
<nav class="flex items-center justify-between px-4 py-6 bg-teal-800">
<div>
<a href="/" class="text-xl text-white">Djangochat</a>
</div>
Login.html
{% extends 'core/base.html' %}
{% block content %}
<div class="p-10 lg:p-20 text-center">
<h1 class="text-3xl lg:text-6xl text-white">Log in</h1>
</div>
<div class="mb-5">
<label class="text-white">Username</label>
<div class="mb-5">
<label class="text-white">Password</label>
{% if form.errors %}
{% for field in form %}
{% for error in field.errors %}
<div class="mb-5 p-4 rounded-xl bg-red-300 text-white">
<p>{{ error|escape }}</p>
</div>
{% endfor %}
{% endfor %}
{% endif %}
{% block content %}
<div class="p-10 lg:p-20 text-center">
<h1 class="text-3xl lg:text-6xl text-white">Sign up</h1>
</div>
<div class="mb-5">
<label class="text-white">Username</label>
<div class="mb-5">
<label class="text-white">Password</label>
{% if form.errors %}
{% for field in form %}
{% for error in field.errors %}
<div class="mb-5 p-4 rounded-xl bg-red-300 text-white">
<p>{{ error|escape }}</p>
</div>
{% endfor %}
{% endfor %}
{% endif %}
{% block content %}
<div class="p-10 lg:p-20 text-center">
<h1 class="text-3xl lg:text-6xl text-white">{{ room.name }}</h1>
</div>
<button
class="px-5 py-3 rounded-xl text-white bg-teal-600 hover:bg-teal-700"
id="chat-message-submit"
>Submit</button>
</form>
</div>
{% endblock %}
{% block scripts %}
{{ room.slug|json_script:"json-roomname" }}
{{ request.user.username|json_script:"json-username" }}
<script>
const roomName = JSON.parse(document.getElementById('json-
roomname').textContent);
const userName = JSON.parse(document.getElementById('json-
username').textContent);
const chatSocket = new WebSocket(
'ws://'
+ window.location.host
+ '/ws/'
+ roomName
+ '/'
);
chatSocket.onclose = function(e) {
console.log('onclose')
}
chatSocket.onmessage = function(e) {
const data = JSON.parse(e.data);
if (data.message) {
document.querySelector('#chat-messages').innerHTML += ('<b>' +
data.username + '</b>: ' + data.message + '<br>');
} else {
// alert('The message was empty!')
}
scrollToBottom();
};
document.querySelector('#chat-message-input').focus();
document.querySelector('#chat-message-input').onkeyup = function(e) {
if (e.keyCode === 13) {
document.querySelector('#chat-message-submit').click();
}
};
document.querySelector('#chat-message-submit').onclick = function(e) {
e.preventDefault()
console.log({
'message': message,
'username': userName,
'room': roomName
})
chatSocket.send(JSON.stringify({
'message': message,
'username': userName,
'room': roomName
}));
messageInputDom.value = '';
return false
};
/**
* A function for finding the messages element, and scroll to the bottom of it.
*/
function scrollToBottom() {
let objDiv = document.getElementById("chat-messages");
objDiv.scrollTop = objDiv.scrollHeight;
}
Rooms.html
{% extends 'core/base.html' %}
{% block content %}
<div class="p-10 lg:p-20 text-center">
<h1 class="text-3xl lg:text-6xl text-white">Rooms</h1>
</div>
<a href="{% url 'room' room.slug %}" class="px-5 py-3 block rounded-xl
text-white bg-teal-600 hover:bg-teal-700">Join</a>
</div>
</div>
{% endfor %}
</div>
{% endblock %}
Outputs