Aiml (Sample) - Full Stack Development Lab Manual
Aiml (Sample) - Full Stack Development Lab Manual
Aiml (Sample) - Full Stack Development Lab Manual
LABORATORY MANUAL
AY: 2024-2025
GNITC – SPECIAL BRANCH
YEAR : II
SEMESTER :I
DOCUMENT NO : GNITC -
VENUE :
BLOCK :
PREPARED BY :
VERIFIED BY
INDEX
SL.NO. CONTENTS
3. Lab Objective
4. Lab outcomes
Guidelines to students
6. a) Standard Operating Procedure (SOP)
b) General guidelines
PEO 1: Graduates shall have the ability to apply knowledge across the disciplines and in emerging
areas of Artificial Intelligence and Machine Learning for higher studies, research, employability,
product development and handle the realistic problems.
PEO 2: Graduates shall have good communication skills, possess ethical values, sense Responsibility
to serve the society, and protect the environment.
PEO 3: Graduates shall possess academic excellence with innovative insight, managerial skills,
leadership qualities, knowledge of contemporary issues and understand the need for lifelong learning
for a successful professional career.
1. Ability to design, develop, test and debug software applications, evaluate and recognize potential
risks and provide innovative solutions.
To become a premier Computer Science and Engineering department by imparting high quality
education, ethical values, provide creative environment for innovation and global opportunities
M1: Nurture young individuals into knowledgeable, skilful and ethical professionals in their pursuit
of Information Technology.
M2: Transform the students through soft skills, excellent teaching learning process and sustain high
performance by innovations.
M3: Extensive partnerships and collaborations with foreign universities to enrich the knowledge and
research.
M4: Develop industry-interaction for innovation and product development to provide good
placements.
GNITC – SPECIAL BRANCH
Students are asked to carry their lab observation book and record
book.
Students must use the equipments with care, any damage caused to
the equipment by the student is punishable.
Students are not allowed to use their cell phones/pendrives/CDs.
Student need to maintain proper dress code.
Student are supposed to occupy the systems allotted to them.
Students are not allowed to make noise in the lab.
After completion of each experiment student need to update their
observation notes and same to be reflected in the record.
GNITC – SPECIAL BRANCH
Step1: Students have to write the Date, aim, Software and Hardware
requirements for the scheduled experiment in the observation book.
Step2: Students have to listen and understand the experiment
explained by the faculty and note down the important points in the
observation book.
Step3: Students need to write procedure/algorithm in the observation
book.
Step4: Analyze and Develop/implement the logic of the program by
the student in respective platform
Step5: After approval of logic of the experiment by the faculty then
the experiment has to be executed on the system.
Step6: After successful execution, the results have to be recorded in
the observation book and shown to the lab in charge faculty..
Step7: Students need to attend the Viva-Voce on that experiment and
write the same in the observation book.
Step8: Update the completed experiment in the record and submit to
the concerned faculty in- charge.
Before staring of the first lab session students must buy the record
book and bring the same to the lab.
Regularly (Weekly) update the record after completion of the
experiment and get it corrected with concerned lab in-charge for
continuous evaluation.
In case the record is lost, inform on the same day to the faculty in
charge and submit the new record within 2 days for correction.
If record is not submitted in time or record is not written properly, the
record evaluation marks (5M) will be reduced accordingly.
GNITC – SPECIAL BRANCH
COURSE OBJECTIVES
To implement the static web pages using HTML and do client side validation using
JavaScript.
To design and work with databases using Java
To develop an end to end application using java full stack.
To introduce Node JS implementation for server side programming.
To experiment with single page application development using React.
COURSE OUTCOMES
At the end of the course, the student will be able to,
Build a custom website with HTML, CSS, and Bootstrap and little
JavaScript.
Demonstrate Advanced features of JavaScript and learn about JDBC
Develop Server – side implementation using Java technologies like
Develop the server – side implementation using Node JS.
Design a Single Page Application using React.
Develop an express web application that can interact with REST API to
10
perform CRUD operations on student data. (Use Postman).
For the above application create authorized end points using JWT (JSON Web
11
Token).
Create a react application for the student management system having
12 registration, login, contact, about pages and implement routing to navigate
through these pages.
Create a service in react that fetches the weather information from
13 openweathermap.org and the display the current and historical weather
information using graphical representation usingchart.js.
Create a TODO application in react with necessary components and deploy it
14
into github.
REFERENCE BOOK:
LAB EXPERIMENTS
PROGRAM:
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>Shopping Cart</title>
</head>
<body>
<header>
<h1>Shopping Cart</h1>
<nav>
<ul>
<li><a href="#catalog">Catalog</a></li>
<li><a href="#cart">Cart</a></li>
<li><a href="#login">Login</a></li>
<li><a href="#register">Register</a></li>
</ul>
</nav>
</header>
<main>
GNITC – SPECIAL BRANCH
<section id="catalog">
<h2>Catalog</h2>
<div class="product">Product 1</div>
<div class="product">Product 2</div>
<div class="product">Product 3</div>
</section>
<section id="cart">
<h2>Shopping Cart</h2>
<!-- Cart contents go here -->
</section>
<section id="login">
<h2>Login</h2>
<!-- Login form goes here -->
</section>
<section id="register">
<h2>Register</h2>
<!-- Registration form goes here -->
</section>
</main>
<footer>
<p>© 2024 Shopping Cart App</p>
</footer>
</body>
</html>
GNITC – SPECIAL BRANCH
styles.css:
body {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #333;
color: #fff;
padding: 1em;
text-align: center;
}
nav ul {
list-style: none;
padding: 0;
display: flex;
justify-content: space-around;
}
nav a {
text-decoration: none;
color: #fff;
font-weight: bold;
}
main {
GNITC – SPECIAL BRANCH
padding: 1em;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
}
section {
margin-bottom: 2em;
padding: 1em;
border: 1px solid #ddd;
border-radius: 8px;
}
footer {
background-color: #333;
color: #fff;
text-align: center;
padding: 1em;
position: fixed;
bottom: 0;
width: 100%;
}
.product {
border: 1px solid #ddd;
padding: 1em;
border-radius: 8px;
text-align: center;
GNITC – SPECIAL BRANCH
/* Add additional styles for catalog, cart, login, and register sections */
OUTPUT:
GNITC – SPECIAL BRANCH
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap CSS CDN -->
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet">
<title>Shopping Cart</title>
</head>
<body>
<!-- Your existing HTML content goes here -->
</body>
<!-- Bootstrap JS and Popper.js CDN -->
<script
src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"
></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></scrip
t>
</html>
GNITC – SPECIAL BRANCH
index.html:
<!-- ... (previous HTML code) ... -->
</main>
</body>
</html>
OUTPUT:
GNITC – SPECIAL BRANCH
<section id="register">
GNITC – SPECIAL BRANCH
<h2>Register</h2>
<form id="registerForm" onsubmit="return validateRegisterForm()">
<label for="newUsername">Username:</label>
<input type="text" id="newUsername" name="newUsername" required>
<br>
<label for="newPassword">Password:</label>
<input type="password" id="newPassword" name="newPassword" required>
<br>
<input type="submit" value="Register">
</form>
</section>
<!-- ... (remaining body content) ... -->
</body>
</html>
validate.js:
function validateLoginForm() {
var username = document.getElementById('username').value;
var password = document.getElementById('password').value;
return true;
}
function validateRegisterForm() {
var newUsername = document.getElementById('newUsername').value;
var newPassword = document.getElementById('newPassword').value;
return true;
}
OUTPUT:
GNITC – SPECIAL BRANCH
4. Explore the features of ES6 like arrow functions, call backs, promises,
async/await. Implement an application for reading the weather
information from openweathermap.org and display the information in
the form of a graph on the web page.
PROGRAM:
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Weather Graph</title>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="app.js" defer></script>
</head>
<body>
<div>
<h1>Weather Graph</h1>
<canvas id="weatherChart" width="800" height="400"></canvas>
</div>
</body>
</html>
GNITC – SPECIAL BRANCH
app.js:
const apiUrl =
`https://api.openweathermap.org/data/2.5/forecast?q=${city}&appid=${apiKey}`;
new Chart(ctx, {
type: 'line',
data: {
labels: weatherData.map(item => item.date.toLocaleDateString()),
datasets: [{
label: 'Temperature (°C)',
data: weatherData.map(item => item.temperature.toFixed(2)),
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 2,
fill: false,
}],
},
options: {
scales: {
x: {
type: 'linear',
position: 'bottom',
},
y: {
beginAtZero: true,
},
},
},
});
};
GNITC – SPECIAL BRANCH
OUTPUT:
GNITC – SPECIAL BRANCH
e.printStackTrace();
}
}
private static void createRecord(Connection connection, String name, int age)
throws SQLException {
String insertQuery = "INSERT INTO users (name, age) VALUES (?, ?)";
try (PreparedStatement preparedStatement =
connection.prepareStatement(insertQuery)) {
preparedStatement.setString(1, name);
preparedStatement.setInt(2, age);
preparedStatement.executeUpdate();
System.out.println("Record created successfully.");
}
}
private static void readRecords(Connection connection) throws SQLException {
String selectQuery = "SELECT * FROM users";
try (Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(selectQuery)) {
System.out.println("User Records:");
while (resultSet.next()) {
int id = resultSet.getInt("id");
String name = resultSet.getString("name");
int age = resultSet.getInt("age");
System.out.println("ID: " + id + ", Name: " + name + ", Age: " + age);
}
}
}
GNITC – SPECIAL BRANCH
private static void updateRecord(Connection connection, int id, String name, int
age) throws SQLException {
String updateQuery = "UPDATE users SET name = ?, age = ? WHERE id =
?";
try (PreparedStatement preparedStatement =
connection.prepareStatement(updateQuery)) {
preparedStatement.setString(1, name);
preparedStatement.setInt(2, age);
preparedStatement.setInt(3, id);
preparedStatement.executeUpdate();
System.out.println("Record updated successfully.");
}
}
OUTPUT:
GNITC – SPECIAL BRANCH
6. Create an xml for the bookstore. Validate the same using both DTD and
XSD.
PROGRAM:
bookstore.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE bookstore SYSTEM "bookstore.dtd">
<bookstore>
<book>
<title>Harry Potter and the Sorcerer's Stone</title>
<author>J.K. Rowling</author>
<genre>Fantasy</genre>
<price>19.99</price>
</book>
<book>
<title>To Kill a Mockingbird</title>
<author>Harper Lee</author>
<genre>Classic</genre>
<price>14.99</price>
</book>
<!-- Add more books as needed -->
</bookstore>
bookstore.dtd:
<!ELEMENT bookstore (book+)>
<!ELEMENT book (title, author, genre, price)>
<!ELEMENT title (#PCDATA)>
GNITC – SPECIAL BRANCH
bookstore.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="bookstore" type="BookstoreType"/>
<xs:complexType name="BookstoreType">
<xs:sequence>
<xs:element name="book" type="BookType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="BookType">
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="author" type="xs:string"/>
<xs:element name="genre" type="xs:string"/>
<xs:element name="price" type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
GNITC – SPECIAL BRANCH
OUTPUT:
GNITC – SPECIAL BRANCH
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/experiment1")
public class Experiment1Servlet extends HttpServlet {
private static final String JDBC_URL =
"jdbc:mysql://localhost:3306/your_database";
private static final String USERNAME = "your_username";
private static final String PASSWORD = "your_password";
try {
// Load the JDBC driver
Class.forName("com.mysql.cj.jdbc.Driver");
// Establish a connection
Connection connection = DriverManager.getConnection(JDBC_URL,
USERNAME, PASSWORD);
OUTPUT:
GNITC – SPECIAL BRANCH
9. Create a custom server using http module and explore the other
modules of Node JS like OS, path, event.
Program:
Custom Server using http Module:
const http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello, custom server!');
});
const PORT = 3000;
server.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}/`);
});
OS Module:
const os = require('os');
Path Module:
const path = require('path');
Event Module:
const EventEmitter = require('events');
class MyEmitter extends EventEmitter {}
const myEmitter = new MyEmitter();
myEmitter.on('event', () => {
console.log('Event emitted!');
});
myEmitter.emit('event');
OUTPUT:
GNITC – SPECIAL BRANCH
10. Develop an express web application that can interact with REST API to
perform CRUD operations on student data. (Use Postman).
Program:
Initialize the Project:
mkdir express-rest-api
cd express-rest-api
npm init -y
npm install express body-parser
node index.js
OUTPUT:
GNITC – SPECIAL BRANCH
11. For the above application create authorized end points using JWT
(JSON Web Token)
PROGRAM:
Install the jsonwebtoken library:
npm install jsonwebtoken
// Routes
const students = [
{ id: 1, name: 'John Doe', age: 20 },
{ id: 2, name: 'Jane Smith', age: 22 },
];
app.post('/login', (req, res) => {
const { username, password } = req.body;
// You should validate the username and password against your user database
if (username === 'user' && password === 'password') {
const token = jwt.sign({ username }, SECRET_KEY);
res.json({ token });
} else {
res.status(401).json({ message: 'Invalid credentials' });
}
});
// Protected route
app.get('/students', authenticateJWT, (req, res) => {
res.json(students);
});
// ... (other routes are protected similarly)
// Start the server
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});
GNITC – SPECIAL BRANCH
OUTPUT:
GNITC – SPECIAL BRANCH
Login.js:
import React from 'react';
const Login = () => {
return <div>Login Page</div>;
};
export default Login;
GNITC – SPECIAL BRANCH
Contact.js:
import React from 'react';
const Contact = () => {
return <div>Contact Page</div>;
};
export default Contact;
About.js:
import React from 'react';
const About = () => {
return <div>About Page</div>;
};
export default About;
<nav>
<ul>
<li>
<Link to="/registration">Registration</Link>
</li>
<li>
<Link to="/login">Login</Link>
</li>
<li>
<Link to="/contact">Contact</Link>
</li>
<li>
<Link to="/about">About</Link>
</li>
</ul>
</nav>
<Switch>
<Route path="/registration">
<Registration />
</Route>
<Route path="/login">
<Login />
</Route>
<Route path="/contact">
<Contact />
</Route>
GNITC – SPECIAL BRANCH
<Route path="/about">
<About />
</Route>
</Switch>
</div>
</Router>
);
};
export default AppRouter;
13. Create a service in react that fetches the weather information from
openweathermap.org and the display the current and historical weather
information using graphical representation usingchart.js
PROGRAM:
Create a new React App:
npx create-react-app weather-app
cd weather-app
Install Dependencies:
npm install axios react-chartjs-2 chart.js
`${API_BASE_URL}/onecall/timemachine?lat=${city.lat}&lon=${city.lon}&dt
=${Math.round(new Date(startDate).getTime() / 1000)}&appid=${API_KEY}`
);
return response.data;
} catch (error) {
console.error('Error fetching historical weather:', error);
throw error;
}
};
export { getWeatherData, getHistoricalWeatherData };
useEffect(() => {
const fetchData = async () => {
try {
const currentWeatherData = await getWeatherData(city);
setCurrentWeather(currentWeatherData);
const historicalWeatherData = await getHistoricalWeatherData(city, 7); //
Fetch historical data for the last 7 days
setHistoricalWeather(historicalWeatherData);
} catch (error) {
// Handle error
}
};
fetchData();
}, [city]);
const chartData = {
labels: historicalWeather?.hourly.map((hour) => new Date(hour.dt *
1000).toLocaleTimeString([], { hour: 'numeric' })),
datasets: [
{
label: 'Temperature (°C)',
data: historicalWeather?.hourly.map((hour) => hour.temp - 273.15),
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 2,
fill: false,
},
],
GNITC – SPECIAL BRANCH
};
return (
<div>
<h2>Weather Chart for {city.name}</h2>
<Line data={chartData} />
</div>
);
};
export default WeatherChart;
OUTPUT:
GNITC – SPECIAL BRANCH
TodoItem.js:
import React from 'react';
const TodoItem = ({ todo, onDelete }) => {
GNITC – SPECIAL BRANCH
return (
<li>
{todo.text} <button onClick={() => onDelete(todo.id)}>Delete</button>
</li>
);
};
export default TodoItem;
AddTodo.js:
import React, { useState } from 'react';
const AddTodo = ({ onAdd }) => {
const [text, setText] = useState('');
const handleAdd = () => {
if (text.trim() !== '') {
onAdd({ id: Date.now(), text });
setText('');
}
};
return (
<div>
<input type="text" value={text} onChange={(e) =>
setText(e.target.value)} />
<button onClick={handleAdd}>Add Todo</button>
</div>
);
};
GNITC – SPECIAL BRANCH
Modify App.js:
import React, { useState } from 'react';
import TodoList from './TodoList';
import AddTodo from './AddTodo';
const App = () => {
const [todos, setTodos] = useState([]);
const handleAddTodo = (newTodo) => {
setTodos([...todos, newTodo]);
};
const handleDeleteTodo = (id) => {
setTodos(todos.filter((todo) => todo.id !== id));
};
return (
<div className="App">
<h1>TODO App</h1>
<AddTodo onAdd={handleAddTodo} />
<TodoList todos={todos} onDelete={handleDeleteTodo} />
</div>
);
};
Deploy to GitHub:
git init
git add .
git commit -m "Initial commit"
"homepage": "https://your-username.github.io/your-repo-name",
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
// ... other scripts
}