A comprehensive backend system for Jobs3, a modern job marketplace platform similar to Upwork. This Node.js/Express backend provides a full-featured API for connecting freelancers, employees, employers, and clients with intelligent job matching, real-time communication, and AI-powered search capabilities.
- Multi-Role User System: Supports Freelancers, Employees, Employers, and Clients
- Job/Gig Management: Create, browse, and manage job postings with multiple payment types (fixed-price and hourly)
- Proposal System: Submit and manage proposals for jobs
- Contract Management: Handle contracts between clients and freelancers/employees
- Real-Time Messaging: Socket.io-based instant messaging between users
- Reviews & Ratings: Comprehensive review system for completed projects
- Portfolio Management: Freelancers and employees can showcase their work portfolios
- Recent Views Tracking: Track recently viewed profiles and gigs
- Visit Analytics: Track profile and portfolio visits
- AI-Powered Job Search: OpenAI GPT-4 integration for intelligent job matching and search
- Vector Search with Pinecone: Semantic search capabilities using Pinecone vector database
- Automated Job Syncing: Cron jobs for automatic job synchronization and updates
- Email Notifications: Nodemailer integration for email communications
- Telegram Bot Integration: Telegram bot support for notifications
- File Storage: AWS S3 integration for scalable file storage
- Image Processing: Sharp library for image optimization
- Referral System: User referral tracking and management
- Node.js: Runtime environment
- Express.js: Web application framework
- MongoDB: NoSQL database with Mongoose ODM
- Socket.io: Real-time bidirectional communication
- JWT: JSON Web Tokens for authentication
- OpenAI API: GPT-4 for AI-powered features
- Pinecone: Vector database for semantic search
- LangChain: AI application framework
- AWS S3: Cloud file storage
- GridFS: MongoDB file storage system
- Sharp: Image processing library
- Multer: File upload handling
- bcryptjs: Password hashing
- Nodemailer: Email service
- node-cron: Task scheduling
- moment-timezone: Date/time handling
- Compression: Response compression
- Morgan: HTTP request logger
jobs3-backend/
├── app.js # Express app configuration
├── index.js # Server entry point with Socket.io setup
├── package.json # Dependencies and scripts
├── vercel.json # Vercel deployment configuration
│
├── controllers/ # Business logic controllers
│ ├── applyGig.js
│ ├── clientGig.js
│ ├── contract.js
│ ├── employeeGig.js
│ ├── employerGig.js
│ ├── freelancerGig.js
│ ├── job.js
│ ├── message.js
│ ├── pinecone.js
│ ├── profile.js
│ ├── proposal.js
│ ├── reviews.js
│ └── user.js
│
├── models/ # Mongoose data models
│ ├── User.js
│ ├── Profile.js
│ ├── ClientsGig.js
│ ├── EmployerGig.js
│ ├── EmployeeGig.js
│ ├── freelancerGig.js
│ ├── Contract.js
│ ├── Proposal.js
│ ├── Reviews.js
│ └── ...
│
├── routes/ # API route definitions
│ ├── user.js
│ ├── job.js
│ ├── clientGig.js
│ ├── freelancerGig.js
│ ├── employerGig.js
│ ├── employeeGig.js
│ ├── proposal.js
│ ├── message.js
│ ├── contract.js
│ └── ...
│
├── middlewares/ # Custom middleware
│ ├── auth.js # JWT authentication
│ ├── errorHandler.js # Error handling
│ ├── asyncHandler.js # Async error wrapper
│ └── socketAuth.js # Socket.io authentication
│
├── database/ # Database configuration
│ └── databaseCon.js # MongoDB connection
│
├── utils/ # Utility functions
│ ├── openai.js # OpenAI API integration
│ ├── pinecone-client.js # Pinecone client setup
│ ├── s3Client.js # AWS S3 client
│ ├── mailer.js # Email service
│ ├── socketServices.js # Socket.io services
│ ├── uploadJobs.js # Job synchronization
│ └── ...
│
└── public/ # Static files
└── uploads/ # Uploaded files
Before you begin, ensure you have the following installed:
- Node.js (v14 or higher)
- npm or yarn
- MongoDB (local or cloud instance like MongoDB Atlas)
- AWS Account (for S3 storage)
- OpenAI API Key
- Pinecone Account (for vector search)
-
Clone the repository
git clone <repository-url> cd jobs3-backend
-
Install dependencies
npm install # or yarn install -
Set up environment variables Create a
.envfile in the root directory:# Server Configuration PORT=5846 NODE_ENV=development # Database MONGODB_URL=mongodb://localhost:27017/jobs3 # or for MongoDB Atlas: # MONGODB_URL=mongodb+srv://username:[email protected]/jobs3 # JWT Configuration JWT_SECRETKEY=your-secret-key-here JWT_EXPIRE=1d # AWS S3 Configuration AWS_ACCESS_KEY_ID=your-aws-access-key AWS_SECRET_ACCESS_KEY=your-aws-secret-key AWS_REGION=us-east-1 AWS_BUCKET_NAME=your-bucket-name # OpenAI Configuration OPENAI_API_KEY=your-openai-api-key # Pinecone Configuration PINECONE_API_KEY=your-pinecone-api-key PINECONE_ENVIRONMENT=your-pinecone-environment PINECONE_INDEX_NAME=your-index-name # Email Configuration (Nodemailer) EMAIL_HOST=smtp.gmail.com EMAIL_PORT=587 EMAIL_USER=[email protected] EMAIL_PASS=your-email-password # Telegram Bot (Optional) TELEGRAM_BOT_TOKEN=your-telegram-bot-token
-
Start the development server
npm start # or yarn startThe server will start on
http://localhost:5846(or the port specified in your.envfile).
http://localhost:5846/api/v1
POST /user/register- Register a new userPOST /user/login- User loginGET /user/profile- Get user profile (protected)PUT /user/profile- Update user profile (protected)
GET /jobs/ai-search/:searchKey- AI-powered job searchGET /client_gig- Get client gigsPOST /client_gig- Create client gig (protected)GET /freelancer_gig- Get freelancer gigsPOST /freelancer_gig- Create freelancer gig (protected)GET /employer_gig- Get employer gigsPOST /employer_gig- Create employer gig (protected)GET /employee_gig- Get employee gigsPOST /employee_gig- Create employee gig (protected)
POST /proposal- Submit a proposal (protected)GET /proposal- Get proposals (protected)PUT /proposal/:id- Update proposal (protected)
POST /contract- Create a contract (protected)GET /contract- Get contracts (protected)PUT /contract/:id- Update contract (protected)POST /extend_request- Request contract extension (protected)
- Real-time messaging via Socket.io
GET /message- Get message history (protected)POST /message- Send message (protected)
POST /review- Submit a review (protected)GET /review- Get reviews (protected)
GET /freelancer_portfolio- Get freelancer portfoliosPOST /freelancer_portfolio- Create/update portfolio (protected)GET /employee_portfolio- Get employee portfoliosPOST /employee_portfolio- Create/update portfolio (protected)
GET /profile- Get profilesPUT /profile- Update profile (protected)GET /visit_freelancer- Track freelancer visitsGET /visit_portfolio- Track portfolio visits
GET /recentView- Get recently viewed items (protected)POST /recentView- Add to recent views (protected)
The API uses JWT (JSON Web Tokens) for authentication. Include the token in the Authorization header:
Authorization: Bearer <your-jwt-token>
Protected routes require a valid JWT token. The token is generated upon login and expires after the time specified in JWT_EXPIRE.
The backend uses Socket.io for real-time communication. Key events include:
- Connection: Connect to the server
- Message Events: Send and receive messages in real-time
- User Status: Track online/offline status
- Notifications: Real-time notifications for various events
Socket connections are authenticated using the socketAuth middleware. Include the JWT token when connecting:
const socket = io('http://localhost:5846', {
auth: {
token: 'your-jwt-token'
}
});The platform uses OpenAI GPT-4 and Pinecone vector database for intelligent job matching:
- Semantic Search: Find jobs based on meaning, not just keywords
- Job Recommendations: AI-powered job recommendations for users
- Profile Matching: Match freelancers/employees with relevant jobs
Automated cron jobs sync and update job listings, ensuring the vector database stays current with the latest job postings.
The project includes vercel.json for easy deployment on Vercel:
-
Install Vercel CLI:
npm i -g vercel
-
Deploy:
vercel
-
Set environment variables in Vercel dashboard
Ensure all environment variables are set in your production environment:
- MongoDB connection string
- AWS credentials
- OpenAI API key
- Pinecone credentials
- JWT secret
- Email service credentials
The system includes automated cron jobs for:
- Job synchronization with Pinecone
- Sending email recommendations
- Updating job statuses
- Cleaning up expired data
The platform supports four main user roles:
- Freelancer: Independent contractors offering services
- Employee: Full-time or part-time employees
- Employer: Companies posting job opportunities
- Client: Clients posting project requirements
Users can have multiple roles simultaneously.
Key database models include:
- User: User accounts and authentication
- Profile: Extended user profiles with skills, experience, etc.
- ClientsGig: Job postings by clients
- EmployerGig: Job postings by employers
- FreelancerGig: Service offerings by freelancers
- EmployeeGig: Job applications by employees
- Contract: Contracts between parties
- Proposal: Job proposals
- Reviews: Reviews and ratings
- Message: Chat messages
- Notification: System notifications
- Password hashing with bcryptjs
- JWT-based authentication
- CORS configuration
- Input validation
- Error handling middleware
- File upload security
The platform uses Nodemailer for:
- User registration confirmations
- Password reset emails
- Job recommendations
- Contract notifications
- Proposal updates
Currently, no test suite is configured. To add testing:
npm install --save-dev jest supertest- Fork the repository
- Create a 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
ISC License
For support and questions, please contact the development team or open an issue in the repository.
- Enhanced AI matching algorithms
- Advanced analytics dashboard
- Payment gateway integration
- Mobile app API support
- Enhanced security features
- Comprehensive test coverage
- API documentation with Swagger/OpenAPI
Built with ❤️ for the Jobs3 marketplace platform