A TypeScript-based REST API backend for an AI-powered job application and recruitment platform. This system manages job postings, job applications, and integrates with OpenAI for intelligent features and Clerk for authentication.
- Job Management: Create, read, update, and delete job postings
- Job Applications: Submit and manage job applications
- AI Integration: OpenAI integration for intelligent features
- Authentication: Clerk-based authentication and authorization
- Authorization Middleware: Role-based access control
- MongoDB Database: NoSQL database with Mongoose ODM
- TypeScript: Fully typed for better development experience
- Error Handling: Global error handling middleware
Before running this project, ensure you have:
- Node.js (v16 or higher)
- npm or yarn
- MongoDB instance (local or MongoDB Atlas)
- Clerk account and API keys
- OpenAI API key
-
Clone the repository
git clone https://github.com/savanisgithub/AIDF-back-end.git cd AIDF-back-end -
Install dependencies
npm install
-
Set up environment variables
Create a
.envfile in the root directory with the following variables:CONNECTION_STRING=mongodb://localhost:27017/your-database-name # Or for MongoDB Atlas: # CONNECTION_STRING=mongodb+srv://<username>:<password>@cluster.mongodb.net/<dbname>?retryWrites=true&w=majority CLERK_SECRET_KEY=your_clerk_secret_key CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key OPENAI_API_KEY=your_openai_api_key PORT=8000
Important Notes:
- Replace
<username>,<password>, and<dbname>with your actual MongoDB credentials - URL-encode special characters in your password
- Get Clerk keys from your Clerk Dashboard
- Get OpenAI API key from OpenAI Platform
- Replace
npm run devnpm startThe server will start on http://localhost:8000 (or the PORT specified in your .env file).
| Method | Endpoint | Description | Authentication | Authorization |
|---|---|---|---|---|
| GET | /jobs |
Get all jobs | No | No |
| POST | /jobs |
Create a new job | Yes | Admin only |
| GET | /jobs/:id |
Get job by ID | Yes | No |
| PUT | /jobs/:id |
Update a job | No | No |
| DELETE | /jobs/:id |
Delete a job | No | No |
| Method | Endpoint | Description | Authentication | Authorization |
|---|---|---|---|---|
| POST | /jobApplications |
Submit a job application | Yes | No |
| GET | /jobApplications |
Get all job applications | Yes | Admin only |
| GET | /jobApplications/:id |
Get job application by ID | Yes | Admin only |
AIDF-back-end/
├── src/
│ ├── api/ # API routes and middleware
│ │ ├── middleware/
│ │ │ ├── authorization-middleware.ts
│ │ │ └── global-error-handler.ts
│ │ ├── jobApplications.ts
│ │ └── jobs.ts
│ ├── application/ # Business logic layer
│ │ ├── jobApplicatons.ts
│ │ ├── jobs.ts
│ │ └── rating.ts
│ ├── domain/ # Domain models and errors
│ │ └── errors/
│ │ ├── forbidden-error.ts
│ │ ├── not-found-error.ts
│ │ ├── unauthorized-errors.ts
│ │ └── validation-error.ts
│ ├── infrastructure/ # Database and schemas
│ │ ├── schemas/
│ │ │ ├── job.ts
│ │ │ └── jobApplication.ts
│ │ ├── db.ts
│ │ └── jobs.ts
│ └── index.ts # Application entry point
├── .env # Environment variables
├── nodemon.json # Nodemon configuration
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── README.md # This file
- Runtime: Node.js
- Language: TypeScript
- Framework: Express.js
- Database: MongoDB with Mongoose ODM
- Authentication: Clerk
- AI: OpenAI API
- Validation: Zod
- CORS: cors middleware
- Development: nodemon, ts-node
This API uses Clerk for authentication:
- Authentication: Protected routes require a valid Clerk session token in the request headers
- Authorization: Admin-only routes check user roles using the
AuthorizationMiddleware
To access protected endpoints, include the Clerk session token in your request headers:
Authorization: Bearer <your-clerk-token>
Jobs include the following default questions for applicants:
- Share your academic background and highlight key programming concepts you've mastered. How has your education shaped your current tech skill set?
- Describe your professional development, emphasizing any certifications obtained. How have these certifications enriched your technical abilities, and can you provide an example of their practical application?
- Discuss notable projects in your programming experience. What challenges did you face, and how did you apply your skills to overcome them? Highlight the technologies used and the impact of these projects on your overall growth as a professional.
If you encounter ENOTFOUND errors:
- Check your connection string in
.env - For MongoDB Atlas: Ensure your IP is whitelisted in Atlas Network Access
- Test DNS resolution (Windows PowerShell):
nslookup -type=SRV _mongodb._tcp.your-cluster.mongodb.net
- Flush DNS cache:
ipconfig /flushdns - URL-encode special characters in your password
If port 8000 is already in use, change the PORT in your .env file.
savanisgithub
- GitHub: @savanisgithub