Full Stack Development
Full Stack Development
FULLSTACK DEVELOPMENT - 2
Experiment 1: [Link]
a. Write a program to show the workflow of JavaScript code executable by
creating web server in [Link].
Description:
This program creates a basic [Link] server using the http module.
It listens on port 3000 and sends a plain text response to the browser.
Program:
Explanation:
b. Write a program to transfer data over http protocol using http module.
Description:
This program sends HTML content to the client browser using [Link] HTTP module.
It responds with a heading and paragraph.
Program:
});
Explanation:
c. Create a text file [Link] and add the following content to it. (HTML, CSS,
Javascript, Typescript, MongoDB, [Link], [Link], [Link])
Description:
This program uses the [Link] fs module to create a file [Link] and write content into it.
Program:
Explanation:
Description:
This program demonstrates how to extract parts of a URL using the [Link] URL module.
Program:
[Link]('Host:', [Link]);
[Link]('Pathname:', [Link]);
[Link]('Query param (name):', [Link]('name'));
[Link]('Query param (city):', [Link]('city'));
FSD2
Explanation:
Description:
This example shows how to create your own module ([Link]) and import it into a
main file ([Link]).
Step 1 – [Link]
// [Link]
function greet(name) {
return 'Hello, ' + name + '!';
}
[Link] = { greet };
Step 2 – [Link]
// [Link]
const myModule = require('./myModule');
Explanation:
Experiment 2: TypeScript
a. Write a program to understand simple and special types.
Description:
This program demonstrates TypeScript types like number, string, and the special type any.
Program:
[Link]("ID:", id);
[Link]("Name:", name);
[Link]("Any Type:", anything);
Explanation:
Description:
This function accepts two numbers and returns their sum, showing how parameter and return
types work.
Program:
Explanation:
Description:
This arrow function shows how to use optional, default, and rest parameters in TypeScript.
Program:
Explanation:
FSD2
Description:
This code defines a Person class with public and private members, constructor, and a
method.
Program:
class Person {
public name: string;
private age: number;
Explanation:
Description:
Namespaces group functions under a single name, helping organize large code.
Program:
namespace MathOperations {
export function square(x: number): number {
return x * x;
}
}
FSD2
Explanation:
Description:
Generics let you write flexible, reusable code that works with different types.
Program:
display<string>("Hello TypeScript");
display<number>(101);
Explanation:
Description:
Full Program:
<!DOCTYPE html>
<html>
<head>
<title>2D and 3D Transformations</title>
<style>
body {
FSD2
.container {
perspective: 1000px; /* Enables 3D perspective */
}
.box {
width: 200px;
height: 200px;
background-color: coral;
color: white;
display: flex;
align-items: center;
justify-content: center;
font-size: 20px;
transition: transform 0.6s;
transform: rotate(10deg) scale(1.1); /* 2D Transformation */
transform-style: preserve-3d; /* Keeps child 3D transforms */
}
.box:hover {
transform: rotateY(180deg); /* 3D Transformation on hover */
background-color: teal;
}
</style>
</head>
<body>
<div class="container">
<div class="box">
Hover Me!
</div>
</div>
</body>
</html>
Explanation:
Description:
This program demonstrates new HTML5 semantic tags (header, section, article, footer)
and CSS3 features.
It includes form elements, layout styling, shadows, transitions, and media queries.
Full Program:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML5 + CSS3 Demo</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f9f9f9;
}
header {
background-color: #2c3e50;
color: white;
text-align: center;
padding: 20px;
}
nav {
background-color: #34495e;
padding: 10px;
text-align: center;
}
nav a {
color: white;
margin: 0 15px;
text-decoration: none;
font-weight: bold;
}
section {
padding: 20px;
}
article {
background: white;
padding: 15px;
margin-bottom: 20px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
transition: transform 0.3s;
FSD2
article:hover {
transform: scale(1.02);
}
footer {
background-color: #2c3e50;
color: white;
text-align: center;
padding: 10px;
position: fixed;
width: 100%;
bottom: 0;
}
<header>
<h1>My HTML5 + CSS3 Page</h1>
</header>
<nav>
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Contact</a>
</nav>
<section>
<article>
<h2>What is HTML5?</h2>
<p>HTML5 is the latest version of the HTML standard. It includes new
semantic tags, multimedia support, and form enhancements.</p>
</article>
<article>
<h2>What is CSS3?</h2>
<p>CSS3 adds modern styling features like transitions, transformations,
shadows, and media queries to enhance web design.</p>
</article>
</section>
<footer>
© 2025 My Web Page
</footer>
</body>
</html>
Explanation:
CSS3 features:
o box-shadow, transition, transform (modern effects)
o media query makes the nav responsive on small screens
Clean and modern layout for teaching real-world usage
Description:
This application allows the user to type tasks and display them in a list.
It uses HTML for layout, CSS for design, and JavaScript to manage tasks.
Program:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>To-Do List App</title>
<style>
body {
font-family: Arial;
background: #f2f2f2;
text-align: center;
padding: 50px;
}
#todo-container {
background: white;
padding: 20px;
width: 300px;
margin: auto;
box-shadow: 0 0 10px rgba(0,0,0,0.2);
}
input {
padding: 10px;
width: 80%;
margin-bottom: 10px;
}
button {
padding: 10px;
background-color: teal;
color: white;
border: none;
cursor: pointer;
}
ul {
FSD2
list-style: none;
padding: 0;
}
li {
background: #e0e0e0;
padding: 10px;
margin: 5px 0;
}
</style>
</head>
<body>
<div id="todo-container">
<h2>My To-Do List</h2>
<input type="text" id="taskInput" placeholder="Enter your task here">
<button onclick="addTask()">Add Task</button>
<ul id="taskList"></ul>
</div>
<script>
function addTask() {
const input = [Link]("taskInput");
const task = [Link]();
const li = [Link]("li");
[Link] = task;
[Link]("taskList").appendChild(li);
[Link] = "";
}
</script>
</body>
</html>
Explanation:
Description:
This program defines multiple routes using Express. It handles URL route parameters, query
strings, and shows how to build dynamic URLs.
Program:
// Filename: [Link]
const express = require('express');
const app = express();
[Link](3000, () => {
[Link]('Server running at [Link]
});
Explanation:
(b) Question:
Write a program to accept data, retrieve data and delete a specified resource using http
methods.
Description:
This code uses Express with GET, POST, and DELETE HTTP methods. It simulates basic
CRUD using in-memory array.
Program:
// Filename: [Link]
const express = require('express');
const app = express();
[Link]([Link]());
[Link](3001, () => {
[Link]('Server running at [Link]
});
Explanation:
Description:
This example uses middleware to log each request before routing. Middleware can run before
route handlers.
FSD2
Program:
// Filename: [Link]
const express = require('express');
const app = express();
// Custom middleware
[Link]((req, res, next) => {
[Link]('Request URL:', [Link]);
next(); // move to next handler
});
[Link](3002, () => {
[Link]('Server running at [Link]
});
Explanation:
Description:
This program uses the EJS templating engine in ExpressJS to render HTML pages
dynamically with variables.
Program:
Bash :
npm install express ejs
2. Project Structure:
Pgsql :
project/
├── views/
│ └── [Link]
└── [Link]
FSD2
3. File: [Link]
[Link](3003, () => {
[Link]('Server running at [Link]
});
4. File: views/[Link]
<!DOCTYPE html>
<html>
<head><title>EJS Example</title></head>
<body>
<h1>Welcome, <%= name %>!</h1>
</body>
</html>
Explanation:
Description:
This ExpressJS program creates an HTML form and processes submitted data using POST
method.
Program:
Bash :
npm install express
2. File: [Link]
[Link](3004, () => {
[Link]('Server running at [Link]
});
Explanation:
Description:
This program uses cookies and session to store a user's visit count. It remembers the user
across requests.
Program:
Bash :
npm install express express-session cookie-parser
2. File: [Link]
}));
[Link](3005, () => {
[Link]('Server running at [Link]
});
Explanation:
Description:
This simple login system checks hardcoded credentials and creates a session if login is
successful.
Program:
Bash :
npm install express express-session body-parser
2. File: [Link]
[Link](session({
secret: 'secretKey',
resave: false,
saveUninitialized: true
}));
[Link](3006, () => {
[Link]('Server running at [Link]
});
Explanation:
Description:
This program connects to MongoDB using Mongoose and performs simple Create, Read,
Update, and Delete (CRUD) operations on a student database.
Bash :
npm install express mongoose body-parser
FSD2
2. File: [Link]
[Link]('mongodb://[Link]:27017/mydb')
.then(() => [Link]('Connected to MongoDB'))
.catch(err => [Link](err));
// Create
[Link]('/students', async (req, res) => {
const student = new Student([Link]);
await [Link]();
[Link]('Student added!');
});
// Read
[Link]('/students', async (req, res) => {
const students = await [Link]();
[Link](students);
});
// Update
[Link]('/students/:id', async (req, res) => {
await [Link]([Link], [Link]);
[Link]('Student updated!');
});
// Delete
[Link]('/students/:id', async (req, res) => {
await [Link]([Link]);
[Link]('Student deleted!');
});
[Link](3009, () => {
[Link]('Server running on [Link]
});
Explanation:
Description:
This example shows how frontend and backend connect using REST APIs to display student
data on a single HTML page.
const students = [
{ id: 1, name: "Rahul", age: 20 },
{ id: 2, name: "Priya", age: 21 }
];
[Link](3010, () => {
[Link]('Server running on [Link]
});
Frontend ([Link]):
<!DOCTYPE html>
<html>
<head><title>Student App</title></head>
<body>
<h2>Student List</h2>
<ul id="list"></ul>
<script>
fetch('[Link]
.then(res => [Link]())
.then(data => {
const ul = [Link]('list');
[Link](s => {
const li = [Link]('li');
[Link] = `${[Link]} - ${[Link]} years`;
[Link](li);
});
});
</script>
</body>
</html>
Explanation:
Description:
Program ([Link])
import React from 'react';
import ReactDOM from 'react-dom';
Description:
JSX allows HTML-like syntax in JavaScript. This program shows how JSX looks in React.
Program:
const element = (
<div>
<h2>Hello JSX!</h2>
<p>This is a JSX paragraph.</p>
</div>
);
[Link](element, [Link]('root'));
(c) Question: Write a program for creating and nesting components (function
and class).
Description:
FSD2
This example demonstrates function and class components nested inside another component.
Program:
import React from 'react';
function Header() {
return <h1>Welcome!</h1>;
}
function App() {
return (
<div>
<Header />
<Message />
</div>
);
}
Description:
Props are used to pass data. State holds data inside a component.
Program:
import React, { useState } from 'react';
function Greeting(props) {
return <h2>Hello, {[Link]}!</h2>;
}
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<Greeting name="Aadi" />
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>
);
}
(b) Question: Write a program to add styles (CSS & Sass Styling) and display
data.
Description:
This program adds simple inline CSS and displays student data.
Program:
const style = {
color: 'blue',
fontSize: '20px'
};
function Student() {
const name = "Ravi";
return <p style={style}>Student Name: {name}</p>;
}
Description:
Program:
function EventDemo() {
const showMsg = () => {
alert('Button clicked!');
};
return (
<button onClick={showMsg}>Click Me</button>
);
}
Description:
This React app conditionally renders content based on a logged-in state. It switches between
"Welcome" and "Please Login".
Program:
// File: [Link]
import React, { useState } from 'react';
function App() {
const [loggedIn, setLoggedIn] = useState(false);
return (
<div>
<h2>{loggedIn ? 'Welcome User!' : 'Please Login'}</h2>
<button onClick={() => setLoggedIn(!loggedIn)}>
{loggedIn ? 'Logout' : 'Login'}
</button>
</div>
);
}
Explanation:
Description:
This React app displays a list of fruits using map() to render them in an unordered list.
Program :
// File: [Link]
import React from 'react';
function App() {
const fruits = ['Apple', 'Banana', 'Cherry'];
return (
<div>
<h2>Fruit List</h2>
<ul>
FSD2
Explanation:
Description :
React Router allows switching between pages without reloading the browser. It helps in
building a single-page application with multiple views.
Program ([Link]):
// Step 1: Install router
// npm install react-router-dom
function Home() {
return <h2>This is Home Page</h2>;
}
function About() {
return <h2>This is About Page</h2>;
}
function App() {
return (
<Router>
<nav>
<Link to="/">Home</Link> | <Link to="/about">About</Link>
</nav>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/about" element={<About />} />
</Routes>
</Router>
);
FSD2
Explanation:
React Router handles page switching without refreshing the page. Route matches the URL,
and Link is used for navigation.
Description :
React updates the UI automatically when the state or props change. Here, we change the
screen by updating the state.
Program :
import React, { useState } from 'react';
function App() {
const [message, setMessage] = useState("Welcome!");
return (
<div>
<h2>{message}</h2>
<button onClick={handleClick}>Click Me</button>
</div>
);
}
Explanation:
State is updated using setMessage(), which causes React to re-render the screen with the
new message.
Description:
Hooks like useState allow functional components to manage state. Before hooks, state was
only in class components. Now, it's easier and cleaner in functions.
FSD2
Program ([Link]):
import React, { useState } from 'react';
function App() {
const [count, setCount] = useState(0); // useState hook
return (
<div>
<h2>Count: {count}</h2>
<button onClick={() => setCount(count + 1)}>Increase</button>
</div>
);
}
Explanation:
The useState hook creates a count variable that updates when the button is clicked. The UI
updates automatically when state changes.
Description :
Data is passed from parent to child using props. This is the simplest way to share data
between React components.
Program ([Link]):
import React from 'react';
function Child(props) {
return <h3>Hello, {[Link]}</h3>;
}
function App() {
return (
<div>
<h2>Welcome Message</h2>
<Child name="Student" />
</div>
);
}
Explanation:
App sends the name to Child using props. The child component uses [Link] to show
personalized content.
FSD2
Description:
A to-do app helps users add and delete tasks. It uses React's state to manage the task list and
update the UI when tasks change.
Program ([Link]):
import React, { useState } from 'react';
function App() {
const [task, setTask] = useState(""); // stores input task
const [tasks, setTasks] = useState([]); // stores all tasks
return (
<div>
<h2>To-do List</h2>
<input
type="text"
value={task}
onChange={(e) => setTask([Link])}
placeholder="Enter task"
/>
<button onClick={addTask}>Add</button>
<ul>
{[Link]((t, index) => (
<li key={index}>
{t} <button onClick={() => deleteTask(index)}>❌</button>
</li>
))}
</ul>
</div>
);
}
Explanation:
We use useState for the input field and the task list. On clicking "Add", it stores the task
and updates the list. Clicking "❌" removes that task.
Description:
MongoDB Atlas is a cloud-based database service. We can store, manage, and access
MongoDB databases online without installing it locally.
1. Go to [Link]
2. Create a free account or log in.
3. Click "Create" → Choose Shared → Select AWS and region (like Mumbai).
4. Create a username and password.
5. Add IP address: Choose Allow access from anywhere ([Link]/0).
6. Click "Connect" → Choose Connect your application.
7. Copy the connection string like:
Bash :
mongodb+srv://<username>:<password>@[Link]/mydb?
retryWrites=true&w=majority
Description :
These queries help insert, read, update, and delete documents from a collection in MongoDB.
Explanation:
Description:
MongoDB allows creation of databases and collections dynamically. It also provides
commands to delete (drop) them when not needed.
// Drop collection
[Link]()
// Drop database
[Link]()
Explanation:
FSD2
(b) Question : Write MongoDB queries to work with records using find(),
limit(), sort(), createIndex(), aggregate().
Description:
MongoDB supports powerful queries for filtering, limiting results, sorting, indexing for fast
search, and aggregation for data analysis.
// Limit to 2 students
[Link]().limit(2)
Explanation:
Description:
This program creates a simple to-do list backend where you can add, view, and delete tasks
using RESTful APIs built with NodeJS and ExpressJS. Data is stored in memory for
simplicity.
// Add a task
[Link]('/todos', (req, res) => {
const task = { id: idCounter++, text: [Link] };
[Link](task);
[Link]({ message: "Task added", task });
});
// Delete a task by ID
[Link]('/todos/:id', (req, res) => {
const id = parseInt([Link]);
todos = [Link](task => [Link] !== id);
[Link]({ message: "Task deleted" });
});
// Server listening
[Link](3020, () => {
[Link]("To-Do server running at [Link]
});
Explanation:
Description:
This is a simple quiz application built with ReactJS. It shows one question at a time and
tracks the user's score. The quiz ends after all questions are answered.
const questions = [
{
question: "What is the capital of India?",
options: ["Mumbai", "Delhi", "Kolkata", "Chennai"],
answer: "Delhi"
},
{
question: "Which language runs in a web browser?",
options: ["Java", "C", "Python", "JavaScript"],
answer: "JavaScript"
}
];
function QuizApp() {
const [index, setIndex] = useState(0); // Current question index
const [score, setScore] = useState(0); // User score
const [showResult, setShowResult] = useState(false); // Show result flag
return (
<div style={{ textAlign: 'center', marginTop: '50px' }}>
<h2>React Quiz App</h2>
{!showResult ? (
<div>
<h3>{questions[index].question}</h3>
{questions[index].[Link]((opt, i) => (
<button key={i} onClick={() => handleOptionClick(opt)} style={{
margin: '5px' }}>
{opt}
</button>
))}
</div>
FSD2
) : (
<div>
<h3>Quiz Finished!</h3>
<p>Your Score: {score} / {[Link]}</p>
</div>
)}
</div>
);
}
Explanation:
React state is used to track the current question, score, and whether to show results.
On clicking an option, the app checks the answer and moves to the next question.
After the last question, it displays the score.
Description:
This experiment requires students to enroll in an official MongoDB course provided by
MongoDB University. The certification helps build real-world knowledge of database
concepts, CRUD operations, indexing, aggregation, and performance tuning.
Explanation:
This task ensures students gain professional training directly from MongoDB experts.
Completing the certification proves skills in MongoDB and enhances job opportunities in
backend and full-stack development
FSD2