Awp Report
Awp Report
& MongoDB.
Project Title : - Loan Manager
Description : -
The Loan Manager Web Application is designed to streamline the loan processing workflow
for financial institutions or individuals. It facilitates the management of borrowers, loan
issuance, repayment tracking, interest calculations, and reporting. The application provides
an intuitive interface for users to monitor and manage loans efficiently.
Members : -
Patanee Gopal S. ( 220170116029 )
Pansuriya Yash P. ( 220170116028 )
Jadeja Brijrajsinh S. ( 220170116019 )
1. Models : -
54
2. Routes : -
All the API routes are defined here. Each route handles logic related to :
POST /api/login
• Purpose: Authenticate user and issue JWT.
GET /api/user/loans
• Purpose: Fetch loans for the logged-in user.
• Header: Authorization: Bearer JWT_TOKEN
POST /api/user/loans
• Purpose: Submit a new loan application.
GET /api/admin/loans
• Purpose: Get all loan applications (admin only).
PUT /api/admin/loans/:id
• Purpose: Approve or reject a loan
55
Programs : -
backend : -
routes : -
auth.js : -
const express = require("express");
const router = express.Router();
const jwt = require("jsonwebtoken");
const bcrypt = require("bcryptjs");
const User = require("../models/User");
try {
const userExist = await User.findOne({ email });
if (userExist) return res.status(400).json({ msg: "User already exists" });
// Login
router.post("/login", async (req, res) => {
const { email, password } = req.body;
try {
const user = await User.findOne({ email });
if (!user) return res.status(400).json({ msg: "Invalid credentials" });
56
res.json({
token,
user: { id: user._id, username: user.username, role: user.role },
});
} catch (err) {
res.status(500).json({ msg: "Server error" });
}
});
module.exports = router;
loan.js
57
});
await newLoan.save();
res.json({ msg: "Loan application submitted", loan: newLoan });
} catch (err) {
res.status(500).json({ msg: "Server error" });
}
});
try {
const loans = await Loan.find().populate("user", "username email");
res.json(loans);
} catch (err) {
res.status(500).json({ msg: "Server error" });
}
});
try {
const loan = await Loan.findById(req.params.id);
if (!loan) return res.status(404).json({ msg: "Loan not found" });
loan.status = "approved";
await loan.save();
res.json({ msg: "Loan approved" });
} catch (err) {
res.status(500).json({ msg: "Server error" });
58
}
});
try {
const loan = await Loan.findById(req.params.id);
if (!loan) return res.status(404).json({ msg: "Loan not found" });
loan.status = "rejected";
await loan.save();
res.json({ msg: "Loan rejected" });
} catch (err) {
res.status(500).json({ msg: "Server error" });
}
});
module.exports = router;
frontend : -
Dashboard.html : -
<div class="d-flex justify-content-center align-items-center vh-100" style="background:
#eef2f7;">
<div class="card shadow p-5 text-center" style="width: 500px; border-radius: 1.5rem;">
<div class="card-body">
<h2 class="card-title mb-4">Welcome to <span style="color:#007bff;">Loan
Manager</span></h2>
<button
class="btn btn-info btn-lg"
ui-sref="adminLoans"
59
ng-if="isAdmin"
style="border-radius: 0.5rem;"
>
Admin View
</button>
</div>
adminLoan.html
<div class="container mt-5">
<div class="card shadow-lg p-4" style="border-radius: 1rem;">
<div class="card-body">
<h2 class="card-title text-center mb-4" style="color: #007bff;">Admin Loan
Management</h2>
<div class="table-responsive">
<table class="table table-bordered table-hover align-middle text-center">
<thead class="thead-dark">
<tr>
<th>User</th>
<th>Amount</th>
<th>Interest</th>
<th>Term</th>
<th>Status</th>
<th>Applied On</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="loan in allLoans">
<td>{{loan.user.username}}</td>
<td>${{loan.amount}}</td>
<td>{{loan.interestRate}}%</td>
<td>{{loan.term}} months</td>
<td>
<span class="badge" ng-class="{
'badge-secondary': loan.status === 'Pending',
'badge-success': loan.status === 'approved',
60
'badge-danger': loan.status === 'rejected'
}" style="text-transform: uppercase;font-weight: bold;" >
{{loan.status}}
</span>
</td>
<td>{{loan.createdAt | date:'short'}}</td>
<td>
<button
class="btn btn-success btn-sm mb-1"
ng-click="approveLoan(loan._id)"
ng-disabled="loan.status !== 'Pending'"
style="width: 80px;"
>
Approve
</button>
<button
class="btn btn-danger btn-sm"
ng-click="rejectLoan(loan._id)"
ng-disabled="loan.status !== 'Pending'"
style="width: 80px;"
>
Reject
</button>
</td>
</tr>
</tbody>
</table>
</div> </div> </div> </div>
Output : -
61
Rubric Wise Marks Obtained : -
Marks
62