cpp final
cpp final
Project Report On
“Simple Chatboat”
CERTIFICATE OF COMPLETION
This is to certify that the project “Simple Chatboat” in CPE(Capstone Project Execution)
is successfully completed by the following students of fifth semester of Diploma in
“GOVERNMENT POLYTECHNIC DHARASHIV” (Instt.code:0118) has completed project
work satisfactorily in subject Software Testing.
I take this opportunity to express my profound gratitude and deep regards to my guide, Mr. B.R.Chauhan
(Computer Department, Government Polytechnic Dharashiv), for his exemplary guidance, monitoring, and
constant encouragement throughout the course of this project. The blessings, help, and guidance given by
him from time to time shall carry me a long way in the journey of life on which I am about to embark.
I also take this opportunity to express my deep sense of gratitude to Mr. A. B. Gaikwad (Head of
Department) for his cordial support, valuable information, and guidance, which helped me complete this
task through various stages.
I am also obliged to the staff members of Government Polytechnic Dharashiv for the valuable information
provided by them in their respective fields. I am grateful for their cooperation during the period of my
assignment.
INDEX
1.0) INTRODUCTION:-
1.1 Rationale :-
A capstone project serves as an essential final assignment that allows students to demonstrate the skills and
knowledge they have gained throughout their academic program. Through this project, students apply
theoretical concepts to practical situations, enhancing their overall learning experience.
The Simple Chatbot project helps students develop critical skills such as problem-solving, logical thinking,
technical proficiency, and creativity. By designing and implementing a chatbot using web technologies and
integrating it with AI services, students learn how to analyze real-world problems and create working
solutions.
Additionally, this project fosters important professional abilities including teamwork, research,
communication, and time management. Students engage with current technological trends, such as artificial
intelligence and web development, making them better prepared to meet industry demands.
Thus, the chatbot project not only strengthens technical capabilities but also bridges the gap between
academic learning and real-world applications.
Automated Responses: The chatbot automates answering basic user queries, reducing the need
for constant human support.
Quick Communication: Provides instant responses to user questions without delay, saving time
and effort compared to manual replies.
2. Enhanced Communication
User Interaction: Facilitates seamless interaction between users and the system by allowing
users to ask questions and receive smart answers.
24/7 Availability: The chatbot is always active, allowing users to communicate anytime without
depending on staff availability.
3. Data Management
Conversation Flow: Maintains the sequence of chats in an organized way, making it easy to
trace past interactions if needed.
User Query Handling: Helps analyze the types of questions users frequently ask, providing
valuable insights for improving services.
User-Friendly Interface: The chatbot has a simple, clean, and responsive design that enhances
the overall user experience.
Personalized Interaction: By using AI responses, users receive more relevant and personalized
answers, making conversations feel natural and engaging.
Login functionality: User is provided with a login page functionality where he/she can login or
sign in using user name and password.
1.3 Scope:-
The scope of the Simple Chatbot micro project involves building a responsive, intelligent communication
system that allows users to interact naturally and receive automated replies. The project covers multiple
important areas of web development and AI integration. Key areas of scope include:
User-Friendly Chat Portal: Provide a simple and interactive chat interface where users can send
messages and receive replies in real-time.
Dynamic Message Handling: Allow the system to process user inputs instantly and show them
as chat bubbles, making the interaction feel natural.
Use of Gemini API: Integrate Google’s Gemini API to generate intelligent and human-like
responses based on the user's message.
Automated Conversations: Simulate human-like communication without manual intervention,
making the chatbot work independently.
3. Web Development and Design
Frontend Development: Design a clean and attractive webpage using HTML, CSS, and
JavaScript for better user experience.
Responsive Design: Ensure the chatbot works on different screen sizes like mobile phones,
tablets, and desktops.
Real-Time Message Updates: Maintain proper flow of user and bot messages dynamically
without refreshing the page.
Auto-Scrolling Feature: Automatically scroll to the newest message so that users can follow the
conversation easily.
5. Future Scalability
Expandable Features: The chatbot can later be expanded to include voice recognition,
multilingual support, saving conversation history, and smarter AI features.
Customization for Industries: It can be adapted for educational help desks, customer support,
booking systems, and more.
Wrote the problem specification for the need of an automated chatbot system.
Collected and used knowledge of web development and AI integration to complete the project.
Chose a web-based chatbot solution logically for user interaction.
Prepared a detailed project proposal with a clear action plan and timeline.
Managed multiple user interactions together using the chatbot.
Greatly reduced workload by automating user responses.
Improved communication efficiency and user experience through AI integration.
1.5 Problem Definition:-
The Simple Chatbot aims to provide an automated communication system where users can interact naturally
with a web-based chatbot for instant query resolution. The system is designed to replace manual, time-
consuming conversations with smart AI-generated responses, ensuring faster and more efficient interaction
between users and digital platforms. Current methods of answering queries manually are often slow,
inconsistent, and require constant human presence, leading to inefficiency and delayed response times.
The Simple Chatbot project is designed to offer an automated, efficient, and user-friendly way for users to
interact with a digital system. It reduces the need for human effort in answering frequent queries and
provides a seamless communication experience. The system ensures fast response times, consistent
communication, and availability without interruption. It promotes better engagement between users and the
platform while keeping the interface simple, intuitive, and accessible for everyone
2.1 Specifications:
Future Expansion:
The system is designed in a modular way, allowing future upgrades such as voice support, saving
conversation history, adding FAQs, and advanced analytics.
Integration with Other Systems:
APIs and external services (like Google AI) are already being used, and future integrations with
databases, support systems, or CRM tools are possible to extend the chatbot’s capabilities
HTML:
HTML (HyperText Markup Language) is the standard markup language used to create the
structure of web pages. It defines the meaning and structure of web content and works alongside
CSS and JavaScript to build interactive websites.
CSS:
CSS (Cascading Style Sheets) is a style sheet language used for describing the presentation of a
document written in HTML. It controls the layout, colors, fonts, and overall appearance of the
website, ensuring a user-friendly and visually appealing design.
JavaScript:
JavaScript is a high-level, interpreted programming language that enables the creation of
dynamic, interactive websites. It is used for controlling the chatbot functionality, handling user
inputs, and connecting with external APIs like Google Gemini.
All user queries and AI responses are handled in real-time through API calls without storing any data
3.0) LITERATURE VIEW:-
Design of Project:
The Simple Chatbot project is structured into different modules to create a smooth and interactive user
experience. The system is focused on efficient communication and real-time response generation using AI.
Section Description
Welcome Screen Displays a friendly greeting message: "Hey There! Talk to your own
Chatbot".
Chat Interface After user interaction, the chatbot screen opens where users can type and
send messages.
Prompt Area At the bottom, users can type queries into the input field and press the
send button to interact with the chatbot.
Section Description
User Message Handling Captures the user’s input message and displays it in the chat window.
Bot Thinking Phase Shows a "thinking..." message while waiting for the AI response from the
Gemini API
AI Response Handling Receives the AI-generated reply from the Gemini API and displays it in the
chat.
Auto-Scroll Feature Automatically scrolls down to the latest messages during chat interaction.
3.2 Implementation Steps:
Step 1: Project Setup
Chat area
Input field
Send button
Scrollable chat container
Chat layout
User and bot message bubbles
Gradient titles, custom scrollbar, responsive layout
Test for:
Empty input
Invalid login
Broken API call
UI responsiveness
Hide API key using server-side logic or .env file (optional for advanced version).
Prevent unauthorized use of your key.
Set up project
Generate API key
Deploy code
4.0) SYSTEM REQUIREMENTS
Functional Expectations:
User Interaction
API Integration
The chatbot must generate smart, relevant replies using Google's Gemini API.
Must simulate human-like conversation without manual input.
Login Feature
Users must log in with a username and password before accessing the chatbot.
Credentials are stored securely and managed through PHP and MySQL.
Chat Experience
Messages must appear in chat bubbles with appropriate design (user and bot).
The interface should auto-scroll to show the latest message.
Real-Time Communication
Security Measures
Functional Requirements
Login System
Non-Functional Requirements
Main Interface
API Integration
Secure API key and handle API failures with proper error messages.
Use efficient fetch() logic to minimize request latency.
Handle large promizes without breaking UI or freezing.
Codebase should be modular: separate files for HTML, CSS, JS, and PHP.
Easy to add new features (voice support, saving chat, etc.).
Follow best practices (semantic HTML, clean CSS, and commented JS).
Compatibility
DFD LEVEL 0:
DFD LEVEL 1:
6.0) Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Login | Chatbot</title>
<style>
body {
margin: 0;
padding: 0;
font-family: "Segoe UI", sans-serif;
background: #f5f5f5;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.login-container {
background: white;
padding: 40px;
border-radius: 15px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
width: 350px;
text-align: center;
}
.login-container h2 {
font-size: 28px;
margin-bottom: 10px;
background: linear-gradient(to right, #d16ba5, #86a8e7, #5ffbf1);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.login-container p {
color: #666;
font-size: 14px;
margin-bottom: 30px;
}
.login-container input {
width: 100%;
padding: 12px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 8px;
font-size: 14px;
}
.login-container button {
background: linear-gradient(to right, #86a8e7, #d16ba5);
color: white;
border: none;
padding: 12px;
width: 100%;
border-radius: 8px;
cursor: pointer;
font-size: 16px;
margin-top: 10px;
transition: background 0.3s ease;
}
.login-container button:hover {
background: linear-gradient(to right, #d16ba5, #86a8e7);
}
</style>
</head>
<body>
<div class="login-container">
<h2>Login</h2>
<p>Enter your credentials to start chatting</p>
<form action="http://localhost/LoginInsert.php" method="POST">
<input type="text" id="username" name="Username" placeholder="Username" required />
<input type="password" id="password" name="Password" placeholder="Password" required />
<button type="submit">Login</button>
</form>
</div>
</body>
</html>
<?php
$servername="localhost";
$username="root";
$password="Aaditi@12";
$db="mydb";
$conn=mysqli_connect($servername,$username,$password,$db);
if($conn){
$username=$_POST['Username'];
$password=$_POST['Password'];
$query="insert into login values('".$username."','".$password."')";
if(mysqli_query($conn,$query)){
header("Location: login.html");
exit();
}
else
{
$msg="<script>alert('Login Failed');</script>";
echo $msg;
}
}
?>
6.2 Script.js:
try {
let response = await fetch(Api_url, requestOption);
let data = await response.json();
userChat.classList.add("user-chat-box");
userImg.classList.add("img");
msg.classList.add("userChat");
msg.innerHTML = message;
img.src = "user.png";
img.width = "50";
userChat.appendChild(userImg);
userChat.appendChild(msg);
userImg.appendChild(img);
chatContainer.appendChild(userChat);
autoScroll(); // Auto-scroll to the latest message
}
botChat.classList.add("ai-chat-box");
botImg.classList.add("img");
msg.classList.add("bot-chat");
msg.innerHTML = "thinking....";
img.src = "robot.png";
img.width = "50";
botChat.appendChild(botImg);
botChat.appendChild(msg);
botImg.appendChild(img);
chatContainer.appendChild(botChat);
autoScroll(); // Auto-scroll to the latest message
}
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Roboto', sans-serif; /* Modern font */
}
body {
width: 100%;
height: 100%;
background-color: #f5f5f5; /* Light background color */
font-size: 16px;
}
.container {
width: 100%;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding-top: 50px;
display: flex;
}
.container h1 {
font-size: 3rem;
background: linear-gradient(to right, rgb(214, 161, 161), rgb(123, 166, 188), rgb(197, 95, 143));
background-clip: text;
-webkit-text-fill-color: transparent;
margin-bottom: 10px;
}
.container h2 {
font-size: 1.2rem;
color: rgba(0, 0, 0, 0.6);
}
.chat-container {
width: 100%;
max-height: 80vh;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 20px;
padding: 20px;
margin-bottom: 100px;
background: #ffffff; /* Light white background for chat */
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.user-chat-box, .ai-chat-box {
width: fit-content;
max-width: 60%;
padding: 10px;
border-radius: 25px;
font-size: 15px;
margin: 10px 0;
}
.user-chat-box {
background-color: #1e90ff;
color: white;
align-self: flex-end;
border-top-right-radius: 0;
}
.ai-chat-box {
background-color: #e0e0e0;
color: #333;
align-self: flex-start;
border-top-left-radius: 0;
}
.img {
width: 40px;
height: 40px;
border-radius: 50%;
margin-right: 10px;
}
.prompt-area {
width: 100%;
height: 80px;
background-color: #333;
position: fixed;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
padding: 10px;
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}
#prompt {
background-color: #ffffff;
width: 75%;
height: 50px;
padding: 10px;
outline: none;
border: none;
border-radius: 25px 0px 0px 25px;
font-size: 16px;
}
#btn {
width: 50px;
height: 50px;
background-color: #1e90ff;
border: none;
border-radius: 50%;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
margin-left: 10px;
}
#btn img {
width: 25px;
height: 25px;
}
#btn:hover {
background-color: #00bfff;
}
#btn:active {
background-color: #008cba;
}
/* Scrollbar styling for smooth scroll */
.chat-container::-webkit-scrollbar {
width: 8px;
}
.chat-container::-webkit-scrollbar-thumb {
background: #888;
border-radius: 10px;
}
.chat-container::-webkit-scrollbar-thumb:hover {
background: #555;
}
6.3 Index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Chatbot</title>
</head>
<body>
<div class="container">
<h1>Hey There!</h1>
</div>
<div class="chat-container">
<div class="user-chat-box">
<div class="img">
</div>
<p class="text">
</p>
</div>
<div class="ai-chat-box">
<div class="img">
</div>
<p class="text">
</p>
</div>
</div>
<div class="prompt-area">
</div>
<script src="script.js"></script>
</body>
</html>
7.0) output:-
8.0) Application:
The Simple Chatbot system has a wide range of applications across various domains, primarily due to its
ability to simulate human-like conversations and provide automated support. Below are the key areas where
this chatbot can be effectively applied:
1. Educational Institutions
Automated Customer Care: Address customer queries instantly without waiting for a human
representative.
Product Information: Provide information about services or products to users through natural
language queries.
Ticket Booking Systems: Integrate with ticketing services for event or travel bookings using chat
commands.
3. Corporate Environments
4. Healthcare
Citizen Support: Guide users through application processes, document requirements, and
deadlines.
Information Dissemination: Share public notices or alerts efficiently and interactively.
Complaint Registration: Help users log issues and receive updates on their status.
Personal Assistant: Provide entertainment suggestions, reminders, weather updates, and more.
Games and Quizzes: Engage users with interactive and fun chat-based content.
Event Information: Update users about upcoming concerts, movies, or festival
8.1 SKILLS DEVELOPED / LEARNING OUTCOMES
Technical Skills
Soft Skills
The Simple Chatbot project successfully demonstrates how artificial intelligence and web technologies can
be combined to create an efficient, user-friendly communication platform. Designed with a clean interface
and powered by Google’s Gemini API, the chatbot automates user interaction, providing instant, intelligent
responses without the need for human intervention.
This project not only enhances the user experience by offering real-time assistance but also reduces
workload and improves overall efficiency. Key features such as login authentication, dynamic message
handling, and responsive design make it suitable for educational, customer support, and organizational use.
Looking ahead, the chatbot can be expanded with features like voice integration, multilingual support, cloud
deployment, and data analytics—making it scalable and adaptable to diverse industries. The project has
provided valuable hands-on experience in full-stack development, API integration, and AI implementation,
reflecting both technical skill and creative problem-solving.
10.0) REFERENCES
developer.mozilla.org (MDN) – For JavaScript and modern web development best practices.
Project-based learning material and class notes from Government Polytechnic, Dharashiv