Homespun
Homespun
Homespun
MAREESWARI J
REG. NO :22MCA503
DECLARATION
DATE : (MAREESWARI J)
22MCA503
2
CERTIFICATE
ACKNOWLEDGEMENT
TABLE OF CONTENT
TITLE PAGE NO.
DECLARATION II
ACKNOWLEDGEMENT IV
ABSTRACT 6
CHAPTER-1: INTRODUCTION
5.1 Benefits 26
5
CHAPTER-7: CONCLUSION
6.1 Conclusion 30
APPENDIX-A:
1.Source Code 31
2.Enclousers 43
APPENDIX-B:
BIBLIOGRAPHY 48
6
ABSTRACT
CHAPTER-1 INTRODUCTION
1.1 Overview of the project
The Online Homemade Food Ordering Portal is a digital platform designed
to connect home-based cooks with consumers seeking freshly prepared
homemade meals. It serves as a marketplace where individuals can discover,
order, and enjoy a wide variety of homemade dishes conveniently from their
own homes. The portal caters to both food providers, who are typically
passionate home cooks or smallscale culinary entrepreneurs, and consumers
looking for authentic, homemade cuisine.
The primary aim is to create a digital platform that enables users to easily
discover and order freshly prepared homemade meals from a diverse
range of home-based cooks.
The project seeks to provide users with a convenient and hassle-free way
to access homemade food, eliminating the need for extensive meal
preparation and cooking time.
Users can access a wide selection of homemade dishes from the comfort
of their homes, eliminating the need for extensive meal preparation.
Food providers may undergo verification processes, and the platform may
enforce food safety standards and guidelines to maintain quality and
hygiene standards.
CHAPTER-4
SYSTEM ANALYSIS
16
Registration Login
Login Add Products
Profile View Products
View data -COMMERCE
E View
Orders
User Search Update
Orders Admin
Search result SYSTEM
Update Products
Order Request Remove Products
Order Response Inventory
Logout Log out
17
Home
User Validator
Login
Payment
Order
Admin
Search
Registered Unregistered
Home page
Search
Filters
18
Register
Login
Home
Profile
Search
Logout
Home
Login
Create User
Profile
Search
Logout
19
Providing
Credentials
No
Validation
Yes
Administrator Process
CHAPTER-5
SOFTWARE DEVELOPMENT
5.1 Benefits:
Benefits for Consumers:
1. Development Tools:
• Integrated Development Environment (IDE): Visual Studio Code for
writing and debugging code.
• Git: Version control system for tracking changes in codebase,
collaboration, and managing source code.
• Node.js: JavaScript runtime environment for executing server-side
code.
• npm (Node Package Manager): Package manager for installing and
managing project dependencies.
• MongoDB Compass: GUI tool for interacting with MongoDB
databases during development.
2. Backend Requirements:
• Node.js: JavaScript runtime environment for building the backend
server.
• Express.js: Web application framework for Node.js to create
RESTful APIs and handle HTTP requests.
• MongoDB: NoSQL database for storing product data, user
information, and session management.
• Mongoose: MongoDB object modeling tool for Node.js to interact
with MongoDB databases.
28
3. Frontend Requirements:
• React.js: JavaScript library for building user interfaces and frontend
components.
• React Router: Library for handling client-side routing in React
applications.
• Axios: HTTP client for making API requests from the frontend to the
backend server.
• Redux (optional): State management library for managing
application state in large-scale React applications.
5. Payment Integration:
• Stripe.js: JavaScript library for integrating Stripe payment gateway
into the application for processing online payments securely.
6. Deployment Tools:
• AWS: Cloud hosting platforms for deploying and scaling the
application in production environments.
These software requirements provide the necessary tools and libraries for
developing the System, covering both backend and frontend development,
authentication, payment integration, deployment, testing, and quality
assurance.
30
CHAPTER-6
SYSTEM TESTING AND IMPLEMENTATION SYSTEM TESTING
CHAPTER-7 CONCLUSION
1.1 Homespun/src/App.js
import './App.css';
import Navbar from './Components/Navbar/Navbar'; import {
BrowserRouter,Routes,Route } from 'react-router-dom';
import Home from './Pages/Home';
import ProductsDiplay from
'./Pages/ProductsDiplay'; import Product from
'./Pages/Product'; import Cart from './Pages/Cart';
import LoginSignup from './Pages/LoginSignup';
import Footer from './Components/Footer/Footer'
; function App() { return (
<div >
<BrowserRouter>
<Navbar/>
<Routes>
<Route path='/' element={<Home/>}/>
<Route path='/breakfast' element={< ProductsDiplay banner={null}
category="breakfast" />} />
<Route path='/lunch' element={<
ProductsDiplay banner={null} category="lunch" />} />
<Route path='/dinner' element={<
ProductsDiplay banner={null} category="dinner" />} />
<Route path='/product' element={<Product />}>
<Route path=':productId' element={<Product/>}/>
</Route>
<Route path='/cart' element={<Cart />} />
<Route path='/login' element={<LoginSignup />} />
</Routes>
<Footer/>
</BrowserRouter>
</div>
);
33
1.2 Homespun/src/Components/CartItem.js
{all_product.map((e)=>{ if(cart
Items[e.id]>0)
{
return (
<div className="cartitems-format cartitems-main">
<img src={e.image} alt="" className='carticon-producticon' />
<p>{e.name}</p>
<p> ₹{e.new_price} </p>
<button
className='cartitemsquantity'>{cartItems[e.id]}</button>
<p> ₹{e.new_price * cartItems[e.id]} </p>
<img style={{width: '30px', height: '30px'}}
className='remove' src={remove_icon} onClick={()=>{removeFromCart(e.id)}}
alt="" />
<hr />
</div>)
}
return null;
})}
34
<div className="cartitems-down">
<div className="cartitems-total">
<h1>cart totals</h1>
<div>
<div className="cartitems-total-item">
<p>subtotal</p>
<p> ₹{getTotalCartAmount()}</p>
{/* <p> {total} </p> */}
</div>
<hr />
<div className="cartitems-total-item">
<p>shipping fee</p>
<p>free</p>
</div>
<hr />
<div className="cartitems-total-item">
<h3>total</h3>
<h3> ₹{getTotalCartAmount()} </h3>
</div>
</div>
<button>proceed to checkout</button>
</div>
</div>
</div>
)
}
1.3 Homespun/src/Components/Display.js
<div className="display-star">
<img src={star_icon} alt="" />
<img src={star_icon} alt="" />
<img src={star_icon} alt="" />
<img src={star_icon} alt="" />
<img src={stardull_icon} alt="" />
<p>(47)</p>
</div>
<div className="display-prices">
<div className="display-oldprice">
₹{product.old_price}
</div>
<div className="display-newprice">
₹{product.new_price}
</div>
</div>
<div className="display-discription">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur,
error eius, neque unde accusantium impedit ratione aspernatur reiciendis
necessitatibus eum quaerat! Culpa incidunt iure consequatur similique itaque
repudiandae amet odit!
</div>
<button onClick={()=> {addToCart(product.id)}} > ADD TO CART</button>
</div>
</div>
)
}
1.4 Homespun/src/Components/Navbar.js
return (
<div className='navbar'>
<div className='nav-left'>
<img src={logo_big} alt=''/>
<p>HomeSpun</p>
36
</div>
<ul>
<li onClick={()=>{setMenu('home')}} > <Link className='link'
style={{textDecoration: 'none' }} to='/'>Home</Link>{menu===
'home'?<hr/>:<></>} </li>
<li onClick={()=>{setMenu('break-fast')}}><Link className='link'
style={{textDecoration: 'none' }} to='/breakfast'>Break-Fast</Link> {menu===
'break-fast'?<hr/>:<></>}</li>
<li onClick={()=>{setMenu('lunch')}} > <Link
className='link' style={{textDecoration: 'none' }} to='/lunch'>Lunch</Link>
{menu=== 'lunch'?<hr/>:<></>}</li>
<li onClick={()=>{setMenu('dinner')}} > <Link className='link'
style={{textDecoration: 'none' }} to='/dinner'>Dinner</Link> {menu===
'dinner'?<hr/>:<></>}</li>
</ul>
<div className='nav-right'>
{localStorage.getItem('auth-token')
?<button
onClick={()=>{localStorage.removeItem('authtoken');window.location .replace('/')}
}>Logout</button>:
<Link style={{textDecoration: 'none' }}
to='/login'><button>Login</button></Link>
}
{/* <Link style={{textDecoration: 'none' }}
to='/login'><button>Login</button></Link> */}
<Link style={{textDecoration: 'none' }} to='/cart'><img src={cart_icon}
alt=''/></Link>
<div className='cart-count'> {getTotalCartItems()} </div>
</div>
</div>
)
}
1.5 Homespun/src/Context/ShopContext.js
}
return cart;
}
useEffect(()=>{
fetch('http://localhost:4000/allproducts')
.then((response)=>response.json())
.then((data)=>setAll_Product(data))
},[])
}
const removeFromCart = (itemId)=>{ setCartItems((prev)=>({...prev,
[itemId]:prev[itemId]-1}))
}
const getTotalCartAmount = ()
=> { let totalAmount = 0;
for(const item in cartItems){
if(cartItems[item]>0){
let itemInfo = all_product.find((itemss)=>itemss.id === Number
(item)) totalAmount += itemInfo.new_price *
cartItems[item];
} }
return totalAmount;
}
const getTotalCartItems =()
=>{ let totalItems = 0;
for(const item in cartItems){
if(cartItems[item]>0){
totalItems+= cartItems[item];
} }
return totalItems;
}
)
}
1.6 Homespun/src/LoginSignup.jsx
const [state,setState] =
useState("Login"); const [formData,
setFormData] =
useState({ username:"",
password:"", email:""
})
const changeHandler= (e)=>{ setFormData({...formData,
[e.target.name]:e.target.value})
}
const login = async
()=>{ console.log("login function exicuted",
formData); let responseData; await
fetch('http://localhost:4000/login',
{ method:'POST', headers:{
Accept:'application/form-data',
'Content-Type':'application/json',
},
body:JSON.stringify(formData), }).then((response)=>
response.json()) .then((data)=>responseData=data)
if(responseData.success)
{ localStorage.setItem('auth-
token',responseData.token);
window.location.replace("/");
}
else{ alert(responseData
.errors )
}
}
const signup = async
()=>{ console.log("signup function exicuted",
formData); let responseData; await
39
fetch('http://localhost:4000/signup',
{ method:'POST', headers:{
Accept:'application/form-data',
'Content-Type':'application/json',
},
body:JSON.stringify(formData),
}).then((response)=>
response.json()) .then((data)=>responseData=data)
if(responseData.success){ localStorage.setItem('auth-
token',responseData.token);
window.location.replace("/");
}
else{ alert(responseData
.errors )
}
}
return
(
<div>
<div className="signup">
<div className="container">
<form>
<h1>{state}</h1>
<div className="fields">
{state === "Sign Up"?<input name='username'
value={formData.username} onChange={changeHandler} type="text"
placeholder='Your Name' />:<></>}
<input type="email" name='email' value={formData.email}
onChange={changeHandler} placeholder=' Email Address' />
<input type="password" name='password'
value={formData.password} onChange={changeHandler} placeholder='Password' />
</div>
<button type='button' onClick={() => {state === "Login"?
login() : signup() }} >Continue</button>
{state === "Sign Up"?<p className="loginsignup-login">
Already have an account? <span
onClick={()=>{setState("Login")}} > Login here </span>
</p> :<p className="loginsignup-login">
Create an account? <span onClick={()=>{setState("Sign
Up")}} > Click here </span>
</p>}
<div className="agree">
<input type="checkbox" name="" id="" />
<p>By continuing , i agree to the terms of use & privacy
policy.</p>
</div>
</form>
</div>
</div>
</div>
40
)
}
1.7 Homespun/Backend/index.js
//api creation
app.get("/",
(req,res)=>{
res.send("Express App is Running")
})
const storage =
multer.diskStorage({ destination:
'./upload/images', filename:
(req,file,cb)=>{
return cb(null,`${file.fieldname}_${Date.now()}$
{path.extname(file.originalname)}`)
}
}
)
app.post("/upload",upload.single('product'),
(req,res)=>{ res.json({ success:1, image_url:
`http://localhost:${port}/images/${req.file.filename}`
})
})
const Product =
mongoose.model("Product",{ id:{
type: Number, required: true,
}, name:{
type: String,
required: true,
}, image:{
type: String,
required: true,
}, category:
{ type:
String,
required: true,
},
new_price:
{ type:
Number,
required: true,
},
old_price:
{ type:
Number,
required: true,
}, date:{
type: Date,
default: Date.now,
},
available:{
type: Boolean,
default: true,
},
})
app.post('/addproduct', async (req, res)=>{
app.post('/removeproduct',
async(req,res)=>{ await
Product.findOneAndDelete({id:req.body.id});
console.log("Removed");
res.json({ success:true,
name:req.body.name,
})
})
app.get('/allproducts', async(req,res)=>{
let products = await Product.find({});
console.log("All Products Fetched");
res.send(products);
})
}, date:{
type:Date,
default:Date.now,
}
})
})
await user.save();
const data = {
user:{
id:user.id
}
}
const token = jwt.sign(data,'secret_ecom');
res.json({success:true,token})
})
} }
const token = jwt.sign(data,'secret_ecom');
res.json({success:true,token});
}
else{ res.json({success:false,errors:"Wrong
Password"});
44
} }
else{ res.json({success:false,errors:"Wrong Email
address"})
}
})
app.listen(port,(error)=>{ if(!error)
{ console.log("Server is running on port " +
port);
}
else{ console.log("Error : "
+ error);
}
})
Admin Page:
Cart Page:
2.7 List of products added in cart & user able to remove it.
48
Product Page:
49
APPENDIX-B
1.BIBLIOGRAPHY
1.https://www.w3schools.com/nodejs/
2. https://www.javatpoint.com/nodejs-tutorial
3. https://www.w3schools.com/REACT/DEFAULT.ASP
4. https://www.geeksforgeeks.org/react-tutorial/
5. https://www.javatpoint.com/reactjs-tutorial