A comprehensive Django REST Framework based backend for a Job Portal platform that connects recruiters with candidates. Features include role-based authentication, job posting management, and email notifications.
- User roles: Recruiter and Candidate
- JWT-based authentication
- Role-specific permissions and access control
- Secure password hashing
- Email-based password reset
- Welcome emails on registration
- Password reset functionality
- Role-specific email templates
- HTML formatted emails
- Secure credential storage in .env
- Complete CRUD operations for job postings
- Role-based access control
- Job status management (Draft, Published, Closed, Archived)
- Comprehensive job details
- Job type categorization
- Salary range specification
- Application tracking
- Python 3.12
- Django REST Framework
- JWT Authentication
- SQLite Database
- SMTP Email Integration
-
Clone the Repository
git clone <repository-url> cd intern_backend_project
-
Install Dependencies
pip install -r requirements.txt
-
Environment Setup Create a
.envfile in the root directory with the following configurations:EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend EMAIL_HOST=smtp.gmail.com EMAIL_PORT=587 EMAIL_USE_TLS=True EMAIL_HOST_USER=your-email@gmail.com EMAIL_HOST_PASSWORD=your-app-password DEFAULT_FROM_EMAIL=your-email@gmail.com
Replace the email credentials with your own.
-
Database Setup
python manage.py migrate
-
Run the Development Server
python manage.py runserver
POST /api/v1/auth/register/
Content-Type: application/json
{
"email": "user@example.com",
"password": "secure_password",
"confirm_password": "secure_password",
"first_name": "John",
"last_name": "Doe",
"role": "CANDIDATE", // or "RECRUITER"
"username": "user@example.com"
}POST /api/v1/auth/token/
Content-Type: application/json
{
"email": "user@example.com",
"password": "secure_password"
}# Request Password Reset
POST /api/v1/auth/password/forgot/
Content-Type: application/json
{
"email": "user@example.com"
}
# Reset Password
POST /api/v1/auth/password/reset/
Content-Type: application/json
{
"password": "new_password",
"confirm_password": "new_password",
"token": "reset_token",
"uidb64": "user_id_b64"
}GET /api/v1/jobs/
Authorization: Bearer <your_token>POST /api/v1/jobs/
Authorization: Bearer <your_token>
Content-Type: application/json
{
"title": "Senior Python Developer",
"description": "Job description...",
"job_type": "FULL_TIME",
"location": "New York, NY",
"salary_min": 80000,
"salary_max": 120000,
"deadline": "2025-07-18T23:59:59Z",
"requirements": "Required skills...",
"responsibilities": "Job responsibilities...",
"company_name": "Tech Corp",
"company_description": "About company...",
"experience_required": 5,
"skills_required": "Python, Django...",
"benefits": "Health insurance..."
}GET /api/v1/jobs/{job_uid}/
Authorization: Bearer <your_token>PATCH /api/v1/jobs/{job_uid}/
Authorization: Bearer <your_token>
Content-Type: application/json
{
"title": "Updated Title",
...
}# Publish Job
POST /api/v1/jobs/{job_uid}/publish/
Authorization: Bearer <your_token>
# Close Job
POST /api/v1/jobs/{job_uid}/close/
Authorization: Bearer <your_token>
# Archive Job
POST /api/v1/jobs/{job_uid}/archive/
Authorization: Bearer <your_token>GET /api/v1/jobs/dashboard/
Authorization: Bearer <your_token>Response:
{
"total_published_jobs": 5,
"total_closed_jobs": 2,
"total_applications": 25,
"total_candidates_hired": 3,
"total_candidates_rejected": 8
}POST /api/v1/applications/
Authorization: Bearer <your_token>
Content-Type: multipart/form-data
{
"job": "job_uid",
"cover_letter": "I am excited to apply...",
"resume": <file>,
"expected_salary": 90000,
"availability_date": "2024-03-01"
}GET /api/v1/applications/
Authorization: Bearer <your_token>GET /api/v1/jobs/{job_uid}/applications/
Authorization: Bearer <your_token>GET /api/v1/applications/{application_uid}/
Authorization: Bearer <your_token>POST /api/v1/applications/{application_uid}/change_status/
Authorization: Bearer <your_token>
Content-Type: application/json
{
"status": "ACCEPTED" // Valid statuses: PENDING, REVIEWED, SHORTLISTED, REJECTED, ACCEPTED
}class User(AbstractBaseUser, PermissionsMixin, BaseModel):
username = CharField(max_length=50, unique=True)
email = EmailField(unique=True)
first_name = CharField(max_length=50)
last_name = CharField(max_length=50)
role = CharField(choices=RoleChoices.choices)
is_staff = BooleanField(default=False)
is_superuser = BooleanField(default=False)class Job(BaseModel):
title = CharField(max_length=255)
description = TextField()
recruiter = ForeignKey(User, related_name='posted_jobs')
job_type = CharField(choices=JobTypeChoices)
location = CharField(max_length=255)
salary_min = DecimalField()
salary_max = DecimalField()
deadline = DateTimeField()
requirements = TextField()
responsibilities = TextField()
status = CharField(choices=JobStatusChoices)
company_name = CharField(max_length=255)
company_description = TextField()
experience_required = IntegerField()
skills_required = TextField()
benefits = TextField()
is_featured = BooleanField()
views_count = IntegerField()
applications_count = IntegerField()class JobApplication(BaseModel):
job = ForeignKey(Job, related_name='applications')
candidate = ForeignKey(User, related_name='job_applications')
cover_letter = TextField()
status = CharField(choices=ApplicationStatusChoices)
resume = FileField(upload_to='resumes/')
expected_salary = DecimalField()
availability_date = DateField()
class Meta:
unique_together = ('job', 'candidate')class UserProfile(BaseModel):
user = OneToOneField(User, related_name="profile")
photo = ImageField(upload_to="profile_pictures/")
bio = TextField()
date_of_birth = DateField(null=True)
gender = CharField(choices=GenderChoices.choices)The API implements comprehensive role-based access control:
- User registration
- Login (token generation)
- Password reset request
- Password reset confirmation
- View published jobs
- View job details
- View company information
- Filter and search jobs
- Apply for jobs
- View own job applications
- Update own job applications
- Create new job postings
- Edit own job postings
- Delete own job postings
- Manage job status (Draft/Publish/Close/Archive)
- View all own jobs
- View job applications for own jobs
- Update application status (Accept/Reject/Under Review)
Run the test suite:
python manage.py testThe project includes tests for:
- User registration
- Email functionality
- Role-based authorization
- API endpoints
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details