Recruitment Project
Recruitment Project
Backend - server.js
const express = require('express');
const mongoose = require('mongoose');
const cors = require('cors');
mongoose.connect('mongodb+srv://yourusername:[email protected]/recruitment',
{ useNewUrlParser: true, useUnifiedTopology: true })
.then(() => console.log('MongoDB Connected'))
.catch(err => console.log(err));
Backend - models/Job.js
const mongoose = require('mongoose');
Backend - models/Application.js
const mongoose = require('mongoose');
Backend - models/Interview.js
const mongoose = require('mongoose');
Frontend - index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Job Listings</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Job Listings</h1>
<div id="job-list"></div>
<script src="script.js"></script>
</body>
</html>
Frontend - apply.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Apply for Job</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Apply for a Job</h1>
<form id="apply-form">
<input type="text" id="name" placeholder="Your Name" required>
<input type="email" id="email" placeholder="Your Email" required>
<input type="text" id="resume" placeholder="Resume Link" required>
<input type="datetime-local" id="interviewDate" required>
<button type="submit">Submit Application</button>
</form>
<script src="script.js"></script>
</body>
</html>
Frontend - style.css
body {
font-family: Arial, sans-serif;
margin: 20px;
}
h1 {
text-align: center;
}
form {
display: flex;
flex-direction: column;
width: 300px;
margin: auto;
}
input, button {
margin: 10px 0;
padding: 10px;
}
Frontend - script.js
fetch('http://localhost:5000/jobs')
.then(response => response.json())
.then(jobs => {
const jobList = document.getElementById('job-list');
jobs.forEach(job => {
jobList.innerHTML += `
<div>
<h2>${job.title}</h2>
<p>${job.company} - ${job.location}</p>
<a href="apply.html">Apply</a>
</div>
`;
});
});
document.getElementById('apply-form')?.addEventListener('submit', function(event) {
event.preventDefault();
const applicationData = {
candidateName: document.getElementById('name').value,
candidateEmail: document.getElementById('email').value,
resumeLink: document.getElementById('resume').value,
interviewDate: document.getElementById('interviewDate').value
};
fetch('http://localhost:5000/applications', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(applicationData)
})
.then(response => response.json())
.then(data => alert("Application Submitted!"))
.catch(error => console.error('Error:', error));
});